Skip to content

Commit

Permalink
put ruff config in a dedicated file
Browse files Browse the repository at this point in the history
  • Loading branch information
vtnate committed Oct 31, 2024
1 parent 7c1aa84 commit 9215ce6
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 24 deletions.
26 changes: 2 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ dependencies = [

[project.optional-dependencies]
dev = [
"pytest ~= 7.4",
"pre-commit ~= 3.3",
"ruff ~= 0.4.0",
"pytest ~= 8.0",
"pre-commit ~= 4.0",
]

# https://setuptools.pypa.io/en/latest/userguide/package_discovery.html
Expand All @@ -61,26 +60,5 @@ readme = {file = "README.md", content-type = "text/markdown"}
minversion = "6.0"
testpaths = "tests"

# https://docs.astral.sh/ruff/tutorial/#configuration
[tool.ruff]
fix = true # automatically fix problems if possible
line-length = 120

# https://docs.astral.sh/ruff/linter/#rule-selection
[tool.ruff.lint]
extend-select = ["RUF", "E", "F", "I", "UP", "N", "S", "BLE", "A", "C4", "T10", "ISC", "ICN", "PT",
"Q", "SIM", "TID", "ARG", "DTZ", "PD", "PGH", "PLC", "PLE", "PLR", "PLW", "PIE", "COM"] # Enable these rules
ignore = ["PLR0913", "PLR2004", "PLR0402", "COM812", "COM819", "SIM108", "ARG002", "ISC001"] # except for these specific errors

# https://docs.astral.sh/ruff/settings/#format
[tool.ruff.format]
# quote-style = "double"

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["S101", "S607", "S603"] # assert statements are allowed in tests, and paths are safe
"update_licenses.py" = ["SIM115", "A002", "ARG001"]
"urbanopt_ditto_reader/reader/read.py" = ["PLR0912", "PLR0915"] # ignore complexity warnings in this file
"urbanopt_ditto_reader/urbanopt_ditto_reader.py" = ["PLR0912", "PLR0915"] # ignore complexity warnings in this file

[project.scripts]
ditto_reader_cli = "urbanopt_ditto_reader.ditto_reader_cli:cli"
89 changes: 89 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# https://docs.astral.sh/ruff/tutorial/#configuration
fix = true # automatically fix problems if possible
line-length = 120

# https://docs.astral.sh/ruff/linter/#rule-selection
[lint]
# Enable these rules
extend-select = [
"A", # flake8-builtins
"ARG", # flake8-unused-arguments
"BLE", # flake8-blind-except
"C4", # flake8-comprehensions
"COM", # flake8-commas
# "DTZ", # flake8-datetimez
"E", # Error
"F", # Pyflakes
"I", # isort
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
"N", # pep8-naming
# "NPY", # NumPy
"PD", # pandas-vet
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PLC", # Pylint Convention
"PLE", # Pylint Error
"PLR", # Pylint Refactor
"PLW", # Pylint Warning
"PT", # flake8-pytest-style
"Q", # flake8-quotes
"RUF", # Ruff-specific rules
"S", # flake8-bandit
"SIM", # flake8-simplify
"T10", # flake8-debugger
"TID", # flake8-tidy-imports
"UP", # pyupgrade
]
# except for these specific errors
# Ruff has a list of linting rules to ignore when using the Ruff formatter (as we are): https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
ignore = [
# "A001", # builtin-variable-shadowing
# "ARG001", # unused-function-argument
"ARG002", # unused-method-argument
# "ARG003", # unused-class-method-argument
# "BLE001", # blind-except
"COM812", # missing-trailing-comma
"COM819", # prohibited-trailing-comma
"D206", # indent-with-spaces
"D300", # triple-single-quotes
"E111", # indentation-with-invalid-multiple
"E114", # indentation-with-invalid-multiple-comment
"E117", # over-indented
"E501", # line-too-long
"ISC001", # single-line-implicit-string-concatenation
"ISC002", # multi-line-implicit-string-concatenation
# "N806", # non-lowercase-variable-in-function
# "PLC1901", # compare-to-empty-string (preview)
# "PLR0402", # manual-from-import
"PLR0911", # too-many-return-statements
# "PLR0912", # too-many-branches
"PLR0913", # too-many-arguments
# "PLR0915", # too-many-statements
"PLR2004", # magic-value-comparison
"PT009", # pytest-unittest-assertion
"Q000", # bad-quotes-inline-string
"Q001", # bad-quotes-multiline-string
"Q002", # bad-quotes-docstring
"Q003", # avoidable-escaped-quote
"Q004", # unnecessary-escaped-quote
# "RUF012", # mutable-class-default
# "S106", # hardcoded-password-func-arg
# "S311", # suspicious-non-cryptographic-random-usage
# "S320", # suspicious-xmle-tree-usage
# "S603", # subprocess-without-shell-equals-true
# "S607", # start-process-with-partial-path
# "S701", # jinja2-autoescape-false
"SIM108", # if-else-block-instead-of-if-exp
"W191", # tab-indentation
]

[lint.per-file-ignores]
"tests/*" = ["S101", "S607", "S603"] # assert statements are allowed in tests, and paths are safe
"update_licenses.py" = ["SIM115", "A002", "ARG001"]
"urbanopt_ditto_reader/reader/read.py" = ["PLR0912", "PLR0915"] # ignore complexity warnings in this file
"urbanopt_ditto_reader/urbanopt_ditto_reader.py" = ["PLR0912", "PLR0915"] # ignore complexity warnings in this file

# https://docs.astral.sh/ruff/settings/#format
[format]
# quote-style = "double"

0 comments on commit 9215ce6

Please sign in to comment.