Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F821 not recognizing requires-python in pyproject.toml #14813

Open
CNSeniorious000 opened this issue Dec 6, 2024 · 3 comments
Open

F821 not recognizing requires-python in pyproject.toml #14813

CNSeniorious000 opened this issue Dec 6, 2024 · 3 comments
Labels
configuration Related to settings and configuration question Asking for support or clarification

Comments

@CNSeniorious000
Copy link

I tried to use anext and aiter in a project configured with requires-python = "~=3.10", but Ruff still complaining

F821 Undefined name `anext`. Consider specifying `requires-python = ">= 3.10"` or `tool.ruff.target-version = "py310"` in your `pyproject.toml` file.
  |
8 | async def main():
9 |     print(anext(g()))
  |           ^^^^^ F821
  |

Here is a reproduction repository:

https://github.com/CNSeniorious000/ruff-F821-repro

See these workflow logs:

https://github.com/CNSeniorious000/ruff-F821-repro/actions/runs/12198261365/job/34029609880#step:5:13

@charliermarsh
Copy link
Member

If you add [tool.ruff] (even followed by nothing else) to your pyproject.toml, then we'll read the requires-python.

@charliermarsh charliermarsh added the question Asking for support or clarification label Dec 6, 2024
@CNSeniorious000
Copy link
Author

Thank you! I'm surprised this workaround is needed.

@MichaReiser
Copy link
Member

MichaReiser commented Dec 6, 2024

So am I! I'd expect Ruff to pick up the pyproject.toml as the root even if it has no tool.ruff section and there's no other configuration in any ancestor directory. However, that's probably a breaking change

@AlexWaygood AlexWaygood added the configuration Related to settings and configuration label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Related to settings and configuration question Asking for support or clarification
Projects
None yet
Development

No branches or pull requests

4 participants