# https://docs.astral.sh/ruff/configuration/

# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".git-rewrite",
    ".hg",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".pytype",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "venv",
    ".venv",
    "docs",
    "*.ipynb",
    "*.md",
]

# Same as Black.
line-length = 88
indent-width = 4

# Assume Python 3.10
target-version = "py310"

[lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`)  codes by default.
select = [
    # pycodestyle
    "E",
    # Pyflakes
    "F",
    # pyupgrade
    "UP",
    # flake8-bugbear
    "B",
    # flake8-simplify
    "SIM",
    # isort
    "I",
    # Warning
    "W",
    # pydocstyle
    "D100", "D101", "D102", "D103", "D104", "D105", "D106", "D107",
    # ruff
    "RUF",
    # McCabe Complexity
    "C90",
    # pep8-naming (N)
    "N",
    # flake8-2020 (YTT)
    "YTT",
    # flake8-annotations (ANN)
    "ANN",
    # flake8-async
    "ASYNC",
    # flake8-bandit
    "S",
    # flake8-commas
    "COM",
    # flake8-use-pathlib
    "PTH",
    # FastAPI
    "FAST",
    # flake8-logging
    "LOG",
    # flake8-comprehensions
    "C4",
    # flake8-pie
    "PIE",
    # flake8-return
    "RET",
    # Pylint
    "PL",
    # eradicate
    "ERA",
    # refurb
    "FURB",
    # flake-8-unused-arguments
    "ARG",
    # flake-8-print
    "T20",
]
ignore = [
    "E501", # Line too long
    "B006", # Do not use mutable data structures for argument defaults
    "ANN401", # Don't flag Any types
    "COM812", # Don't fight over trailing commas
    "PLR0913", # Allow for a reasonable number of arguments
    "PLR2004", # Magic value used in comparison
    "UP006", # Ignoring errors for typing types such as Dict or List
    "UP045", # Ignoring errors for Unions
    "UP007", # Ignoring errors for Optional
    "UP035", # Ignoring errors for typing types such as Dict or List
    "S311",  # Ignoring use of standard random number generators
]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[lint.per-file-ignores]
"**/tests/**/*.py" = ["S101", "ANN", "D", "ARG002"]
"**/sila_example_server/generated/**/*.py" = ["N", "ARG", "D", "ANN", "E722", "PTH", "PIE", "ERA", "RUF012", "RUF022"]  # SiLA codegen
"**/sila_example_server/*.py" = ["N", "ARG002", "D"]  # SiLA interface implementations (naming conventions + required metadata param)
"**/sila_example_server/feature_implementations/*.py" = ["N", "ARG002", "D"]  # SiLA interface implementations
"**/*.ipynb" = ["T20"]
"scripts/**/*.py" = ["D", "T20", "S101", "C901", "SIM", "C401"]
"**/cli/**/*.py" = ["PLC0415"]  # Allow lazy imports in CLI for startup performance

[format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
