ruff.toml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. extend-select = [
  29. "E1", # pycodestyle errors: indentation-related (e.g., unexpected/missing indent)
  30. "E2", # pycodestyle errors: whitespace-related (e.g., missing whitespace, extra spaces)
  31. "E3", # pycodestyle errors: blank lines / spacing around definitions
  32. "E501", # pycodestyle: line too long (enforced with `line-length` above)
  33. "W", # pycodestyle warnings (various style warnings, often whitespace/newlines)
  34. "I", # import sorting (isort-equivalent)
  35. "RET", # return semantics (flake8-return family: consistent/explicit returns; remove redundant else/assign before return)
  36. "UP", # pyupgrade: modernize syntax for your target Python (e.g., f-strings, built-in generics, newer stdlib idioms)
  37. ]
  38. ignore = [
  39. "F403", # pyflakes: `from ... import *` used; unable to detect undefined names
  40. "F405", # pyflakes: name may be undefined or defined from star imports
  41. "RET504", # return: unnecessary assignment before `return` (e.g., `x = expr; return x` -> `return expr`)
  42. "UP032", # pyupgrade: prefer f-strings over `str.format(...)`
  43. ]
  44. preview = true
  45. [lint.isort]
  46. known-first-party = [
  47. "account",
  48. "circuits",
  49. "core",
  50. "dcim",
  51. "extras",
  52. "ipam",
  53. "netbox",
  54. "tenancy",
  55. "users",
  56. "utilities",
  57. "virtualization",
  58. "vpn",
  59. "wireless",
  60. ]
  61. [lint.per-file-ignores]
  62. "template_code.py" = ["E501"]
  63. "netbox/netbox/graphql/filter_lookups.py" = ["UP046"] # Strawberry typing: keep `Generic[T]` for now
  64. "netbox/netbox/graphql/scalars.py" = ["UP007"] # Strawberry scalar typing: `Union[...]` required
  65. [format]
  66. # Use single quotes for strings.
  67. quote-style = "single"
  68. # Indent with spaces, rather than tabs.
  69. indent-style = "space"
  70. # Enforce UNIX line ending
  71. line-ending = "lf"