From 751c74e7de1c78a151fdd8b76f220d8411a2108a Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Tue, 28 Apr 2026 14:27:05 +0200 Subject: Restructure the entire project, enforce linting and add support for type checkers --- .ruff.toml | 47 +++++++++++++---------------------------------- 1 file changed, 13 insertions(+), 34 deletions(-) (limited to '.ruff.toml') diff --git a/.ruff.toml b/.ruff.toml index c5617c1..a9fd42e 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -1,59 +1,40 @@ cache-dir = "~/.cache/ruff" indent-width = 4 line-length = 79 -target-version = "py312" +target-version = "py310" +namespace-packages = ["tests"] + [lint] -select = ["ALL", "D101", "D102", "D103", "D104"] +select = ["ALL"] ignore = [ - "ANN", "BLE001", "COM812", - "D", + "D2", + "D4", "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", "S324", "T201", "TRY003", - "TRY300", - "UP020" ] +# ARG005 - Unused lambda argument: `args` +# BLE001 - Do not catch blind exception: `Exception` # 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 +# E721 - Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +# ERA001 - Found commented-out code # 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 +# PT008 - Use `return_value=` instead of patching with `lambda` # PLR2004 - Magic value used in comparison, consider replacing `200` with a constant variable -# PTH111 - `os.path.expanduser()` should be replaced by `Path.expanduser()` -# PTH113 - `os.path.isfile()` should be replaced by `Path.is_file()` -# PTH123 - `open()` should be replaced by `Path.open()` -# RUF012 - Mutable class attributes should be annotated with `typing.ClassVar` -# RUF013 - PEP 484 prohibits implicit `Optional` # S101 - Use of `assert` detected # S324 - Probable use of insecure hash functions in `hashlib`: `md5` # 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"] @@ -61,7 +42,8 @@ unfixable = [] # custom settings [lint.per-file-ignores] -"src/otp2289/__main__.py" = ["PTH113", "PTH123"] # "Readability counts" +"src/otp2289/generator.py" = ["ERA001"] # commented example code from RFC 2289 +# "tests/test_main.py" = ["ARG005", "E721", "PT008"] [format] @@ -93,6 +75,3 @@ docstring-code-line-length = "dynamic" [lint.flake8-quotes] inline-quotes = "single" - -[lint.isort] -split-on-trailing-comma = false -- cgit v1.3