# We keep the ruff configuration separate so it can easily be shared across
# all projects
target-version = 'py310'

src = ['.']

exclude = [
    'docs',
    '.tox',
    # Ignore local test files/directories/old-stuff
    'test.py',
    '*_old.py',
]

line-length = 79

[lint]
ignore = [
    'A001', # Variable {name} is shadowing a Python builtin
    'A002', # Argument {name} is shadowing a Python builtin
    'A003', # Class attribute {name} is shadowing a Python builtin
    'B023', # function-uses-loop-variable
    'B024', # `FormatWidgetMixin` is an abstract base class, but it has no abstract methods
    'D205', # blank-line-after-summary
    'D212', # multi-line-summary-first-line
    'RET505', # Unnecessary `else` after `return` statement
    'TRY003', # Avoid specifying long messages outside the exception class
    'RET507', # Unnecessary `elif` after `continue` statement
    'C405', # Unnecessary {obj_type} literal (rewrite as a set literal)
    'C406', # Unnecessary {obj_type} literal (rewrite as a dict literal)
    'C408', # Unnecessary {obj_type} call (rewrite as a literal)
    'SIM114', # Combine `if` branches using logical `or` operator
    'RET506', # Unnecessary `else` after `raise` statement
    'Q001', # Remove bad quotes
    'Q002', # Remove bad quotes
    'FA100', # Missing `from __future__ import annotations`, but uses `typing.Optional`
    'COM812', # Missing trailing comma in a list
    'SIM108', # Ternary operators are not always more readable
    'RUF100', # Unused noqa directives. Due to multiple Python versions, we need to keep them
]

select = [
    'A', # flake8-builtins
    'ASYNC', # flake8 async checker
    'B', # flake8-bugbear
    'C4', # flake8-comprehensions
    'C90', # mccabe
    'COM', # flake8-commas
    'D',   # pydocstyle

    'E', # pycodestyle error ('W' for warning)
    'F', # pyflakes
    'FA', # flake8-future-annotations
    'I', # isort
    'ICN', # flake8-import-conventions
    'INP', # flake8-no-pep420
    'N', # pep8-naming
    'NPY', # NumPy-specific rules
    'PERF', # perflint,
    'PIE', # flake8-pie
    'Q', # flake8-quotes

    'RET', # flake8-return
    'RUF', # Ruff-specific rules
    'SIM', # flake8-simplify
    'T20', # flake8-print
    'TD', # flake8-todos
    'TRY', # tryceratops
    'UP', # pyupgrade
]

[lint.per-file-ignores]
'portalocker_tests/tests.py' = ['SIM115', 'SIM117', 'T201']
# Test modules are not part of the documented API — commit 8961865 removed
# tests.rst from the docs for that reason — so the missing-docstring rules
# stay off here. The style rules (D200/D209/D300) still apply.
'portalocker_tests/*' = ['D100', 'D101', 'D102', 'D103', 'D104', 'D105', 'D107']

[lint.pydocstyle]
convention = 'google'
ignore-decorators = [
    'typing.overload',
    'typing.override',
]

[lint.isort]
case-sensitive = true
combine-as-imports = true
force-wrap-aliases = true

[lint.flake8-quotes]
docstring-quotes = 'single'
inline-quotes = 'single'
multiline-quotes = 'single'

[format]
line-ending = 'lf'
indent-style = 'space'
quote-style = 'single'
docstring-code-format = true
skip-magic-trailing-comma = false
exclude = [
    '__init__.py',
]

[lint.pycodestyle]
max-line-length = 79

[lint.flake8-pytest-style]
mark-parentheses = true

