Skip to content

Emit diagnostics for new syntax as per the target Python version #6591

@dhruvmanila

Description

@dhruvmanila

Our parser doesn't take into account the Python version aka target-version setting while parsing the source code. This means that we would allow having a match statement when the target Python version is 3.9 or lower. We want to signal this to the user.

One solution is to provide a diagnostic after the parsing is done. This diagnostic would indicate to the user that there's a syntax usage which isn't valid for the current target version. This is what's being done in Rome and Pyright1. We would still continue linting the file and emit other diagnostics as well.

Following is a non-exhaustive list of syntax changes with the minimum required Python version:

3.13

3.12

3.11

3.10

3.9

3.8

Footnotes

  1. Pyright: Type alias statement requires Python 3.12 or newer

Sub-issues

Metadata

Metadata

Assignees

Labels

parserRelated to the parserruleImplementing or modifying a lint rule

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions