Skip to content

No need to run flake test session with multiple Python versions? #13000

Closed
@DimitriPapadopoulos

Description

@DimitriPapadopoulos

The flake test session runs:

  • the ruff linter
  • the ruff formatter
  • mypy
  • check-sdist

cryptography/noxfile.py

Lines 205 to 215 in f5fe820

session.run("ruff", "check", ".")
session.run("ruff", "format", "--check", ".")
session.run(
"mypy",
"src/cryptography/",
"vectors/cryptography_vectors/",
"tests/",
"release.py",
"noxfile.py",
)
session.run("check-sdist", "--no-isolation")

This test session is run twice during CI, with two different versions of Python:

- {VERSION: "3.8", NOXSESSION: "flake"}
- {VERSION: "3.13", NOXSESSION: "flake"}

I don't see the need for that:

  • ruff is a Rust program that does not depend on the available version of Python. Instead, the target Python version is defined in:
    requires-python = ">=3.8,!=3.9.0,!=3.9.1"
  • While mypy does target the version of Python that is running mypy by default, the version of Python does not seem relevant:
    • Option --python-version could be used to modify the target version of Python.
    • Most importantly, cryptography lacks checks based on sys.version_info, except for a couple checks detailed in bump mypy #12989 (comment) that are irrelevant for typing. Such checks define different code paths when targeting different versions of Python according to section Python version and system platform checks of the documentation.
    • Even if there were more code paths specific to Python 3.8, testing typing with previous versions of Python doesn't seem useful. Such “legacy” code paths usually do not change much until they disappear and should have been tested at some point in the past with previous versions of Python.
  • I understand the version of Python used to run check-sdist is irrelevant too.

I suggest running the flake test session with Python 3.13 only. If you insist on running mypy with different target versions of Python, I suggest splitting it into ruff, mypy and check-sdist sessions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions