Skip to content

Commit d5f51f1

Browse files
committed
[build] Add linter configs
1 parent 6bc7652 commit d5f51f1

File tree

8 files changed

+109
-26
lines changed

8 files changed

+109
-26
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
*.tar.gz
33
*.egg-info
44
.*
5+
build
6+
dist
7+
__pycache__

MANIFEST.in

Lines changed: 0 additions & 1 deletion
This file was deleted.

pyproject.toml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,3 @@ content-type = "text/markdown"
3939

4040
[tool.setuptools]
4141
py-modules = ["mfusepy"]
42-
43-
[tool.flake8]
44-
# W503 "line break before binary operator" is directly in opposition to how black breaks lines!
45-
extend-ignore = ["C901", "E201", "E202", "E203", "E211", "E221", "E251", "E266", "E501", "W503"]
46-
max-line-length = 120
47-
max-complexity = 18
48-
select = ["B", "C", "E", "F", "W", "T4", "B9"]
49-
50-
[tool.pylint."MESSAGES CONTROL"]
51-
disable = [
52-
"broad-except",
53-
"too-many-arguments",
54-
"too-many-instance-attributes",
55-
"too-many-locals",
56-
"too-many-lines",
57-
"too-many-positional-arguments",
58-
# I don't need the style checker to bother me with missing docstrings and todos.
59-
"missing-class-docstring",
60-
"missing-function-docstring",
61-
"missing-module-docstring",
62-
"fixme",
63-
]
64-
65-
[tool.mypy]
66-
ignore_missing_imports = true

tests/.flake8

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[flake8]
2+
# W503 "line break before binary operator" is directly in opposition to how black breaks lines!
3+
extend-ignore = C901, E201, E202, E203, E211, E221, E251, E266, E501, W503
4+
max-line-length = 120
5+
max-complexity = 18
6+
select = B,C,E,F,W,T4,B9
7+
# We need to configure the mypy.ini because the flake8-mypy's default
8+
# options don't properly override it, so if we don't specify it we get
9+
# half of the config from mypy.ini and half from flake8-mypy.
10+
mypy_config = .mypy.ini

tests/.mypy.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[mypy]
2+
ignore_missing_imports = True

tests/.pylintrc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[MASTER]
2+
# Maximum number of characters on a single line.
3+
max-line-length=120
4+
5+
[MESSAGES CONTROL]
6+
7+
# Disable the message, report, category or checker with the given id(s). You
8+
# can either give multiple identifiers separated by comma (,) or put this
9+
# option multiple times (only on the command line, not in the configuration
10+
# file where it should appear only once). You can also use "--disable=all" to
11+
# disable everything first and then reenable specific checks. For example, if
12+
# you want to run only the similarities checker, you can use "--disable=all
13+
# --enable=similarities". If you want to run only the classes checker, but have
14+
# no Warning level messages displayed, use "--disable=all --enable=classes
15+
# --disable=W".
16+
disable=broad-except,
17+
invalid-name,
18+
too-many-arguments,
19+
too-many-instance-attributes,
20+
too-many-locals,
21+
too-many-lines,
22+
too-many-positional-arguments,
23+
too-many-public-methods,
24+
too-few-public-methods,
25+
# I don't need the style checker to bother me with missing docstrings and todos.
26+
missing-class-docstring,
27+
missing-function-docstring,
28+
missing-module-docstring,
29+
fixme,
30+
unused-argument,

tests/.ruff.toml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
line-length = 120
2+
target-version = "py37"
3+
4+
[lint]
5+
select = [
6+
"A", "B", "E", "F", "G", "I", "W", "N", "ASYNC", "C4", "COM", "FLY", "FURB", "ICN", "INT", "ISC", "LOG",
7+
"PERF", "PIE", "PLW", "PT", "PYI", "RET", "RSE", "RUF", "SIM", "TID", "TC", "UP", "YTT"
8+
]
9+
ignore = [
10+
# Preview. Complaining about spaces (aligned arguments) should be a formatter option, not a linter one!
11+
# https://github.com/astral-sh/ruff/issues/2402
12+
"E201", "E202", "E203", "E211", "E221", "E226", "E251", "E265", "E266", "E271",
13+
"E501", # A linter should lint, not check for line lengths!
14+
"F401", # Wants to from .version import __version__ as __version__ which clashes with pylint errors!
15+
"B904",
16+
"N801", # Some class names are snake_case to match ctypes
17+
"N803", # Argument names are camelCase instead of snake_case (400+ errors).
18+
"N806", # Variable names are camelCase instead of snake_case (1100+ errors).
19+
"N815", # Class-scope variable names are camelCase instead of snake_case (10 errors).
20+
"N816", # Global variable names are camelCase instead of snake_case (73 errors).
21+
"N999", # Module names are CamelCase like the classes they provide instead of snake_case (11 errors).
22+
"COM812", # Do not force trailing commas where it makes no sense, e.g., function calls for which I'll
23+
# never add more arguments.
24+
"PERF203", # Some code parts HAVE to try-except inside loops because only the element should be skipped,
25+
# not the whole loop being broken out of. Furthermore, this is a useless micro-optimization,
26+
# which is actually removed for Python 3.11+ which introduces zero-cost exceptions.
27+
"PLW0603", # Cannot live without global statements, especially for subprocessing.
28+
"PLW2901", # Only false positives for constructs such as for data in ...: data = data.clean(); process(data)
29+
"RET504", # https://github.com/astral-sh/ruff/issues/17292#issuecomment-3039232890
30+
"RUF001", # Only false positives from tests with Unicode characters.
31+
"RUF039", # https://github.com/astral-sh/ruff/issues/18795
32+
"RUF056", # "options.get('disableUnionMount', False):" Wants me to change False to None,
33+
# but it makes no sense semantically (expecting a bool)
34+
"RUF100", # BUG: removes necessary noqa: E402 in tests!
35+
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`, but _fields_ is not mutable.
36+
37+
"SIM102",
38+
"SIM105",
39+
"SIM115", # Too many locations where I do not know how to use context managers for files,
40+
# which are stored as object members for example!
41+
"TC006", # Wants to quote cast("IO[bytes]", ...) I don't agree with this style choice.
42+
"S101", "S110", "S105", "S311", "S324", "S603", "S607", "S608"
43+
44+
# Bug: SIM118 removes the keys() from row.keys(), which is an sqlite3.Row not a Dict!
45+
]
46+
# Allow fix for all enabled rules (when `--fix`) is provided.
47+
fixable = ["ALL"]
48+
unfixable = []
49+
50+
[format]
51+
line-ending = "lf"
52+
quote-style = "preserve"
53+

tests/clean.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
# Will print warnings for each folder because find tries to descend into it after finding those.
4+
# It may be confusing but it is a nice verbose output to list deleted folders.
5+
find . -type d '(' \
6+
-name '*.egg-info' -or -name '*.mypy_cache' -or -name '__pycache__' -or '.ruff_cache' -or \
7+
-name '*.pytest_cache' -or -name '*.pytype' -or -name 'dist' -or -name 'build' \
8+
')' -exec rm -rf {} ';'
9+
'rm' -f httpd-ruby-webrick.log ratarmount.stderr.log.tmp ratarmount.stdout.log.tmp
10+
11+
for service in httpd ipfs pyftpdlib wsgidav; do pkill -f "$service"; done

0 commit comments

Comments
 (0)