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

RFE: infer target-version from project metadata #2039

Closed
scop opened this issue Jan 20, 2023 · 9 comments
Closed

RFE: infer target-version from project metadata #2039

scop opened this issue Jan 20, 2023 · 9 comments
Labels
core Related to core functionality

Comments

@scop
Copy link
Contributor

scop commented Jan 20, 2023

target-version could in many cases be inferred from project metadata:

Would be great to see ruff do that to eliminate one maintenance chore.

Black is moving toward doing that, too. The implementation over there is obviously somewhat different, because they still take a list of target versions whereas ruff takes the minimum one (which I think is the better, yet less flexible approach). Perhaps some of that work can be reused in ruff: psf/black#3219

@charliermarsh
Copy link
Member

Perhaps we can use https://github.com/konstin/pep440-rs from @konstin to power the version parsing?

@ilkersigirci
Copy link

FYI: black#3219 was merged and shipped with black 23.1.0

@manueljacob
Copy link
Contributor

Black’s target version inference is currently broken: psf/black#3581. I’m currently working on a fix and would be happy to port the solution to ruff. However, before that, #2519 should be decided.

@charliermarsh
Copy link
Member

Nice! I'm happy to support target ranges, it's just not totally clear to me what rules they would affect and how.

@JonathanPlasse
Copy link
Contributor

JonathanPlasse commented Feb 24, 2023

Black have different behaviors depending on the versions for example. Maybe ruff formatter should do the same.

@konstin
Copy link
Member

konstin commented Feb 25, 2023

one thing to consider is that the behavior in psf/black#3581 (>3.7 still implying 3.7 code styles) is most likely unintended and imho >3.7 (as opposed to >3.7.1 or >=3.7) should raise a warning (or you could emit linter errors for ruff's own configuration :D) EDIT: See also Y006 in flake8-pyi ("Use only < and >= for version comparisons. Comparisons involving > and <= may produce unintuitive results when tools do use the full sys.version_info tuple.")

@JonathanPlasse
Copy link
Contributor

Should we close this issue?

@konstin
Copy link
Member

konstin commented Mar 13, 2023

yep

@charliermarsh
Copy link
Member

I created #3487 to track inferring this info at runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to core functionality
Projects
None yet
Development

No branches or pull requests

6 participants