Skip to content

Migration codestyle from Flake8 to ruff#2523

Merged
ChrisLovering merged 5 commits into
mainfrom
flake8-to-ruff
Apr 11, 2023
Merged

Migration codestyle from Flake8 to ruff#2523
ChrisLovering merged 5 commits into
mainfrom
flake8-to-ruff

Conversation

@ChrisLovering
Copy link
Copy Markdown
Member

@ChrisLovering ChrisLovering commented Apr 9, 2023

To see these code changes commit-by-commit see this diff.

This migrates our linting toolchain from flake8, and related plug-ins, to ruff. from testing, ruff is considerably faster, as well as having more auto-fix support for many of the rules.

There are also more rules than what we have enabled in this PR, which we may look into adding in the future.

See the select like in pyproject.toml to see the list of rules that have been added. Specific rules have also been disabled, for not fitting into our code style, see ignore for which rules have been ignored. A full list of ruff rules can be found here

@python-discord-policy-bot python-discord-policy-bot Bot requested a review from a team April 9, 2023 20:22
@ChrisLovering ChrisLovering marked this pull request as draft April 9, 2023 20:30
@ChrisLovering ChrisLovering marked this pull request as ready for review April 9, 2023 20:58
Comment thread bot/exts/filtering/_filter_lists/antispam.py
Comment thread bot/exts/filtering/_settings_types/validations/channel_scope.py Outdated
Comment thread bot/exts/filtering/_settings_types/validations/bypass_roles.py Outdated
Comment thread bot/exts/filtering/_ui/filter.py Outdated
Comment thread bot/exts/filtering/_ui/filter_list.py Outdated
Comment thread bot/exts/filtering/_ui/search.py Outdated
Comment thread bot/exts/filtering/_utils.py
Comment thread bot/exts/filtering/filtering.py
@ChrisLovering
Copy link
Copy Markdown
Member Author

Will squash all fixup commits before merging, so marking as do not merge so I can do that once approved.

@ChrisLovering ChrisLovering added p: 2 - normal Normal Priority a: tools Development related to our toolchain (Docker, pipenv, flake8) s: needs review Author is waiting for someone to review and approve review: do not merge The PR can be reviewed but cannot be merged now labels Apr 10, 2023
Copy link
Copy Markdown
Member

@mbaruh mbaruh left a comment

Choose a reason for hiding this comment

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

There are various places across the codebase where a type alias is set to some Union, which doesn't seem to be handled by the autofixes. You can find them by regex matching = (t\.|typing\.)?Union across the project.

Comment thread tox.ini
Comment thread bot/exts/info/python_news.py
Comment thread bot/rules/mentions.py Outdated
Comment thread .pre-commit-config.yaml Outdated
@ChrisLovering ChrisLovering force-pushed the flake8-to-ruff branch 2 times, most recently from de4c846 to 2e968ad Compare April 11, 2023 15:35
Comment thread bot/constants.py Outdated
Co-authored-by: Boris Muratov <8bee278@gmail.com>
Co-authored-by: wookie184 <wookie1840@gmail.com>
This is required as | is not supported between a function and NoneType
Copy link
Copy Markdown
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

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

💯

@wookie184
Copy link
Copy Markdown
Contributor

FWIW I opened two issues on the ruff repo regarding the typing things it didn't pick up: astral-sh/ruff#3937 and astral-sh/ruff#3936.

@ChrisLovering ChrisLovering removed the review: do not merge The PR can be reviewed but cannot be merged now label Apr 11, 2023
@jchristgit
Copy link
Copy Markdown
Contributor

BEAST!!!!!!

@ChrisLovering ChrisLovering merged commit f94505a into main Apr 11, 2023
@ChrisLovering ChrisLovering deleted the flake8-to-ruff branch April 11, 2023 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: tools Development related to our toolchain (Docker, pipenv, flake8) p: 2 - normal Normal Priority s: needs review Author is waiting for someone to review and approve

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants