Skip to content

Commit

Permalink
ENH: select ALL Ruff linting rules (#355)
Browse files Browse the repository at this point in the history
* DX: allow use of `typing.Any`
* DX: disable Ruff linting rule `DOC` and `G004`
* DX: disable Ruff rule `FURB140` (`itertools.starmap`)
* DX: select `ALL` Ruff linting rules
* DX: set same test rules for `benchmarks/` directory
* ENH: disable Ruff linting rule `ANN` in notebooks
* ENH: remove redundant lines that are covered with global ignores
* MAINT: address new Ruff linting errors
  • Loading branch information
redeboer authored Aug 5, 2024
1 parent 823b323 commit bd6d69b
Show file tree
Hide file tree
Showing 13 changed files with 190 additions and 185 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"Zenodo"
],
"ignoreWords": [
"FURB",
"MAINT",
"PyPI",
"addopts",
Expand Down
48 changes: 15 additions & 33 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ addopts = [
filterwarnings = [
"error",
"ignore: Importing ErrorTree directly from the jsonschema package is deprecated.*",
"ignore: The `hash` argument is deprecated in favor of `unsafe_hash` and will be removed in or after August 2025.:DeprecationWarning",
]
markers = ["slow: marks tests as slow (deselect with '-m \"not slow\"')"]
testpaths = [
Expand All @@ -215,40 +216,11 @@ docstring-code-format = true
line-ending = "lf"

[tool.ruff.lint]
extend-select = [
"A",
"B",
"BLE",
"C4",
"C90",
"D",
"EM",
"ERA",
"FA",
"I",
"ICN",
"INP",
"ISC",
"N",
"NPY",
"PGH",
"PIE",
"PL",
"Q",
"RET",
"RSE",
"RUF",
"S",
"SIM",
"T20",
"TCH",
"TID",
"TRY",
"UP",
"YTT",
]
ignore = [
"ANN401",
"C408",
"COM812",
"CPY001",
"D101",
"D102",
"D103",
Expand All @@ -258,15 +230,24 @@ ignore = [
"D213",
"D407",
"D416",
"DOC",
"E501",
"FBT",
"FURB101",
"FURB103",
"FURB140",
"G004",
"ISC001",
"PLR0913",
"PLW1514",
"PLW2901",
"PT001",
"PTH",
"S301",
"SIM108",
"UP036",
]
select = ["ALL"]
task-tags = ["cspell"]

[tool.ruff.lint.flake8-tidy-imports]
Expand All @@ -287,14 +268,15 @@ split-on-trailing-comma = false
"docs/conf.py" = ["D100"]
"setup.py" = ["D100"]
"tests/*" = [
"ANN",
"D",
"INP001",
"PGH001",
"PLC2701",
"PLR0913",
"PLR2004",
"PLR6301",
"S101",
"SLF001",
"T20",
]

Expand Down
1 change: 0 additions & 1 deletion src/compwa_policy/check_dev_files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def main(argv: Sequence[str] | None = None) -> int:
release_drafter.main,
args.repo_name,
args.repo_title,
github_pages=args.github_pages,
organization=args.repo_organization,
)
do(mypy.main)
Expand Down
4 changes: 2 additions & 2 deletions src/compwa_policy/check_dev_files/github_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ def __get_package_name() -> str:
if not s.endswith(".egg-info")
]
if candidate_dirs:
return sorted(candidate_dirs)[0]
return sorted(src_dirs)[0]
return min(candidate_dirs)
return min(src_dirs)


def _copy_workflow_file(filename: str) -> None:
Expand Down
14 changes: 5 additions & 9 deletions src/compwa_policy/check_dev_files/release_drafter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,14 @@
from compwa_policy.utilities.yaml import create_prettier_round_trip_yaml


def main(
repo_name: str, repo_title: str, github_pages: bool, organization: str
) -> None:
def main(repo_name: str, repo_title: str, organization: str) -> None:
update_file(CONFIG_PATH.release_drafter_workflow)
_update_draft(repo_name, repo_title, github_pages, organization)
_update_draft(repo_name, repo_title, organization)


def _update_draft(
repo_name: str, repo_title: str, github_pages: bool, organization: str
) -> None:
def _update_draft(repo_name: str, repo_title: str, organization: str) -> None:
yaml = create_prettier_round_trip_yaml()
expected = _get_expected_config(repo_name, repo_title, github_pages, organization)
expected = _get_expected_config(repo_name, repo_title, organization)
output_path = CONFIG_PATH.release_drafter_config
if not os.path.exists(output_path):
yaml.dump(expected, output_path)
Expand All @@ -35,7 +31,7 @@ def _update_draft(


def _get_expected_config(
repo_name: str, repo_title: str, github_pages: bool, organization: str
repo_name: str, repo_title: str, organization: str
) -> dict[str, Any]:
yaml = create_prettier_round_trip_yaml()
config = yaml.load(COMPWA_POLICY_DIR / CONFIG_PATH.release_drafter_config)
Expand Down
Loading

0 comments on commit bd6d69b

Please sign in to comment.