Summary
The lint F821 has a false positive with anext.
As pointed out by @MichaReiser, this ultimately is due to having either project.requires-python or tools.ruff.target-version set to a too lower version.
In this instances, it was discovered that Ruff was targeting Python 3.8 (from an erroneous config).
Example
async def foo(iter: AsyncGenerator[str, None]):
assert await anext(iter)
Desired Behaviour
Where a symbol is introduced in a more recent version of Python, Ruff should:
- Still raise F821 as it is strictly correct; but also,
- Inform the use Ruff is assuming Python 3.x, and the symbol in question was only introduced in Python 3.y, and nudge the user to set
reures-python or target-version.
Environment
❯ ruff --version
ruff 0.6.4
❯ python --version
Python 3.12.5
Summary
The lint F821 has a false positive with
anext.As pointed out by @MichaReiser, this ultimately is due to having either
project.requires-pythonortools.ruff.target-versionset to a too lower version.In this instances, it was discovered that Ruff was targeting Python 3.8 (from an erroneous config).
Example
Desired Behaviour
Where a symbol is introduced in a more recent version of Python, Ruff should:
reures-pythonortarget-version.Environment