Repository navigation
Description
Why?
Linting, formatting and type checking are spread over three tools with old versions (flake8 6.1 with Flake8-pyproject, black, mypy 0.971), run only in CI, and mypy checks only cloud_registry/, not tests/. #31 asks to fix the errors that mypy is told to ignore (ignore_missing_imports = true in pyproject.toml and five # type: ignore comments in cloud_registry/ga4gh/registry/); its blocker, elixir-cloud-aai/foca#144, is closed.
There is no pre-commit configuration, so contributors find problems only after pushing, and there are no checks for security issues or for project-specific anti-patterns (e.g. f-strings in logging calls, HTTP status codes as strings such as the "201" in postServiceInfo, Pydantic v1 .dict()).
How?
- Replace flake8 and black with ruff (lint + format), configured in
pyproject.toml; keep the line length at 88. Reformat in one commit and add it to.git-blame-ignore-revs. - Upgrade mypy, check
cloud_registry/andtests/, and remove the ignores that are no longer needed now that FOCA ships type information (py.typed, added after 0.12.1) (resolves Bug: Fix mypy ignored cases #31). - Add
.pre-commit-config.yamlwith ruff, mypy, semgrep (pinned local rules, e.g. Python and secrets rule sets checked into.semgrep/) and ast-grep (sgconfig.ymlwith repo-specific rules for the anti-patterns above). - Run the same hooks in CI (
pre-commit run --all-files) instead of separate lint steps. - Document the setup in the README (see Docs: update README and Read the Docs build #80).
Acceptance criteria
-
pre-commit run --all-filespasses locally and in CI. - mypy checks
cloud_registry/andtests/without blanket ignores. - A string status code or an f-string in a logging call fails the ast-grep check.
Resolves #31.
Dependencies: after #65 (FOCA 0.14).
Activity