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

Upgrade all files to Python 3.7+ syntax #486

Merged
merged 3 commits into from
Mar 30, 2022
Merged

Upgrade all files to Python 3.7+ syntax #486

merged 3 commits into from
Mar 30, 2022

Conversation

adamjstewart
Copy link
Collaborator

pyupgrade is a tool similar to black and isort that auto-formats code to use language features introduced in newer versions of Python. This PR runs pyupgrade on the code base and adds a CI test to ensure that all code uses modern language features.

I'm actually hesitant to add this to CI. The developer of pyupgrade is the same person who develops git pre-commit hooks. This developer has a history of rude comments and dismissive remarks towards users who open issues or suggest new features. For example, pyupgrade doesn't work unless you manually specify a list of all files you want to upgrade (hence $(find . -name "*.py")) because the developer couldn't understand why anyone would possibly want to use this tool outside of a commit hook (asottile/pyupgrade#40). Similarly, we have to duplicate all tool flags and dependencies in .pre-commit-config.yaml because the developer didn't understand why anyone would want to use something as silly as pyproject.toml (pre-commit/pre-commit#1165, pre-commit/pre-commit#2056).

With that aside, the tool itself is very useful. It will help greatly in modernizing our type hints for newer Python versions. So even if we don't add it to CI, we should still use it to update the repo from time to time.

@github-actions github-actions bot added datasets Geospatial or benchmark datasets documentation Improvements or additions to documentation models Models and pretrained weights testing Continuous integration testing labels Mar 29, 2022
@adamjstewart adamjstewart merged commit f20f02a into main Mar 30, 2022
@adamjstewart adamjstewart deleted the pyupgrade branch March 30, 2022 16:29
remtav pushed a commit to remtav/torchgeo that referenced this pull request May 26, 2022
* Upgrade all files to Python 3.7+ syntax

* Update contributing guide

* Move pyupgrade to correct section
@adamjstewart adamjstewart mentioned this pull request Jul 11, 2022
@adamjstewart adamjstewart added this to the 0.3.0 milestone Jul 11, 2022
yichiac pushed a commit to yichiac/torchgeo that referenced this pull request Apr 29, 2023
* Upgrade all files to Python 3.7+ syntax

* Update contributing guide

* Move pyupgrade to correct section
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datasets Geospatial or benchmark datasets documentation Improvements or additions to documentation models Models and pretrained weights testing Continuous integration testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants