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

More ruff rules #154

Merged
merged 11 commits into from Jul 16, 2023
Merged

More ruff rules #154

merged 11 commits into from Jul 16, 2023

Conversation

ItsDrike
Copy link
Member

@ItsDrike ItsDrike commented Jul 15, 2023

This adds various new linter rules:

  • PGH: pygrep-hooks (replaces pre-commit version)
  • PL: pylint (bunch of typing related linter rules)
  • UP: pyupgrade (forces use of the newest possible standards, depending on target version)
  • RET: flake8-return (various linter rules related to function returns)
  • Q: flake8-quotes (always use double quotes)
  • ASYNC: flake8-async (report blocking operations in async functions)
  • INT: flake-gettext (gettext related linting rules)
  • PTH: flake8-use-pathlib (always prefer pathlib alternatives to the os ones)
  • RUF: ruff custom rules (various additional rules created by the ruff linter team)

Ruff has it's own custom set of linter rules, this enables all of them.
This enables all ruff's flake8-use-pathlib (PTH) extension rules.
This enables all ruff's flake8-async (ASYNC) rules.
This enables all ruff's flake8-quotes (Q) rules.
This enables all ruff's flake8-return (RET) rules.
This enables all ruff's pyupgrade (UP) rules.

However UP024 (using errors that alias OSError) is ignored, as that
prohibits use of exceptions like `IOError`, which is utilized pretty
extensively in mcproto.
This enables all ruff's pylint (PL) rules.

However PLR2004 (using unnamed numerical constants) is ignored, as these
kinds of constants are used all over the codebase, in comparisons, etc.
As mcproto is a fairly low level library, this is not surprising, and in
most cases, it's easy to understand what the numerical constant is in
the context of that comparison.
This enables all ruff's pygrep-hooks (PGH) rules.

However PGH003 (using specific rule codes in type ignores) is ignored,
as we're using pyright rather than mypy, and while there are some
rulecodes for pyright and we could be more specific, most of the
violations just fall under the same (general typing issues) category,
which isn't very helpful for categorizing the issue. Because of that,
this would just be annoying to do without any huge benefit for it.
@ItsDrike ItsDrike added p: 2 - normal Normal priority t: feature New request or feature a: internal Related to internal API of the project labels Jul 15, 2023
This enables all ruff's flake8-gettext (INT) rules.
@ItsDrike ItsDrike merged commit 366b613 into main Jul 16, 2023
11 of 12 checks passed
@ItsDrike ItsDrike deleted the more-ruff-rules branch July 16, 2023 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: internal Related to internal API of the project p: 2 - normal Normal priority t: feature New request or feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant