| 1 | line-length = 120 # impacts import sorting |
| 2 | |
| 3 | lint.extend-select = [ |
| 4 | "ALL", |
| 5 | ] |
| 6 | |
| 7 | # Preserve types, even if a file imports `from __future__ import annotations` |
| 8 | # we need this for cachew to work with HPI types on 3.9 |
| 9 | # can probably remove after 3.10? |
| 10 | lint.pyupgrade.keep-runtime-typing = true |
| 11 | |
| 12 | lint.ignore = [ |
| 13 | "D", # annoying nags about docstrings |
| 14 | "N", # pep naming |
| 15 | "TCH", # type checking rules, mostly just suggests moving imports under TYPE_CHECKING |
| 16 | "S", # bandit (security checks) -- tends to be not very useful, lots of nitpicks |
| 17 | "DTZ", # datetimes checks -- complaining about missing tz and mostly false positives |
| 18 | "FIX", # complains about fixmes/todos -- annoying |
| 19 | "TD", # complains about todo formatting -- too annoying |
| 20 | "ANN", # missing type annotations? seems way to strict though |
| 21 | "EM" , # suggests assigning all exception messages into a variable first... pretty annoying |
| 22 | |
| 23 | ### too opinionated style checks |
| 24 | "E501", # too long lines |
| 25 | "E731", # assigning lambda instead of using def |
| 26 | "E741", # Ambiguous variable name: `l` |
| 27 | "E742", # Ambiguous class name: `O |
| 28 | "E401", # Multiple imports on one line |
| 29 | "F403", # import *` used; unable to detect undefined names |
| 30 | ### |
| 31 | |
| 32 | ### |
| 33 | "E722", # Do not use bare `except` ## Sometimes it's useful for defensive imports and that sort of thing.. |
| 34 | "F811", # Redefinition of unused # this gets in the way of pytest fixtures (e.g. in cachew) |
| 35 | |
| 36 | ## might be nice .. but later and I don't wanna make it strict |
| 37 | "E402", # Module level import not at top of file |
| 38 | |
| 39 | ### these are just nitpicky, we usually know better |
| 40 | "PLR0911", # too many return statements |
| 41 | "PLR0912", # too many branches |
| 42 | "PLR0913", # too many function arguments |
| 43 | "PLR0915", # too many statements |
| 44 | "PLR1714", # consider merging multiple comparisons |
| 45 | "PLR2044", # line with empty comment |
| 46 | "PLR5501", # use elif instead of else if |
| 47 | "PLR2004", # magic value in comparison -- super annoying in tests |
| 48 | ### |
| 49 | "PLR0402", # import X.Y as Y -- TODO maybe consider enabling it, but double check |
| 50 | |
| 51 | "B009", # calling gettattr with constant attribute -- this is useful to convince mypy |
| 52 | "B010", # same as above, but setattr |
| 53 | "B017", # pytest.raises(Exception) |
| 54 | "B023", # seems to result in false positives? |
| 55 | |
| 56 | # complains about useless pass, but has sort of a false positive if the function has a docstring? |
| 57 | # this is common for click entrypoints (e.g. in __main__), so disable |
| 58 | "PIE790", |
| 59 | |
| 60 | # a bit too annoying, offers to convert for loops to list comprehension |
| 61 | # , which may heart readability |
| 62 | "PERF401", |
| 63 | |
| 64 | # suggests no using exception in for loops |
| 65 | # we do use this technique a lot, plus in 3.11 happy path exception handling is "zero-cost" |
| 66 | "PERF203", |
| 67 | |
| 68 | "RET504", # unnecessary assignment before returning -- that can be useful for readability |
| 69 | "RET505", # unnecessary else after return -- can hurt readability |
| 70 | |
| 71 | "PLW0603", # global variable update.. we usually know why we are doing this |
| 72 | "PLW2901", # for loop variable overwritten, usually this is intentional |
| 73 | |
| 74 | "PT011", # pytest raises is too broad |
| 75 | |
| 76 | "COM812", # trailing comma missing -- mostly just being annoying with long multiline strings |
| 77 | |
| 78 | "TRY003", # suggests defining exception messages in exception class -- kinda annoying |
| 79 | "TRY201", # raise without specifying exception name -- sometimes hurts readability |
| 80 | "TRY400", # a bit dumb, and results in false positives (see https://github.com/astral-sh/ruff/issues/18070) |
| 81 | "TRY401", # redundant exception in logging.exception call? TODO double check, might result in excessive logging |
| 82 | |
| 83 | "TID252", # Prefer absolute imports over relative imports from parent modules |
| 84 | |
| 85 | ## too annoying |
| 86 | "T20", # just complains about prints and pprints (TODO maybe consider later?) |
| 87 | "Q", # flake quotes, too annoying |
| 88 | "C90", # some complexity checking |
| 89 | "G004", # logging statement uses f string |
| 90 | "ERA001", # commented out code |
| 91 | "SLF001", # private member accessed |
| 92 | "BLE001", # do not catch 'blind' Exception |
| 93 | "INP001", # complains about implicit namespace packages |
| 94 | "SIM102", # if statements collapsing, often hurts readability |
| 95 | "SIM103", # multiple conditions collapsing, often hurts readability |
| 96 | "SIM105", # suggests using contextlib.suppress instad of try/except -- this wouldn't be mypy friendly |
| 97 | "SIM108", # suggests using ternary operation instead of if -- hurts readability |
| 98 | "SIM110", # suggests using any(...) instead of for look/return -- hurts readability |
| 99 | "SIM117", # suggests using single with statement instead of nested -- doesn't work in tests |
| 100 | "RSE102", # complains about missing parens in exceptions |
| 101 | ## |
| 102 | ] |