Skip to content

Fix several rules to handle deferred annotations #20747

@ntBre

Description

@ntBre

Several rules exhibit very different behavior in the presence of deferred annotations, whether from an explicit from __future__ import annotations or on Python 3.14. These include:

  • FAST001
  • FAST003
  • A003
  • PTH210
  • RUF001

You can see the effect of switching the Python version from 3.13 to 3.14 in this commit from #20725.

In addition to the tests modified in the commit above, each of these rules also has a new assert_diagnostics_diff test:

To fix this issue, we should remove all of these diffs.

Micha and Dylan observed that semantic.resolve_name seems to be returning the wrong results now (#20725 (comment)), and I think they suggested possibly making these checks deferred so that we can resolve these lookups differently.

Unless the changes end up being quite small, I think it could make sense to tackle these with one PR per rule.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions