blob: fea968df434e1ea9adbc58d395a769b396ce09e1 [file] [log] [blame] [edit]
[tool.black]
target-version = ["py37"]
line-length = 79
skip-string-normalization = true
# https://black.readthedocs.io/en/stable/the_black_code_style/future_style.html
preview = true
enable-unstable-feature = ["hug_parens_with_braces_and_square_brackets", "multiline_string_handling", "string_processing", "wrap_long_dict_values_in_parens"]
[tool.ruff]
# https://beta.ruff.rs/docs/settings/
target-version = "py37"
line-length = 79
[tool.ruff.lint]
preview = true
select = [
# To get a list of all values: `python3 -m ruff linter`.
"ALL",
"D200", # [*] One-line docstring should fit on one line
"D204", # [*] 1 blank line required after class docstring
"D209", # [*] Multi-line docstring closing quotes should be on a separate line
"D212", # [*] Multi-line docstring summary should start at the first line
"D301", # Use `r"""` if any backslashes in a docstring
"D403", # [*] First word of the first line should be capitalized
"PERF102", # [*] When using only the keys of a dict use the `keys()` method
"RET507", # Unnecessary `elif` after `continue` statement
"S113", # Probable use of requests call without timeout
"S602", # `subprocess` call with `shell=True` identified, security issue
]
ignore = [
"A", # flake8-builtins (shadowing of builtins like all, any, ...)
"ANN", # flake8-annotations
"ARG001", # unused-function-argument
"ARG002", # unused-method-argument
"B007", # Loop control variable `x` not used within loop body
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` (PYTHON2.7 COMPAT)
"B904", # Use `raise from` to specify exception cause (PYTHON2.7 COMPAT)
"C4", # flake8-comprehensions (PYTHON2.7 COMPAT)
"C90", # mccabe (function `X` is too complex)
"COM812", # Trailing comma missing
"D", # pydocstyle
"DOC", # various docstring warnings
"DTZ", # flake8-datetimez
"ERA001", # Found commented-out code
"FBT", # flake8-boolean-trap (makes zero sense)
"FIX", # Line contains TODO / XXX / ..., consider resolving the issue
"FLY", # flynt (PYTHON2.7 COMPAT)
"FURB101", # `open` and `read` should be replaced by `Path(src).read_text()`
"FURB103", # `open` and `write` should be replaced by `Path(src).write_text()`
"FURB113", # Use `ls.extend(...)` instead of repeatedly calling `ls.append()`
"FURB116", # [*] Replace `hex` call with `f"{start:x}"`
"FURB118", # [*] Use `operator.add` instead of defining a lambda
"FURB140", # [*] Use `itertools.starmap` instead of the generator
"FURB145", # [*] Prefer `copy` method over slicing (PYTHON2.7 COMPAT)
"FURB192", # [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence
"INP", # flake8-no-pep420
"N801", # Class name `async_chat` should use CapWords convention (ASYNCORE COMPAT)
"N802", # Function name X should be lowercase.
"N806", # Variable X in function should be lowercase.
"N818", # Exception name `FooBar` should be named with an Error suffix
"PERF", # Perflint
"PGH004", # Use specific rule codes when using `noqa`
"PLC0415", # `import` should be at the top-level of a file
"PLC2701", # Private name import `x` from external module `y`
"PLR0904", # Too many public methods (x > y)
"PLR0911", # Too many return statements (8 > 6)
"PLR0912", # Too many branches (x > y)
"PLR0913", # Too many arguments in function definition (x > y)
"PLR0914", # Too many local variables (x/y)
"PLR0915", # Too many statements (x > y)
"PLR0917", # Too many positional arguments (x/y)
"PLR1702", # Too many nested blocks (x > y)
"PLR1704", # Redefining argument with the local name `type_`
"PLR2004", # Magic value used in comparison, consider replacing X with a constant variable
"PLR6301", # Method `x` could be a function, class method, or static method
"PLW0603", # Using the global statement to update `lineno` is discouraged
"PLW1514", # `open` in text mode without explicit `encoding` argument
"PLW2901", # `for` loop variable `x` overwritten by assignment target
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"PYI", # flake8-pyi (python types stuff)
"Q000", # Single quotes found but double quotes preferred
"RET", # flake8-return
"RUF", # Ruff-specific rules
"S", # flake8-bandit
"SIM102", # Use a single `if` statement instead of nested `if` statements
"SIM105", # Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass`
"SIM115", # Use context handler for opening files
"SIM117", # Use a single `with` statement with multiple contexts instead of nested `with` statements
"SLF", # flake8-self
"TD", # all TODOs, XXXs, etc.
"TRY300", # Consider moving this statement to an `else` block
"TRY301", # Abstract `raise` to an inner function
"UP009", # [*] UTF-8 encoding declaration is unnecessary (PYTHON2.7 COMPAT)
"UP010", # [*] Unnecessary `__future__` import `print_function` for target Python version (PYTHON2.7 COMPAT)
"UP024", # [*] Replace aliased errors with `OSError` (PYTHON2.7 COMPAT)
"UP025", # [*] Remove unicode literals from strings (PYTHON2.7 COMPAT)
"UP028", # [*] Replace `yield` over `for` loop with `yield from` (PYTHON2.7 COMPAT)
"UP031", # [*] Use format specifiers instead of percent format
"UP032", # [*] Use f-string instead of `format` call (PYTHON2.7 COMPAT)
"UP036", # Version block is outdated for minimum Python version (PYTHON2.7 COMPAT)
]
[tool.ruff.lint.per-file-ignores]
# T201 == print(), T203 == pprint()
# EM101 == raw-string-in-exception
# TRY003 == raise-vanilla-args
".github/workflows/*" = ["T201", "T203"]
"psutil/_compat.py" = ["PLW0127"] # self-assigning-variable
"psutil/tests/*" = ["EM101", "TRY003"]
"scripts/*" = ["T201", "T203"]
"scripts/internal/*" = ["EM101", "T201", "T203", "TRY003"]
"setup.py" = ["T201", "T203"]
[tool.ruff.lint.isort]
# https://beta.ruff.rs/docs/settings/#isort
force-single-line = true # one import per line
lines-after-imports = 2
[tool.coverage.report]
exclude_lines = [
"enum.IntEnum",
"except ImportError:",
"globals().update",
"if BSD",
"if FREEBSD",
"if LINUX",
"if LITTLE_ENDIAN:",
"if MACOS",
"if NETBSD",
"if OPENBSD",
"if PY3:",
"if SUNOS",
"if WINDOWS",
"if _WINDOWS:",
"if __name__ == .__main__.:",
"if enum is None:",
"if enum is not None:",
"if has_enums:",
"if ppid_map is None:",
"if sys.platform.startswith",
"import enum",
"pragma: no cover",
"raise NotImplementedError",
]
omit = [
"psutil/_compat.py",
"psutil/tests/*",
"setup.py",
]
[tool.pylint.messages_control]
# Important ones:
# undefined-all-variable, invalid-envvar-default, reimported, raising-format-tuple, simplifiable-if-expression, useless-object-inheritance
disable = [
"broad-except", # except Exception:
"consider-using-dict-comprehension",
"consider-using-f-string",
"consider-using-set-comprehension",
"consider-using-with",
"disallowed-name",
"fixme",
"global-statement",
"import-error",
"import-outside-toplevel",
"inconsistent-return-statements",
"invalid-name",
"missing-class-docstring",
"missing-function-docstring",
"no-else-raise",
"no-else-return",
"protected-access",
"raise-missing-from",
"redefined-builtin",
"super-with-arguments",
"too-few-public-methods",
"too-many-arguments",
"too-many-branches",
"too-many-instance-attributes",
"too-many-lines",
"too-many-locals",
"too-many-public-methods",
"too-many-return-statements",
"too-many-statements",
"ungrouped-imports",
"unspecified-encoding",
"wrong-import-position",
]
[tool.vulture]
exclude = [
"docs/conf.py",
"psutil/_compat.py",
"psutil/tests/",
"scripts/internal/winmake.py",
]
ignore_decorators = [
"@_common.deprecated_method",
"@atexit.register",
"@pytest.fixture",
]
[tool.rstcheck]
ignore_messages = [
"Duplicate explicit target name",
"Duplicate implicit target name",
"Hyperlink target \".*?\" is not referenced",
]
[tool.tomlsort]
in_place = true
no_sort_tables = true
sort_inline_arrays = true
spaces_before_inline_comment = 2
spaces_indent_inline_array = 4
trailing_comma_inline_array = true
[tool.cibuildwheel]
skip = [
"*-musllinux*",
"cp313-win*", # pywin32 is not available on cp313 yet
"cp3{7,8,9,10,11,12}-*linux_{aarch64,ppc64le,s390x}", # Only test cp36/cp313 on qemu tested architectures
"pp*",
]
[tool.cibuildwheel.macos]
archs = ["arm64", "x86_64"]
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=43"]