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
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"doclive",
"docnb",
"docnblive",
"dunder",
"envrc",
"fromdict",
"indentless",
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ repos:
)$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.21
rev: v0.16.0
hooks:
- id: ruff-check
args: [--fix]
Expand All @@ -110,7 +110,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/tombi-toml/tombi-pre-commit
rev: v1.2.0
rev: v1.2.4
hooks:
- id: tombi-format
- id: tombi-lint
Expand Down Expand Up @@ -139,7 +139,7 @@ repos:
)$

- repo: https://github.com/astral-sh/ty-pre-commit
rev: v0.0.59
rev: v0.0.63
hooks:
- id: ty
args: [--group=types, --no-default-groups]
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
codeautolink_concat_default = True
copybutton_prompt_is_regexp = True
copybutton_prompt_text = r">>> |\.\.\. " # doctest
copyright = "2023, Common Partial Wave Analysis" # noqa: A001
copyright = "2023, Common Partial Wave Analysis"
default_role = "py:obj"
extensions = [
"_ext.policy_settings",
Expand Down
113 changes: 59 additions & 54 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -327,36 +327,36 @@ line-ending = "lf"

[tool.ruff.lint]
ignore = [
"ANN401",
"C408",
"COM812",
"CPY001",
"D101",
"D102",
"D103",
"D105",
"D107",
"D203",
"D213",
"D407",
"D416",
"DOC",
"E501",
"FBT",
"FURB101",
"FURB103",
"FURB140",
"G004",
"ISC001",
"PLR0913",
"PLW1514",
"PLW2901",
"PT001",
"PTH",
"RUF067",
"S301",
"SIM108",
"UP036",
"any-type",
"if-else-block-instead-of-if-exp",
"incorrect-blank-line-before-class",
"line-too-long",
"logging-f-string",
"missing-copyright-notice",
"missing-dashed-underline-after-section",
"missing-section-name-colon",
"missing-trailing-comma",
"multi-line-summary-second-line",
"non-empty-init-module",
"outdated-version-block",
"pytest-fixture-incorrect-parentheses-style",
"read-whole-file",
"redefined-loop-name",
"reimplemented-starmap",
"single-line-implicit-string-concatenation",
"suspicious-pickle-usage",
"too-many-arguments",
"undocumented-magic-method",
"undocumented-public-class",
"undocumented-public-function",
"undocumented-public-init",
"undocumented-public-method",
"unnecessary-collection-call",
"unspecified-encoding",
"write-whole-file",
]
select = ["ALL"]
task-tags = ["cspell"]
Expand All @@ -371,41 +371,46 @@ split-on-trailing-comma = false
"benchmarks/*" = [
"ANN",
"D",
"INP001",
"PLC2701",
"PLR2004",
"PLR6301",
"RUF069",
"S101",
"S404",
"S603",
"S607",
"SLF001",
"T20",
"assert",
"boolean-type-hint-positional-argument",
"float-equality-comparison",
"implicit-namespace-package",
"import-private-name",
"magic-value-comparison",
"no-self-use",
"private-member-access",
"start-process-with-partial-path",
"subprocess-without-shell-equals-true",
"suspicious-subprocess-import",
]
"docs/*" = [
"E402",
"INP001",
"S101",
"S113",
"T201",
"assert",
"implicit-namespace-package",
"module-import-not-at-top-of-file",
"print",
"request-without-timeout",
]
"docs/conf.py" = ["D100"]
"setup.py" = ["D100"]
"src/compwa_policy/config.py" = ["D100"]
"docs/conf.py" = [
"builtin-variable-shadowing",
"undocumented-public-module",
]
"setup.py" = ["undocumented-public-module"]
"src/compwa_policy/config.py" = ["undocumented-public-module"]
"tests/*" = [
"ANN",
"C901",
"D",
"INP001",
"PLC2701",
"PLR0915",
"PLR2004",
"PLR6301",
"RUF069",
"S101",
"SLF001",
"T20",
"assert",
"boolean-type-hint-positional-argument",
"complex-structure",
"float-equality-comparison",
"implicit-namespace-package",
"import-private-name",
"magic-value-comparison",
"no-self-use",
"private-member-access",
"too-many-statements",
]

[tool.ruff.lint.pydocstyle]
Expand Down
2 changes: 1 addition & 1 deletion src/compwa_policy/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _add(command: Command, name: str, parent: Tree) -> None:


@app.callback(invoke_without_command=True)
def run_everything( # noqa: PLR0917
def run_everything( # ruff: ignore[too-many-positional-arguments]
ctx: typer.Context,
python: Python = None,
dev_python_version: DevPythonVersion = None,
Expand Down
6 changes: 3 additions & 3 deletions src/compwa_policy/cli/_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def check_dev_python_version(args: Arguments) -> int:
if CONFIG_PATH.pyproject.exists():
supported_versions = Pyproject.load().get_supported_python_versions()
if supported_versions and args.dev_python_version not in supported_versions:
print( # noqa: T201
print( # ruff: ignore[print]
f"The specified development Python version {args.dev_python_version} is"
" not listed in the supported Python versions of pyproject.toml:"
f" {', '.join(sorted(supported_versions))}"
Expand Down Expand Up @@ -133,10 +133,10 @@ def _run(args: Arguments, groups: frozenset[Group]) -> int:
run_checks(session, args, ctx, groups=groups)
changes = session.flush()
except PolicyError as exception:
print("\n".join(exception.args)) # noqa: T201
print("\n".join(exception.args)) # ruff: ignore[print]
return 1
if changes:
print("\n--------------------\n".join(changes)) # noqa: T201
print("\n--------------------\n".join(changes)) # ruff: ignore[print]
return 1
return 0

Expand Down
2 changes: 1 addition & 1 deletion src/compwa_policy/cli/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)


def env( # noqa: PLR0917
def env( # ruff: ignore[too-many-positional-arguments]
python: Python = None,
dev_python_version: DevPythonVersion = None,
package_manager: PackageManager = None,
Expand Down
2 changes: 1 addition & 1 deletion src/compwa_policy/cli/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
)


def github( # noqa: PLR0917
def github( # ruff: ignore[too-many-positional-arguments]
python: Python = None,
dev_python_version: DevPythonVersion = None,
allow_labels: AllowLabels = None,
Expand Down
2 changes: 1 addition & 1 deletion src/compwa_policy/cli/nb.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)


def nb( # noqa: PLR0917
def nb( # ruff: ignore[too-many-positional-arguments]
package_manager: PackageManager = None,
dev_python_version: DevPythonVersion = None,
no_binder: NoBinder = None,
Expand Down
2 changes: 1 addition & 1 deletion src/compwa_policy/cli/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)


def python( # noqa: PLR0917
def python( # ruff: ignore[too-many-positional-arguments]
python: Python = None,
dev_python_version: DevPythonVersion = None,
excluded_python_versions: ExcludedPythonVersions = None,
Expand Down
2 changes: 1 addition & 1 deletion src/compwa_policy/env/pixi/_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ def remove_pixi_configuration(session: Session, /) -> None:
if pyproject is None:
return
if pyproject.has_table("tool.pixi"):
del pyproject._document["tool"]["pixi"] # noqa: SLF001
del pyproject._document["tool"]["pixi"] # ruff: ignore[private-member-access]
pyproject.changelog.append("Removed Pixi configuration table")
12 changes: 6 additions & 6 deletions src/compwa_policy/env/pixi/_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ def _rename_workspace_table(config: ModifiablePyproject) -> None:
project = __get_table(config, "project")
workspace = __get_table(config, "workspace", create=True)
workspace.update(project)
if config._source == CONFIG_PATH.pyproject: # noqa: SLF001
del config._document["tool"]["pixi"]["project"] # noqa: SLF001
if config._source == CONFIG_PATH.pyproject: # ruff: ignore[private-member-access]
del config._document["tool"]["pixi"]["project"] # ruff: ignore[private-member-access]
else:
del config._document["project"] # noqa: SLF001 # ty:ignore[invalid-argument-type]
del config._document["project"] # ruff: ignore[private-member-access] # ty:ignore[invalid-argument-type]
msg = 'Renamed "project" table to "workspace" in Pixi configuration'
config.changelog.append(msg)

Expand All @@ -136,7 +136,7 @@ def _define_minimal_project(
channels=["conda-forge"],
platforms=["linux-64"],
)
if config._source == CONFIG_PATH.pixi_toml: # noqa: SLF001
if config._source == CONFIG_PATH.pixi_toml: # ruff: ignore[private-member-access]
pyproject = session.pyproject
if pyproject is not None:
minimal_settings["name"] = pyproject.get_package_name()
Expand Down Expand Up @@ -375,12 +375,12 @@ def ___outsource_cmd(task: Table, other_task_name: str) -> bool:
def __get_table(
config: ModifiablePyproject, key: str, create: bool = False
) -> MutableMapping[str, Any]:
if config._source == CONFIG_PATH.pyproject: # noqa: SLF001
if config._source == CONFIG_PATH.pyproject: # ruff: ignore[private-member-access]
key = f"tool.pixi.{key}"
return config.get_table(key, create=create)


def __has_table(config: Pyproject, key: str) -> bool:
if config._source == CONFIG_PATH.pyproject: # noqa: SLF001
if config._source == CONFIG_PATH.pyproject: # ruff: ignore[private-member-access]
key = f"tool.pixi.{key}"
return config.has_table(key)
2 changes: 1 addition & 1 deletion src/compwa_policy/env/uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _remove_pip_constraint_files() -> Changelog:
def _remove_uv_configuration(pyproject: ModifiablePyproject | None) -> None:
if pyproject is None:
return
readonly_pyproject = pyproject._document # noqa: SLF001
readonly_pyproject = pyproject._document # ruff: ignore[private-member-access]
if "tool" not in readonly_pyproject or "uv" not in readonly_pyproject["tool"]:
return
tool_table = pyproject.get_table("tool")
Expand Down
2 changes: 1 addition & 1 deletion src/compwa_policy/errors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# noqa: D100
# ruff: ignore[undocumented-public-module]
class PolicyError(RuntimeError):
"""Policy violation that is caught by the executor and printed without a traceback."""
2 changes: 1 addition & 1 deletion src/compwa_policy/format/cspell.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def __express_list_of_sections(sections: Sequence[str]) -> str:
else:
sentence += "s "
sentence += ", ".join(sections[:-1])
if len(sections) > 2: # noqa: PLR2004
if len(sections) > 2: # ruff: ignore[magic-value-comparison]
sentence += ","
sentence += " and " + sections[-1]
return sentence
Expand Down
2 changes: 1 addition & 1 deletion src/compwa_policy/format/precommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _sort_hooks(precommit: ModifiablePrecommit) -> None:
precommit.changelog.append(msg)


def __repo_sort_key(repo: Repo) -> tuple[int, str]: # noqa: PLR0911
def __repo_sort_key(repo: Repo) -> tuple[int, str]: # ruff: ignore[too-many-return-statements]
repo_url = repo["repo"]
if repo_url == "meta":
return 0, repo_url
Expand Down
2 changes: 1 addition & 1 deletion src/compwa_policy/github/dependabot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
directories=(CONFIG_PATH.github_workflow_dir.parent,),
patterns=("(.*/)?Manifest\\.toml",),
)
def check(session: Session, args: Arguments, _: CheckContext) -> None: # noqa: C901
def check(session: Session, args: Arguments, _: CheckContext) -> None: # ruff: ignore[complex-structure]
frequency = args.upgrade_frequency

def dump_dependabot_config() -> Changelog:
Expand Down
8 changes: 4 additions & 4 deletions src/compwa_policy/github/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ def check(session: Session, args: Arguments, ctx: CheckContext) -> None:
_recommend_vscode_extension(session)


def _update_cd_workflow( # noqa: C901
def _update_cd_workflow( # ruff: ignore[complex-structure]
session: Session,
/,
no_milestones: bool,
no_pypi: bool,
no_version_branches: bool,
) -> None:
def update() -> Changelog: # noqa: C901
def update() -> Changelog: # ruff: ignore[complex-structure]
yaml = create_prettier_round_trip_yaml()
workflow_path = CONFIG_PATH.github_workflow_dir / "cd.yml"
expected_data = yaml.load(COMPWA_POLICY_DIR / workflow_path)
Expand Down Expand Up @@ -126,7 +126,7 @@ def _update_pr_linting() -> Changelog:
return []


def _update_ci_workflow( # noqa: PLR0917
def _update_ci_workflow( # ruff: ignore[too-many-positional-arguments]
session: Session,
/,
allow_deprecated: bool,
Expand Down Expand Up @@ -174,7 +174,7 @@ def update() -> Changelog:
session.changelog += remove_workflow("clean-cache.yml")


def _get_ci_workflow( # noqa: PLR0917
def _get_ci_workflow( # ruff: ignore[too-many-positional-arguments]
path: Path,
precommit: Precommit,
doc_apt_packages: list[str],
Expand Down
2 changes: 1 addition & 1 deletion src/compwa_policy/python/mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _remove_mypy(session: Session, /) -> None:
if pyproject is None:
return
if pyproject.has_table("tool.mypy"):
del pyproject._document["tool"]["mypy"] # noqa: SLF001
del pyproject._document["tool"]["mypy"] # ruff: ignore[private-member-access]
pyproject.changelog.append("Removed mypy configuration table")
pyproject.remove_dependency("mypy")
precommit.remove_hook("mypy")
Expand Down
2 changes: 1 addition & 1 deletion src/compwa_policy/python/pyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _remove_pyright(session: Session, /) -> None:
msg = f"Removed old pyright configuration file {pyright_config}"
pyproject.changelog.append(msg)
if pyproject.has_table("tool.pyright"):
del pyproject._document["tool"]["pyright"] # noqa: SLF001
del pyproject._document["tool"]["pyright"] # ruff: ignore[private-member-access]
msg = "Removed pyright configuration from pyproject.toml"
pyproject.changelog.append(msg)
pyproject.remove_dependency("pyright")
Expand Down
Loading
Loading