Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,6 @@ trailing_comma_inline_array = true
division-by-zero = "warn"
possibly-missing-import = "warn"
possibly-unresolved-reference = "warn"

[tool.ty.terminal]
error-on-warning = true
15 changes: 10 additions & 5 deletions src/compwa_policy/check_dev_files/ty.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,26 @@ def _update_vscode_settings(type_checkers: set[TypeChecker]) -> None:

def _update_configuration(pyproject: ModifiablePyproject) -> None:
def _remove_rule(key: str, default: Literal["error", "ignore", "warn"]) -> None:
if ty_config.get(key) == default:
del ty_config[key]
if ty_rules.get(key) == default:
del ty_rules[key]
pyproject.changelog.append(f"Removed tool.ty.rules.{key}")

def _update_rule(key: str, value: Literal["error", "ignore", "warn"]) -> None:
if key not in ty_config:
ty_config[key] = value
if key not in ty_rules:
ty_rules[key] = value
pyproject.changelog.append(f'Set tool.ty.rules.{key} = "{value}"')

ty_config = pyproject.get_table("tool.ty.rules", create=True)
ty_rules = pyproject.get_table("tool.ty.rules", create=True)
_remove_rule("unused-ignore-comment", "warn")
_update_rule("division-by-zero", "warn")
_update_rule("possibly-missing-import", "warn")
_update_rule("possibly-unresolved-reference", "warn")

ty_terminal = pyproject.get_table("tool.ty.terminal", create=True)
if ty_terminal.get("error-on-warning") is not True:
ty_terminal["error-on-warning"] = True
pyproject.changelog.append("Set tool.ty.terminal.error-on-warning = true")


def _update_precommit_config(precommit: ModifiablePrecommit) -> None:
args = CommentedSeq(["--no-progress", "--output-format=concise"])
Expand Down