ruff.toml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # Ruff configuration
  2. ####################
  3. exclude = [
  4. ".eggs",
  5. ".git",
  6. ".pyenv",
  7. ".pytest_cache",
  8. ".ruff_cache",
  9. ".venv",
  10. ".vscode",
  11. "__pypackages__",
  12. "_build",
  13. "build",
  14. "dist",
  15. "netbox/project-static/**",
  16. "node_modules",
  17. "site-packages",
  18. "venv",
  19. ]
  20. # Enforce line length and indent-width
  21. line-length = 120
  22. indent-width = 4
  23. # Ignores anything in .gitignore
  24. respect-gitignore = true
  25. # Always generate Python 3.12-compatible code
  26. target-version = "py312"
  27. [lint]
  28. # Pin the effective default rule set used with `preview = true` to match Ruff 0.15.1.
  29. # Ruff 0.15.2 changed the preview defaults, see https://github.com/astral-sh/ruff/releases/tag/0.15.2
  30. # Keeping this explicit makes ruff deterministic.
  31. select = ["E4", "E7", "E9", "F"]
  32. extend-select = [
  33. "E1", # pycodestyle errors: indentation-related (e.g., unexpected/missing indent)
  34. "E2", # pycodestyle errors: whitespace-related (e.g., missing whitespace, extra spaces)
  35. "E3", # pycodestyle errors: blank lines / spacing around definitions
  36. "E501", # pycodestyle: line too long (enforced with `line-length` above)
  37. "W", # pycodestyle warnings (various style warnings, often whitespace/newlines)
  38. "I", # import sorting (isort-equivalent)
  39. "RET", # return semantics (flake8-return family: consistent/explicit returns; remove redundant else/assign before return)
  40. "UP", # pyupgrade: modernize syntax for your target Python (e.g., f-strings, built-in generics, newer stdlib idioms)
  41. "RUF022", # ruff: enforce sorted `__all__` lists
  42. ]
  43. # If you add a rule to `ignore`, please also update the "Linter Exceptions" section in
  44. # docs/development/style-guide.md.
  45. ignore = [
  46. "F403", # pyflakes: `from ... import *` used; unable to detect undefined names
  47. "F405", # pyflakes: name may be undefined or defined from star imports
  48. "RET504", # return: unnecessary assignment before `return` (e.g., `x = expr; return x` -> `return expr`)
  49. "UP032", # pyupgrade: prefer f-strings over `str.format(...)`
  50. ]
  51. preview = true
  52. [lint.isort]
  53. known-first-party = [
  54. "account",
  55. "circuits",
  56. "core",
  57. "dcim",
  58. "extras",
  59. "ipam",
  60. "netbox",
  61. "tenancy",
  62. "users",
  63. "utilities",
  64. "virtualization",
  65. "vpn",
  66. "wireless",
  67. ]
  68. [lint.per-file-ignores]
  69. "template_code.py" = ["E501"]
  70. "netbox/netbox/graphql/filter_lookups.py" = ["UP046"] # Strawberry typing: keep `Generic[T]` for now
  71. "netbox/netbox/graphql/scalars.py" = ["UP007"] # Strawberry scalar typing: `Union[...]` required
  72. [format]
  73. # Use single quotes for strings.
  74. quote-style = "single"
  75. # Indent with spaces, rather than tabs.
  76. indent-style = "space"
  77. # Enforce UNIX line ending
  78. line-ending = "lf"