Skip to content

Tooling: ruff, current mypy, pre-commit, semgrep #73

Closed

Description

@uniqueg

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?

  1. 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.
  2. Upgrade mypy, check cloud_registry/ and tests/, 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).
  3. Add .pre-commit-config.yaml with ruff, mypy, semgrep (pinned local rules, e.g. Python and secrets rule sets checked into .semgrep/) and ast-grep (sgconfig.yml with repo-specific rules for the anti-patterns above).
  4. Run the same hooks in CI (pre-commit run --all-files) instead of separate lint steps.
  5. Document the setup in the README (see Docs: update README and Read the Docs build #80).

Acceptance criteria

  • pre-commit run --all-files passes locally and in CI.
  • mypy checks cloud_registry/ and tests/ 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

  1. added
    priority: medium
    type: ci / cd
    type: maintenance
    type: security
    workload: hours
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumtype: ci / cdtype: maintenancetype: securityworkload: hours

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions