Skip to content

Add a per-file-target-version configuration option #19892

@dmarteau

Description

@dmarteau

Feature

Add a per-file-target-version configuration option like Ruff

Pitch

Actually there is no way with Mypy to enforce python compatibility with older version while having specific parts of code for newer version.

Example:

  • I have a project that must be still globally compatible with Python 3.9, but I include some code that would work with Python 3,12.
  • My testing environment is Python 3,12.
  • Because I want Python 3.9 compatibility I set python_version option to 3.9.
  • Part of the code the support python 3.12 may use if sys.version >= (3, 12) but because my testing environment is 3,12, this statement has no effect and Mypy treat the 3.12 code as en error while it should be checked against 3.12.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions