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

Use isort to order import statements #641

Merged
merged 7 commits into from
Nov 8, 2022
Merged

Use isort to order import statements #641

merged 7 commits into from
Nov 8, 2022

Conversation

juhoinkinen
Copy link
Member

@juhoinkinen juhoinkinen commented Nov 7, 2022

PR #640 introduced Black style and tool for checking and autoformatting code. However, Black does not care about the order of import statements, but isort does. Using isort a developer does not need worry about the order of imports.

This PR contains similar changes as the one for Black.

Manual local usage

Just run this to sort imports:

isort .

Automated local usage

isort can check the import order automatically when committing by adding this line to .git/hooks/pre-commit:

isort . --check-only --diff

CI usage

isort check is added to the linting job in GH Actions.

@codecov
Copy link

codecov bot commented Nov 7, 2022

Codecov Report

Base: 99.58% // Head: 99.58% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (9629754) compared to base (f5bc54d).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 9629754 differs from pull request most recent head 5bdc77f. Consider uploading reports for the commit 5bdc77f to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #641      +/-   ##
==========================================
- Coverage   99.58%   99.58%   -0.01%     
==========================================
  Files          87       87              
  Lines        5991     5972      -19     
==========================================
- Hits         5966     5947      -19     
  Misses         25       25              
Impacted Files Coverage Δ
annif/analyzer/simplemma.py 100.00% <ø> (ø)
annif/analyzer/snowball.py 100.00% <ø> (ø)
annif/analyzer/voikko.py 100.00% <ø> (ø)
annif/backend/backend.py 100.00% <ø> (ø)
annif/backend/mixins.py 95.12% <ø> (ø)
annif/corpus/combine.py 100.00% <ø> (ø)
annif/corpus/types.py 100.00% <ø> (ø)
annif/transform/inputlimiter.py 100.00% <ø> (ø)
annif/transform/transform.py 100.00% <ø> (ø)
annif/util.py 98.30% <ø> (ø)
... and 60 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@juhoinkinen juhoinkinen added this to the 0.60 milestone Nov 7, 2022
@juhoinkinen juhoinkinen changed the title Add isort tool Use isort to order import statements Nov 7, 2022
@juhoinkinen juhoinkinen marked this pull request as ready for review November 8, 2022 10:11
Copy link
Member

@osma osma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good. A couple of quick comments:

  • isort seems to have a Black profile, we should probably enable that in pyproject.toml for maximum compatibility (whatever it does, I'm not sure)
  • now that both Black and isort will be expected from commits, it would be good to create a CONTRIBUTING.md file which documents, among other things, what style checks/fixups to perform before committing. This seems to be a good introduction to writing one. (this could of course be another PR, not part of this one)

@juhoinkinen
Copy link
Member Author

Looks very good. A couple of quick comments:

  • isort seems to have a Black profile, we should probably enable that in pyproject.toml for maximum compatibility (whatever it does, I'm not sure)

Done already in Configure isort to be compatible with Black.

  • now that both Black and isort will be expected from commits, it would be good to create a CONTRIBUTING.md file which documents, among other things, what style checks/fixups to perform before committing. This seems to be a good introduction to writing one. (this could of course be another PR, not part of this one)

👍

Copy link
Member

@osma osma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right, I somehow missed the changes to pyproject.toml even though I looked for them...

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 8, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@juhoinkinen juhoinkinen merged commit d9cbcef into master Nov 8, 2022
@juhoinkinen juhoinkinen deleted the add-isort-tool branch November 8, 2022 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants