diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..1b99431 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,37 @@ +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.12.11 + hooks: + - id: ruff + args: [--fix] + - id: ruff-format + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-merge-conflict + - id: check-toml + - id: debug-statements + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.8.0 + hooks: + - id: mypy + additional_dependencies: [types-requests] + args: [--ignore-missing-imports] + +ci: + autofix_commit_msg: | + [pre-commit.ci] auto fixes from pre-commit.com hooks + + for more information, see https://pre-commit.ci + autofix_prs: true + autoupdate_branch: '' + autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' + autoupdate_schedule: weekly + skip: [] + submodules: false diff --git a/pyproject.toml b/pyproject.toml index e3990e5..4acdf24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,14 +10,56 @@ dependencies = [ "cachetools>=5.0.0", ] + [tool.ruff] target-version = "py313" line-length = 88 indent-width = 4 +[tool.ruff.lint] +# Enable pycodestyle (E, W), Pyflakes (F), isort (I), and other useful rules +select = [ + "E", # pycodestyle errors + "W", # pycodestyle warnings + "F", # Pyflakes + "I", # isort + "N", # pep8-naming + "UP", # pyupgrade + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "SIM", # flake8-simplify + "TCH", # flake8-type-checking + "RUF", # Ruff-specific rules +] + +# Ignore specific rules if needed +ignore = [ + "E501", # Line too long (handled by formatter) + "B008", # Do not perform function calls in argument defaults +] + +# Allow unused variables when they start with an underscore +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[tool.ruff.format] +# Use double quotes for strings +quote-style = "double" +# Indent with spaces +indent-style = "space" +# Respect magic trailing commas +skip-magic-trailing-comma = false +# Auto-detect line endings +line-ending = "auto" + +[tool.ruff.lint.isort] +known-first-party = ["trmnl-report"] + [tool.pyright] venvPath = "." venv = ".venv" [dependency-groups] -dev = ["pre-commit>=4.3.0", "ruff>=0.12.11"] +dev = [ + "pre-commit>=4.3.0", + "ruff>=0.12.11", +]