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

an option to use the currently executing python version to determine what the rewrite target is #768

Open
asottile opened this issue Dec 12, 2022 · 7 comments

Comments

@asottile
Copy link
Owner

discussed a bit with @hynek on twitter -- mostly need to bikeshed a name

basically an alternative to the --py36-plus options but instead uses the currently running python

@hynek
Copy link

hynek commented Dec 15, 2022

For posterity: my main motivation here is that I use pyupgrade 100% via pre-commit and currently have to change both the default Python version to run all tools and the target version for pyupgrade whenever I upgrade an app to a newer Python version.

@lev-blit
Copy link

maybe have a fallback of detected version if no --py36-plus option is specified?
seems like changing the min_version argument to have a default of sys.version_info[0:2] would do the trick

@asottile
Copy link
Owner Author

no, unexplainable implicit behaviours are bad -- this will be an explicit setting

@lev-blit
Copy link

perhaps a mutually exclusive option named --detect-version?

@DjLegolas
Copy link

DjLegolas commented Jan 27, 2023

I think that we can use a parameter --currpy-plus which will set min_version = sys.version_info[:2].
The name is still not final 🤣
Something like:

    parser.add_argument(
        '--currpy-plus',
        action='store_const', dest='min_version', const=sys.version_info[:2],
    )

@hynek
Copy link

hynek commented Mar 15, 2023

OK I think I would like to modify my feature request!

pyupgrade --requires-python-plus that looks at my packaging metadata and uses the requires-python field – for all I care just by parsing pyproject.toml and setup.cfg. That's what Black is doing now and kinda is what one would expect? I would go as far as saying that should be the default.

@hugovk
Copy link
Contributor

hugovk commented Mar 15, 2023

Using requires-python from pyproject.toml would be nice but it's been rejected before (#688 (comment)):

no thanks -- that would involve reading configuration files of which I don't want anything to do with that complexity

Also:

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

No branches or pull requests

5 participants