Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7325034
FEAT: switch to `ty` als type checker
redeboer Dec 29, 2025
01b9028
ENH: update `ty` pre-commit hook
redeboer Dec 29, 2025
e0927bc
FIX: import from `typing`
redeboer Dec 29, 2025
a7e0051
FIX: install `ty` in `style` group
redeboer Dec 29, 2025
d052868
ENH: install vscode pylance
redeboer Dec 29, 2025
0b361db
FIX: do not set `rev` if `local` hook
redeboer Dec 29, 2025
a964387
FIX: disable vscode language server
redeboer Dec 29, 2025
5138dfa
DX: install `ty` extension
redeboer Dec 29, 2025
f1194a4
DOC: add `ty` badge
redeboer Dec 29, 2025
d7b4367
ENH: activate more `ty` rules
redeboer Dec 29, 2025
0905dad
FIX: correctly pass multiple values
redeboer Jan 5, 2026
d5917c5
FIX: remove unwanted/recommended extension
redeboer Jan 5, 2026
0865d8c
FIX: allow unicode in JSON dump
redeboer Jan 5, 2026
55bbdce
MAINT: move `ty` badge to back
redeboer Jan 5, 2026
a6d8764
FIX: add `TypeChecker` to API
redeboer Jan 5, 2026
a4e74a0
ENH: remove redundant `--respect-ignore-files`
redeboer Jan 5, 2026
1249d29
ENH: remove redundant `--respect-ignore-files`
redeboer Jan 5, 2026
1704708
MAINT: put args on one row
redeboer Jan 5, 2026
b176c0b
MAINT: use more `from __future__ import annotations`
redeboer Jan 5, 2026
8251678
MAINT: remove support for `typings` dir
redeboer Jan 6, 2026
7280c1e
MAINT: remove outdated lines from gitignore
redeboer Jan 6, 2026
4aafc2b
ENH: update `mypy` badge
redeboer Jan 6, 2026
da3389f
ENH: remove `ty` badge if deactivated
redeboer Jan 6, 2026
a77db30
ENH: update `mypy` and `pyright` pre-commit hooks
redeboer Jan 6, 2026
d7cf34c
ENH: update `tool.pyright`
redeboer Jan 6, 2026
0cb4521
FIX: remove `ty` settings if not selected
redeboer Jan 6, 2026
343126f
ENH: disable autocompletions in `pyright`
redeboer Jan 6, 2026
4d6d35d
ENH: add `mypy` as dependency
redeboer Jan 6, 2026
ab21d65
FIX: update test
redeboer Jan 6, 2026
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
4 changes: 1 addition & 3 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
"docs/conf.py",
"labels/*.toml",
"pyproject.toml",
"pyrightconfig.json",
"typings"
"pyrightconfig.json"
],
"ignoreWords": [
"FURB",
Expand Down Expand Up @@ -113,7 +112,6 @@
"ipykernel",
"ipython",
"mkdir",
"mypy",
"oneline",
"pixi",
"poethepoet",
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ version.py
*.pyc
.coverage
.coverage.*
.mypy*/
.pytest_cache/
__pycache__/
coverage.xml
Expand All @@ -37,4 +36,3 @@ uv.lock
!.readthedocs.yml
!.vscode/*.json
!codecov.yml
!pyrightconfig.json
22 changes: 9 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ ci:
autoupdate_schedule: quarterly
skip:
- check-dev-files
- mypy
- pyright
- self-check
- ty

repos:
- repo: meta
Expand Down Expand Up @@ -51,10 +50,12 @@ repos:
args:
- --allow-labels
- --dependabot=update
- --keep-local-precommit
- --no-pypi
- --pytest-single-threaded
- --repo-name=policy
- --repo-title=ComPWA repository policy
- --type-checker=ty

- id: self-check
name: self-check
Expand Down Expand Up @@ -97,15 +98,10 @@ repos:

- repo: local
hooks:
- id: mypy
name: mypy
entry: mypy
language: system
- id: ty
name: ty
entry: ty check
args: [--output-format=concise]
require_serial: true
types:
- python

- repo: https://github.com/ComPWA/pyright-pre-commit
rev: v1.1.407
hooks:
- id: pyright
language: system
types_or: [python, pyi, jupyter]
5 changes: 3 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"recommendations": [
"astral-sh.ty",
"charliermarsh.ruff",
"christian-kohler.path-intellisense",
"eamodio.gitlens",
Expand All @@ -9,9 +10,7 @@
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"mhutchie.git-graph",
"ms-python.mypy-type-checker",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-vscode.live-server",
"ms-vsliveshare.vsliveshare",
"redhat.vscode-yaml",
Expand All @@ -29,7 +28,9 @@
"ms-python.black-formatter",
"ms-python.flake8",
"ms-python.isort",
"ms-python.mypy-type-checker",
"ms-python.pylint",
"ms-python.vscode-pylance",
"ryanluker.vscode-coverage-gutters",
"travisillig.vscode-json-stable-stringify",
"tyriar.sort-lines"
Expand Down
7 changes: 4 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@
"gitlens.telemetry.enabled": false,
"livePreview.defaultPreviewPath": "docs/_build/html",
"multiDiffEditor.experimental.enabled": true,
"mypy-type-checker.args": ["--config-file=${workspaceFolder}/pyproject.toml"],
"notebook.codeActionsOnSave": {
"notebook.source.organizeImports": "explicit"
},
"notebook.formatOnSave.enabled": true,
"python.analysis.autoImportCompletions": false,
"python.analysis.inlayHints.pytestParameters": true,
"python.defaultInterpreterPath": ".venv/bin/python",
"python.languageServer": "None",
"python.terminal.activateEnvironment": false,
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
Expand All @@ -68,6 +66,9 @@
"telemetry.telemetryLevel": "off",
"testing.coverageToolbarEnabled": true,
"testing.showCoverageInExplorer": true,
"ty.completions.autoImport": false,
"ty.diagnosticMode": "workspace",
"ty.importStrategy": "fromEnvironment",
"yaml.schemas": {
"https://citation-file-format.github.io/1.2.0/schema.json": "CITATION.cff",
"https://json.schemastore.org/github-workflow.json": [
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![ty](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ty/main/assets/badge/v0.json)](https://github.com/astral-sh/ty)

This repository sets the policies for developer environment in repositories if the [ComPWA organization](https://github.com/ComPWA) (See our [Help developing](https://compwa.github.io/develop) page). The policies are automatically enforced through [pre-commit](https://pre-commit.com).

Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"T": "typing.TypeVar",
"Table": "tomlkit.items.Table",
"TOMLDocument": "tomlkit.TOMLDocument",
"TypeChecker": ("obj", "compwa_policy.check_dev_files.ty.TypeChecker"),
"typing_extensions.NotRequired": ("obj", "typing.NotRequired"),
"V": "typing.TypeVar",
}
Expand Down
64 changes: 7 additions & 57 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ doc = [
"sphinx-copybutton",
]
style = [
"mypy",
"ty",
{include-group = "types"},
]
test = [
Expand Down Expand Up @@ -124,32 +124,6 @@ omit = [
]
source = ["src"]

[tool.mypy]
disallow_incomplete_defs = true
disallow_untyped_defs = true
exclude = '.*/compwa_policy/__init__\.py'
files = ["**/*.py"]
show_error_codes = true
warn_unused_configs = true

[[tool.mypy.overrides]]
check_untyped_defs = true
disallow_incomplete_defs = false
disallow_untyped_defs = false
module = ["tests.*"]

[[tool.mypy.overrides]]
ignore_errors = true
module = ["typings.*"]

[[tool.mypy.overrides]]
ignore_missing_imports = true
module = ["ruamel.*"]

[[tool.mypy.overrides]]
ignore_missing_imports = true
module = ["nbformat.*"]

[tool.poe.executor]
isolated = true
no-group = "dev"
Expand Down Expand Up @@ -271,35 +245,6 @@ help = "Selected Python version"
name = "python"
positional = true

[tool.pyright]
reportArgumentType = false
reportGeneralTypeIssues = false
reportIncompatibleMethodOverride = false
reportMissingParameterType = false
reportMissingTypeArgument = false
reportMissingTypeStubs = false
reportOverlappingOverload = false
reportPrivateImportUsage = false
reportPrivateUsage = false
reportReturnType = false
reportUnboundVariable = false
reportUnknownArgumentType = false
reportUnknownLambdaType = false
reportUnknownMemberType = false
reportUnknownParameterType = false
reportUnknownVariableType = false
reportUnnecessaryComparison = false
reportUnnecessaryContains = false
reportUnnecessaryIsInstance = false
reportUntypedFunctionDecorator = false
reportUnusedClass = true
reportUnusedFunction = true
reportUnusedImport = true
reportUnusedVariable = true
typeCheckingMode = "strict"
venv = ".venv"
venvPath = "."

[tool.pytest.ini_options]
addopts = [
"--color=yes",
Expand All @@ -320,7 +265,6 @@ testpaths = [
]

[tool.ruff]
extend-exclude = ["typings"]
preview = true
show-fixes = true
src = [
Expand Down Expand Up @@ -413,3 +357,9 @@ sort_first = [
]
spaces_indent_inline_array = 4
trailing_comma_inline_array = true

[tool.ty.rules]
division-by-zero = "warn"
possibly-missing-import = "warn"
possibly-unresolved-reference = "warn"
unused-ignore-comment = "warn"
29 changes: 22 additions & 7 deletions src/compwa_policy/check_dev_files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
release_drafter,
ruff,
toml,
ty,
update_lock,
uv,
vscode,
Expand Down Expand Up @@ -71,6 +72,7 @@ def main(argv: Sequence[str] | None = None) -> int: # noqa: C901, PLR0915
dev_python_version = __get_python_version(args.dev_python_version)
excluded_python_versions = set(_to_list(args.excluded_python_versions))
package_manager: PackageManagerChoice = args.package_manager
type_checkers: set[ty.TypeChecker] = set(args.type_checker or [])
if CONFIG_PATH.pyproject.exists():
supported_versions = Pyproject.load().get_supported_python_versions()
if supported_versions and dev_python_version not in supported_versions:
Expand Down Expand Up @@ -141,9 +143,10 @@ def main(argv: Sequence[str] | None = None) -> int: # noqa: C901, PLR0915
repo_title,
args.repo_organization,
)
do(mypy.main)
do(pyproject.main, excluded_python_versions)
do(pyright.main, precommit_config)
do(mypy.main, "mypy" in type_checkers, precommit_config)
do(pyright.main, "pyright" in type_checkers, precommit_config)
do(ty.main, type_checkers, args.keep_local_precommit, precommit_config)
do(pytest.main, args.pytest_single_threaded)
do(pyupgrade.main, precommit_config, args.no_ruff)
if not args.no_ruff:
Expand Down Expand Up @@ -199,7 +202,7 @@ def _create_argparse() -> ArgumentParser:
)
parser.add_argument(
"--dependabot",
choices=dependabot.DependabotOption.__args__, # type: ignore[attr-defined]
choices=dependabot.DependabotOption.__args__,
default=None,
help="Leave dependabot.yml untouched ('keep') or sync with ComPWA/policy",
)
Expand Down Expand Up @@ -308,9 +311,15 @@ def _create_argparse() -> ArgumentParser:
help="Specify the Python version for your developer environment",
type=str,
)
parser.add_argument(
"--keep-local-precommit",
action="store_true",
default=False,
help="Do not remove local pre-commit hooks",
)
parser.add_argument(
"--macos-python-version",
choices=[*sorted(PythonVersion.__args__), "disable"], # type:ignore[attr-defined]
choices=[*sorted(PythonVersion.__args__), "disable"],
default="3.10",
help="Run the test job in MacOS on a specific Python version. Use 'disable' to not run the tests on MacOS.",
)
Expand All @@ -334,14 +343,20 @@ def _create_argparse() -> ArgumentParser:
)
parser.add_argument(
"--package-manager",
choices=sorted(conda.PackageManagerChoice.__args__), # type:ignore[attr-defined]
choices=sorted(conda.PackageManagerChoice.__args__),
default="uv",
help="Specify which package manager to use for the project",
type=str,
)
parser.add_argument(
"--type-checker",
action="append",
choices=ty.TypeChecker.__args__,
help="Specify which type checker to use for the project",
)
parser.add_argument(
"--update-lock-files",
choices=update_lock.Frequency.__args__, # type:ignore[attr-defined]
choices=update_lock.Frequency.__args__,
default="outsource",
help=(
"Add a workflow to upgrade lock files, like uv.lock, .pre-commit-config.yml, "
Expand Down Expand Up @@ -451,7 +466,7 @@ def __get_python_version(arg: Any) -> PythonVersion:
if not re.match(r"^3\.\d+$", arg):
msg = f"Invalid Python version: {arg}"
raise ValueError(msg)
return arg # type: ignore[return-value]
return arg


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion src/compwa_policy/check_dev_files/citation.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _convert_zenodo(zenodo: dict) -> CommentedMap:
description = zenodo.get("description")
if description is not None:
converter = HTML2Text()
converter.body_width = None # type: ignore[assignment]
converter.body_width = None
description = converter.handle(description).strip()
citation_cff["abstract"] = PreservedScalarString(description)

Expand Down Expand Up @@ -184,6 +184,7 @@ def add_json_schema_precommit(precommit: ModifiablePrecommit) -> None:
repo_url = "https://github.com/python-jsonschema/check-jsonschema"
idx_and_repo = precommit.find_repo_with_index(repo_url)
if idx_and_repo is None:
repo_idx = 0
repo = Repo(
repo=repo_url,
rev="",
Expand Down
Loading
Loading