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 ruff (GSI-339) #161

Merged
merged 10 commits into from
Sep 22, 2023
Merged

Use ruff (GSI-339) #161

merged 10 commits into from
Sep 22, 2023

Conversation

TheByronHimes
Copy link
Member

🐶 Using ruff to replace some of our code quality tools.

The initial branch for these changes ended up with a lot of merge conflicts since the pip-tools changes occurred in the interim. Rather than try to untangle everything I decided to start over.


Ruff is a python linter written in rust that runs much, much faster than pylint.
Ruff is not a drop-in replacement for pylint, but it implements several dozen of pylint's rules (see here for the list and here for a comparison)). Looking at the parity tracking, ruff seems to implement the most important rules from pylint.
It can, however, be used as a drop-in replacement for flake8.

Changes

  • Pylint, flake8, bandit, and isort have been replaced in the common dev dependencies by ruff.
  • Pylint, flake8, bandit, and isort pre-commit hooks have been replaced by ruff's pre-commit hook.
  • Pylint, flake8, bandit, and isort github actions have been replaced by the ruff github action.
  • The .ruff.toml config file has been added and the pylint/flake8 config files have been removed.
  • Fixed: added update_lock.py to .static_files (was missed in previous PR)
  • Added scripts/update_hook_revs.py to keep the ruff/black/mypy pre-commit hook versions in line with the dependencies in the lock file. This is also added as a first-step pre-commit hook run with --check.
    • Since the dev dependency versions are now uncapped, it would be difficult to enforce versions centrally.
  • Expanded the settings in .ruff.toml (thanks @Cito) to include flake8-bugbear, flake8-bandit, ruff's rules from pylint, isort, pyupgrade, and more.

Copy link
Contributor

@KerstenBreuer KerstenBreuer left a comment

Choose a reason for hiding this comment

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

Looks great. As always, an outstanding PR description, that really helps and serves as a good documentation if later questions come up.

Thanks also for te prep-commit update scripts, that really handy in deed.

Just some cosmetics.

.github/workflows/static_code_analysis.yaml Show resolved Hide resolved
.github/workflows/static_code_analysis.yaml Show resolved Hide resolved
.pre-commit-config.yaml Show resolved Hide resolved
.pre-commit-config.yaml Outdated Show resolved Hide resolved
.ruff.toml Show resolved Hide resolved
scripts/update_hook_revs.py Outdated Show resolved Hide resolved
scripts/update_hook_revs.py Outdated Show resolved Hide resolved
scripts/update_hook_revs.py Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Sep 22, 2023

Pull Request Test Coverage Report for Build 6274642022

  • 0 of 7 (0.0%) changed or added relevant lines in 7 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage remained the same at 0.0%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/my_microservice/init.py 0 1 0.0%
src/my_microservice/main.py 0 1 0.0%
src/my_microservice/api/init.py 0 1 0.0%
src/my_microservice/api/deps.py 0 1 0.0%
src/my_microservice/config.py 0 1 0.0%
src/my_microservice/core/greeting.py 0 1 0.0%
src/my_microservice/models.py 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
src/my_microservice/core/greeting.py 1 0.0%
Totals Coverage Status
Change from base Build 6248562550: 0.0%
Covered Lines: 0
Relevant Lines: 72

💛 - Coveralls

Cito
Cito previously approved these changes Sep 22, 2023
Copy link
Member

@Cito Cito left a comment

Choose a reason for hiding this comment

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

Nice work. Sorry, could only do a superficial review.

.ruff.toml Outdated Show resolved Hide resolved
.ruff.toml Show resolved Hide resolved
scripts/update_hook_revs.py Outdated Show resolved Hide resolved
Cito
Cito previously approved these changes Sep 22, 2023
Copy link
Member

@Cito Cito left a comment

Choose a reason for hiding this comment

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

Can you still add comments to all entries in the "ignore" list?

@TheByronHimes TheByronHimes merged commit 728b3f5 into main Sep 22, 2023
6 checks passed
@TheByronHimes TheByronHimes deleted the feature/use_ruff_not_pylint_GSI-339 branch September 22, 2023 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants