Skip to content

Commit

Permalink
🔧 Make linting stricter
Browse files Browse the repository at this point in the history
  • Loading branch information
spapanik committed Dec 13, 2024
1 parent 54be844 commit dd4199a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 68 deletions.
89 changes: 25 additions & 64 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ classifiers = [
requires-python = ">=3.9"
dependencies = [
"dj_settings~=6.0",
"pyutilkit~=0.5",
"pyutilkit~=0.8.0",
]

[project.urls]
Expand Down Expand Up @@ -78,7 +78,11 @@ target-version = [

[tool.mypy]
check_untyped_defs = true
disallow_any_decorated = false # (strict mode): Remove all Any types
disallow_any_explicit = false # (strict mode): Remove all Any types
disallow_any_expr = false # many builtins are Any
disallow_any_generics = true
disallow_any_unimported = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
Expand All @@ -87,13 +91,18 @@ disallow_untyped_defs = true
extra_checks = true
ignore_missing_imports = true
no_implicit_reexport = true
show_column_numbers = true
show_error_codes = true
strict_equality = true
warn_return_any = true
warn_redundant_casts = true
warn_return_any = true
warn_unused_configs = true
warn_unused_ignores = true
warn_unreachable = true
warn_unused_configs = true

[[tool.mypy.overrides]]
module = "tests.*"
disallow_any_decorated = false # mock.MagicMock is Any

[tool.ruff]
src = [
Expand All @@ -103,73 +112,25 @@ target-version = "py39"

[tool.ruff.lint]
select = [
"A",
"ANN",
"ARG",
"ASYNC",
"B",
"BLE",
"C4",
"COM",
"DTZ",
"E",
"EM",
"ERA",
"EXE",
"F",
"FA",
"FBT",
"FIX",
"FLY",
"FURB",
"G",
"I",
"ICN",
"INP",
"ISC",
"LOG",
"N",
"PGH",
"PERF",
"PIE",
"PL",
"PT",
"PTH",
"PYI",
"Q",
"RET",
"RSE",
"RUF",
"S",
"SIM",
"SLF",
"SLOT",
"T10",
"TCH",
"TD",
"TID",
"TRY",
"UP",
"W",
"YTT",
"ALL",
]
ignore = [
"ANN401",
"COM812",
"E501",
"FIX002",
"PLR09",
"TD002",
"TD003",
"TRY003",
"ANN401", # (strict mode): Remove all Any types
"C901", # Adding a limit to complexity is too arbitrary
"COM812", # Avoid magic trailing commas
"D10", # Not everything needs a docstring
"D203", # Prefer `no-blank-line-before-class` (D211)
"D213", # Prefer `multi-line-summary-first-line` (D212)
"E501", # Avoid clashes with black
"PLR09", # Adding a limit to complexity is too arbitrary
"T201", # (pyutilkit 0.9): use SGROutput instead of print
]

[tool.ruff.lint.per-file-ignores]
"tests/**" = [
"FBT001",
"PLR2004",
"PT011",
"S101",
"FBT001", # Test arguments are handled by pytest
"PLR2004", # Tests should contain magic number comparisons
"S101", # Pytest needs assert statements
]

[tool.ruff.lint.flake8-tidy-imports]
Expand Down
4 changes: 2 additions & 2 deletions tests/yamk/command/test_make/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

def test_make_raises_on_missing_target() -> None:
make_command = get_make_command(cookbook_name=COOKBOOK, target="missing_target")
with pytest.raises(ValueError):
with pytest.raises(ValueError, match="No recipe to build missing_target"):
make_command.make()


def test_make_raises_on_missing_requirement() -> None:
make_command = get_make_command(
cookbook_name=COOKBOOK, target="missing_requirement"
)
with pytest.raises(ValueError):
with pytest.raises(ValueError, match="No recipe to build .*missing_target"):
make_command.make()


Expand Down
4 changes: 2 additions & 2 deletions tests/yamk/lib/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_topological_sort_detects_cycles() -> None:
node.add_requirement(root)
dag = DAG(root)
dag.add_node(node)
with pytest.raises(ValueError):
with pytest.raises(ValueError, match="Cyclic dependencies detected"):
dag.topological_sort()


Expand All @@ -101,7 +101,7 @@ def test_c3_sort_detects_cycles() -> None:
node.add_requirement(root)
dag = DAG(root)
dag.add_node(node)
with pytest.raises(ValueError):
with pytest.raises(ValueError, match="Cannot compute c3_sort"):
dag.c3_sort()


Expand Down

0 comments on commit dd4199a

Please sign in to comment.