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

Update ruff and add pre-commit #52

Merged
merged 4 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.2.1
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
33 changes: 24 additions & 9 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copied originally from pandas
# Copied originally from pandas. This config requires ruff >= 0.2.
target-version = "py310"

# fix = true
unfixable = []
lint.unfixable = []

select = [
lint.select = [
"I", # isort
"F", # pyflakes
"E", "W", # pycodestyle
Expand All @@ -24,7 +24,7 @@ select = [
]

# Some additional rules that are useful
extend-select = [
lint.extend-select = [
"UP009", # UTF-8 encoding declaration is unnecessary
"SIM118", # Use `key in dict` instead of `key in dict.keys()`
"D205", # One blank line required between summary line and description
Expand All @@ -33,7 +33,7 @@ extend-select = [
"PERF401", # Use a list comprehension to create a transformed list
]

ignore = [
lint.ignore = [
"ISC001", # Disable this for compatibility with ruff format
"B028", # No explicit `stacklevel` keyword argument found
"B905", # `zip()` without an explicit `strict=` parameter
Expand All @@ -43,18 +43,33 @@ ignore = [
"PLR0911", # Too many returns
"PLR0912", # Too many branches
"PLR0913", # Too many arguments to function call
"PLR2004", # Magic number
"PLR0915", # Too many statements
"PLR2004", # Magic number
]

# TODO : fix these and stop ignoring. Commented out ones are common and OK to except.
lint.extend-ignore = [
"PGH004", # Use specific rule codes when using `noqa`
# "C401", # Unnecessary generator (rewrite as a `set` comprehension)
# "C402", # Unnecessary generator (rewrite as a dict comprehension)
# "C405", # Unnecessary `list` literal (rewrite as a `set` literal)
# "C408", # Unnecessary `dict` call (rewrite as a literal)
# "C416", # Unnecessary `dict` comprehension (rewrite using `dict()`)
# "G010", # warn is deprecated in favor of warning
# "PYI056", # Calling `.append()` on `__all__` may not be supported by all type checkers
]

extend-exclude = [
"docs",
]

[pycodestyle]
[lint.pycodestyle]
max-line-length = 100 # E501 reports lines that exceed the length of 100.

[lint.extend-per-file-ignores]
"__init__.py" = ["E402", "F401", "F403"]
"Quaternion/shapes.py" = ["D205"]
"**/tests/test*.py" = ["D205"]
# For tests:
# - D205: Don't worry about test docstrings
# - ARG001: Unused function argument false positives for some fixtures
"Quaternion/shapes.py" = ["D205", "ARG001"]
"**/tests/test*.py" = ["D205", "ARG001"]
Loading