Repository navigation
style: adopt the shared ruff, mypy and pre-commit - #231
Merged
Merged
Conversation
Format all Python code with ruff format, line length 88, as in cloud-registry and FOCA; strip trailing whitespace and end files with one newline, as the pre-commit hooks of the shared standard will require. Only formatting changes, so that the commit can be ignored by git blame; the shared lint rules, strict mypy and pre-commit follow separately. Vendored GA4GH specifications are kept as published; the README, docs and community files are left to the docs work. flake8 accepts the line length and slice spacing of ruff format until ruff replaces it. Refs #206 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adopt the standard shared by FOCA and FOCA apps, as in cloud-registry: ruff with the rule set B C4 D E F G I PL RUF S SIM UP W and Google docstrings everywhere; strict mypy (disallow_untyped_defs, disallow_any_generics, warn_unused_ignores) over pro_tes and tests; pre-commit with pre-commit-hooks, ruff, semgrep (Flask debug mode, unverified JWTs), gitleaks, actionlint, ast-grep (untyped FOCA config access, Pydantic v1 dict(), string status codes) and mypy. Remove flake8, pylint and their settings. Fix the findings: lazy logging arguments, explicit errors instead of asserts in app code, request timeouts in the integration tests, docstrings of the TES models, complete type hints. get_task() had the type str as the default of its task identifier. tests/unitTest is excluded until #207 fixes or removes it. List the reformat (#227) in .git-blame-ignore-revs, and fix the file ends and trailing whitespace of docs/middleware.md and docs/images/overview.svg, which the reformat left to the docs work. CI runs pre-commit in one "Static code analysis" job; actions are pinned to commits, runs of a pull request are cancelled when superseded, and jobs have timeouts. Closes #206 Closes #116 Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # .flake8 # pro_tes/ga4gh/tes/models.py # pro_tes/ga4gh/tes/server.py # pro_tes/ga4gh/tes/task_runs.py # pro_tes/middleware/middleware_handler.py # pyproject.toml # tests/conftest.py # tests/test_integration/test_endpoints.py # tests/test_tasks.py
pylint is replaced by ruff, whose PL rules need none of the suppressions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quote $GITHUB_ENV, which shellcheck (via actionlint) flags on the runners. A request whose JSON body the middlewares removed is a server fault (MiddlewareException, 500), not a bad request. Tasks without logs fail loudly again when the forward is recorded, instead of the forward being dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # .github/workflows/checks.yaml # docs/middleware.md
Reviewer's GuideThis PR replaces Flake8/Pylint with the shared Ruff, mypy, and pre-commit standard, adds pinned quality and security checks—including Semgrep and ast-grep rules—and integrates them into reproducible CI. It also updates the application and tests with complete typing, lazy logging, explicit error handling, docstrings, request timeouts, and related documentation/CI adjustments. Sequence diagram for typed task creation and middleware validationsequenceDiagram
participant Client
participant TaskRuns
participant MiddlewareHandler
participant TES
participant Database
Client->>TaskRuns: create_task()
alt missing request body
TaskRuns-->>Client: BadRequest
else body present
TaskRuns->>MiddlewareHandler: apply_middlewares()
alt middleware removes body
MiddlewareHandler-->>TaskRuns: MiddlewareException
else body remains
TaskRuns->>Database: _write_doc_to_db()
TaskRuns->>TES: create_task()
TES-->>TaskRuns: remote_task_id
TaskRuns->>Database: _update_doc_in_db()
end
end
Flow diagram for project-specific anti-pattern checksflowchart TD
Python[Python source] --> AstGrep[ast-grep scan]
AstGrep --> ConfigRule[FOCA config attribute access]
AstGrep --> PydanticRule[Pydantic v1 dict call]
AstGrep --> StatusRule[String HTTP status code]
Python --> Semgrep[Semgrep scan]
Config[Configuration files] --> Semgrep
Semgrep --> FlaskRule[Flask debug mode]
Semgrep --> JwtRule[Unverified JWT decode]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Replace flake8 and pylint in the development docs with the pre-commit workflow, as in cloud-registry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
uniqueg
marked this pull request as ready for review
October 22, 2026 19:51
This was referenced Oct 22, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #206 and #116. This is part 2: the reformat landed in #227 and is listed in
.git-blame-ignore-revs. Supersedes PR #180.This adopts the standard that FOCA and FOCA apps share, exactly as in cloud-registry.
pyproject.toml): rule setB C4 D E F G I PL RUF S SIM UP Wwith cloud-registry's ignores, Google docstrings everywhere, line length 88.disallow_untyped_defs,disallow_any_genericsandwarn_unused_ignoresoverpro_tesandtests. Packages without type information (connexion, py-tes, geopy, ip2geotools, gunicorn) get overrides instead of inline ignores..pre-commit-config.yaml, hooks pinned to commits):.semgrep/pro-tes.yml: Flask debug mode, unverified JWTs..dict(), string status codes.gitleaks-all), builds the distributions and checks the wheel..flake8,pylintrc) and all pylint comments.BadRequest;MiddlewareException(500);ValueError(500, as before).StatesusesClassVar.get_task()had the typestras the default of its task identifier.docs/images/overview.svggets a final newline only, as agreed with the docs work (docs/middleware.mdwas removed ondevin docs: switch to a MkDocs Material site #228).mkdocs.ymlis excluded fromcheck-yamlbecause of its!ENVtag, anddocs/hooks.pyis type-checked, both as in cloud-registry. The CIpublishjob also needs the newdocsjob.docs/development.mddescribes the pre-commit workflow instead of flake8 and pylint, using the cloud-registry wording.tests/unitTestis excluded from ruff and mypy until test: add app test harness and fix the tests #207 fixes or removes it.Metadatabugs intask_runs.pykeep typed ignores marked "fixed with fix: task listing, timestamps and relay bugs #208".Full review lane.
How it was verified
pre-commit run --all-files: all hooks pass, as doespre-commit run --all-files --hook-stage manual gitleaks-all.pytest tests --ignore=tests/unitTest --ignore=tests/test_integration: 41 passed.$GITHUB_ENV) and all medium findings (dead pylint comments) are fixed.CI: all checks pass (Static code analysis, including actionlint with ShellCheck on the runner; documentation build; unit tests on 3.10 and 3.12; Compose integration tests; CodeQL).
mkdocs build --strictalso passes locally.Declined review findings
CONTRIBUTING.mdstill mentions flake8 and pylint (quality, medium). It is left to docs: add code of conduct and contributing guide #211 (draft PR docs: add code of conduct and contributing guide #222), which will align it with this PR._set_logs()always sets the logs. The cancel paths fail with 500 as before.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Adopt the shared FOCA code-quality standard across formatting, typing, security checks, documentation, and CI.
Bug Fixes:
Enhancements:
Build:
CI:
Documentation:
Tests:
Chores: