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
Use PEP 621's [project.requires-python] field to automatically set --target-version #3124
Comments
I'm in favour. |
When it makes sense, I'm in favor of moving everything we can to pyproject.toml long as it does not break mypyc etc. etc. |
I looked into this. It should be easy enough to augment the However, parsing that field is another matter. We would probably have to rely on a third party library if we really want to do this properly. And I'm not sure it's worth introducing a dependency in order to be able to automatically infer the target version. Input is appreciated! |
FWIW, I hacked something similiar in my GitHub workflow to feed |
@kdeldycke If a new version of python is out you will need to modify the file no ? Can we erase the check <= 11 |
I indeed looked at poetry-core for the version parsing. But if you wanted to use their version parser (it's quite extensive), you'd have to add it as a dependency, which feels quite bad. |
I hope to see this feature being added and maybe in a way that it would make it easy to reuse in other tools as updating min-python in so many tools is a PITA and almost a guarantee that you will forget to update one of them. |
We could also probably use |
I'll first add it as a hard dependency - we can adjust in code review if required. |
That's great, thank you for looking into this! I look forward to the PR :) |
The Requires-Python metadata can be in Would Black only support reading from I usually put it in |
I wouldn't want Black to read other config files than |
Hey @SamirPS, just noticed your comment. Since then I indeed removed the hard-coded check on Since #3219 has been released upstream in |
Agreed @ssbarnea. I had to write some code to produce consistent Python target parameters for Black, Mypy and Pyupgrade. For more details, see my |
PEP 621 provides
project.requires-python
field in pyproject.toml. I expect, that most of the tools will support this field eventually.Each code-related linter and formatter has a setting for supported python version.
Using this field would be good for tool interoperability in the future.
Related: #751 (comment)
The text was updated successfully, but these errors were encountered: