From 37f8843f5fecc9bb4a5eb5b18eea35b1bbc16489 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Fri, 5 Jul 2024 22:55:03 +0200 Subject: Add more fixes and linting --- .ruff.toml | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .ruff.toml (limited to '.ruff.toml') diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..1037228 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,109 @@ +cache-dir = "~/.cache/ruff" +indent-width = 4 +line-length = 79 +target-version = "py39" + +[lint] +select = ["ALL", "D101", "D102", "D103", "D104"] +ignore = [ + "ANN", + "BLE001", + "COM812", + "D", + "EM101", # Exception must not use a string literal, assign to variable first + "EM102", # Exception must not use an f-string literal, assign to variable first + "ERA001", + "FBT001", + "FBT002", + "INP001", + "ISC001", + "N802", + "N806", + "PLR2004", + "PTH111", + "RUF012", + "RUF013", + "S101", + "T201", + "TRY003", + "TRY300", + "UP020" +] + +# D101 - Missing docstring in public class +# D102 - Missing docstring in public method +# D200 - One-line docstring should fit on one line +# D203 - 1 blank line required before class docstring +# D205 - 1 blank line required between summary line and description +# D403 - First word of the first line should be capitalized: `str` -> `Str` +# FBT001 - Boolean-typed positional argument in function definition +# FBT002 - Boolean default positional argument in function definition +# INP001 - File `beinc_weechat.py` is part of an implicit namespace package. Add an `__init__.py` +# N802 - Function name `do_GET` should be lowercase +# N806 - Variable `POST_data` in function should be lowercase +# PTH111 - `os.path.expanduser()` should be replaced by `Path.expanduser()` +# PLR2004 - Magic value used in comparison, consider replacing `200` with a constant variable +# RUF012 - Mutable class attributes should be annotated with `typing.ClassVar` +# RUF013 - PEP 484 prohibits implicit `Optional` +# S101 - Use of `assert` detected +# T201 - `print` found +# TRY003 - Avoid specifying long messages outside the exception class +# TRY300 - Consider moving this statement to an `else` block +# UP020 - Use builtin `open` + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# custom settings +[lint.per-file-ignores] +"beinc_generic_client.py" = [ + "S310" # Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected +] +"beinc_pull.py" = [ + "S310", # Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected + "TRY002", # Create your own exception + "TRY301" # Abstract `raise` to an inner function +] +"beinc_weechat.py" = [ + "ARG001", # Unused function argument: `data` + "C901", # `beinc_cmd_target_handler` is too complex (13 > 10) + "DTZ005", # `datetime.datetime.now()` called without a `tz` argument + "PLR0912", # Too many branches (16 > 12) + "PLW0603", # Using the global statement to update `global_values` is discouraged + "PTH118", # `os.path.join()` should be replaced by `Path` with `/` operator + "S310", # Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected + "TRY002", # Create your own exception + "TRY301" # Abstract `raise` to an inner function +] + + +[format] +# Like Black, use double quotes for strings. +quote-style = "single" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = true + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = false + +# Set the line length limit used when formatting code snippets in +# docstrings. +# +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic" + +[lint.flake8-quotes] +inline-quotes = "single" -- cgit v1.3