| 1 |
[build-system] |
| 2 |
requires = [] |
| 3 |
backend-path = ['src'] |
| 4 |
build-backend = 'build_backend' |
| 5 |
|
| 6 |
[tool.mypy] |
| 7 |
follow_imports = 'silent' # https://github.com/python-lsp/pylsp-mypy/issues/81 |
| 8 |
scripts_are_modules = true # allow checking all scripts in one invocation |
| 9 |
explicit_package_bases = true |
| 10 |
mypy_path = 'src:test/common:bots' |
| 11 |
exclude = [ |
| 12 |
'tmp/', |
| 13 |
'tools/vulture-suppressions/', |
| 14 |
'vendor/', |
| 15 |
] |
| 16 |
|
| 17 |
[[tool.mypy.overrides]] |
| 18 |
ignore_missing_imports = true |
| 19 |
module = [ |
| 20 |
# run without submodules checked out |
| 21 |
"cockpit._vendor.*", |
| 22 |
|
| 23 |
# run without bots checked out |
| 24 |
"lib.*", |
| 25 |
"machine.*", |
| 26 |
"task.*", |
| 27 |
"testvm", |
| 28 |
|
| 29 |
# run with bots checked out but its dependencies missing |
| 30 |
"libvirt", |
| 31 |
"libvirt_qemu", |
| 32 |
"pika", |
| 33 |
|
| 34 |
# run without pcp module types |
| 35 |
"pcp", |
| 36 |
"cpmapi", |
| 37 |
|
| 38 |
# run without gobject-introspection (used from cockpit-client for Gtk) |
| 39 |
"gi.*", |
| 40 |
|
| 41 |
# these are used from various scripts meant to run on the host |
| 42 |
"dbus", |
| 43 |
"tracer.query", |
| 44 |
"sos.*", |
| 45 |
"vdo.*", |
| 46 |
] |
| 47 |
|
| 48 |
[[tool.mypy.overrides]] |
| 49 |
# https://github.com/python/mypy/issues/11401 prevents us from enabling strict |
| 50 |
# mode for a given set of files, so instead, we enable the corresponding set of |
| 51 |
# individual checks the files which are strictly typed. |
| 52 |
check_untyped_defs = true |
| 53 |
disallow_any_generics = true |
| 54 |
disallow_incomplete_defs = true |
| 55 |
disallow_subclassing_any = true |
| 56 |
disallow_untyped_calls = true |
| 57 |
disallow_untyped_decorators = true |
| 58 |
disallow_untyped_defs = true |
| 59 |
no_implicit_reexport = true |
| 60 |
strict_concatenate = true |
| 61 |
strict_equality = true |
| 62 |
warn_unused_ignores = true |
| 63 |
module = [ |
| 64 |
# src |
| 65 |
'cockpit', |
| 66 |
'cockpit._version', |
| 67 |
'cockpit.channels.http_channel', |
| 68 |
'cockpit.channels.metrics', |
| 69 |
'cockpit.channels.pcp', |
| 70 |
'cockpit.channels.stream', |
| 71 |
'cockpit.channels.trivial', |
| 72 |
'cockpit.misc.print', |
| 73 |
'cockpit.jsonutil', |
| 74 |
'cockpit.packages', |
| 75 |
'cockpit.peer', |
| 76 |
'cockpit.protocol', |
| 77 |
'cockpit.superuser', |
| 78 |
'cockpit.transports', |
| 79 |
'cockpit.beipack', |
| 80 |
'cockpit.samples', |
| 81 |
'cockpit.misc.bootloader', |
| 82 |
|
| 83 |
# test/common |
| 84 |
'testlib', |
| 85 |
'packagelib', |
| 86 |
'netlib', |
| 87 |
'storagelib', |
| 88 |
'submanlib', |
| 89 |
'js_coverage', |
| 90 |
'webdriver_bidi', |
| 91 |
'run-tests', |
| 92 |
|
| 93 |
# test/pytest |
| 94 |
'test.pytest.test_beiboot', |
| 95 |
'test.pytest.test_packages', |
| 96 |
'test.pytest.test_http_channel', |
| 97 |
] |
| 98 |
|
| 99 |
[tool.pylint] |
| 100 |
max-line-length = 118 |
| 101 |
disable = [ |
| 102 |
"C0114", # Missing module docstring |
| 103 |
"C0115", # Missing class docstring |
| 104 |
"C0116", # Missing function or method docstring |
| 105 |
"R0902", # Too many instance attributes |
| 106 |
"R0903", # Too few public methods |
| 107 |
"R0913", # Too many arguments |
| 108 |
"R1705", # Unnecessary "else" after "return" |
| 109 |
"W0120", # Else clause on loop without a break statement |
| 110 |
"W1113", # Keyword argument before variable positional arguments (PEP-570 is Python 3.8) |
| 111 |
] |
| 112 |
|
| 113 |
[tool.ruff] |
| 114 |
exclude = [ |
| 115 |
".git/", |
| 116 |
"modules/", |
| 117 |
"node_modules/", |
| 118 |
] |
| 119 |
line-length = 118 |
| 120 |
preview = true |
| 121 |
src = [] |
| 122 |
|
| 123 |
[tool.ruff.format] |
| 124 |
quote-style = "preserve" |
| 125 |
|
| 126 |
[tool.ruff.lint] |
| 127 |
select = [ |
| 128 |
"A", # flake8-builtins |
| 129 |
"B", # flake8-bugbear |
| 130 |
"C4", # flake8-comprehensions |
| 131 |
"D300", # pydocstyle: Forbid ''' in docstrings |
| 132 |
"DTZ", # flake8-datetimez |
| 133 |
"E", # pycodestyle |
| 134 |
"EXE", # flake8-executable |
| 135 |
"F", # pyflakes |
| 136 |
"FBT", # flake8-boolean-trap |
| 137 |
"G", # flake8-logging-format |
| 138 |
"I", # isort |
| 139 |
"ICN", # flake8-import-conventions |
| 140 |
"ISC", # flake8-implicit-str-concat |
| 141 |
"PIE", # flake8-pie |
| 142 |
"PLE", # pylint errors |
| 143 |
"PGH", # pygrep-hooks |
| 144 |
"PT", # flake8-pytest-style |
| 145 |
"RSE", # flake8-raise |
| 146 |
"RUF", # ruff rules |
| 147 |
"T10", # flake8-debugger |
| 148 |
"TC", # flake8-type-checking |
| 149 |
"UP032", # f-string |
| 150 |
"W", # warnings (mostly whitespace) |
| 151 |
"YTT", # flake8-2020 |
| 152 |
] |
| 153 |
ignore = [ |
| 154 |
"A003", # Class attribute is shadowing a python builtin |
| 155 |
"B011", # Do not `assert False` (`python -O` removes these calls), raise `AssertionError()` |
| 156 |
"E731", # Do not assign a `lambda` expression, use a `def` |
| 157 |
"PT011", # `pytest.raises(OSError)` is too broad |
| 158 |
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` |
| 159 |
"TC001", # Move application import into a type-checking block |
| 160 |
"TC002", # Move third-party import `..packages.Packages` into a type-checking block |
| 161 |
] |
| 162 |
|
| 163 |
[tool.ruff.lint.flake8-pytest-style] |
| 164 |
fixture-parentheses = false |
| 165 |
mark-parentheses = false |
| 166 |
|
| 167 |
[tool.ruff.lint.isort] |
| 168 |
known-first-party = ["cockpit", "test.pytest"] |
| 169 |
|
| 170 |
[tool.ty.environment] |
| 171 |
extra-paths = ["src", "test/common", "bots"] |
| 172 |
|
| 173 |
[tool.pytest.ini_options] |
| 174 |
addopts = ['--strict-markers'] # cf. https://github.com/cockpit-project/cockpit/pull/18584#issuecomment-1490243994 |
| 175 |
pythonpath = ["src", "test/common", "bots"] |
| 176 |
testpaths = ["test/pytest"] |
| 177 |
log_cli = true |
| 178 |
required_plugins = ["pytest-asyncio"] |
| 179 |
asyncio_default_fixture_loop_scope = "function" |
| 180 |
|
| 181 |
[tool.pyright] |
| 182 |
strict = ["**"] |
| 183 |
extraPaths = ["src", "test/common", "bots"] |
| 184 |
|
| 185 |
[tool.vulture] |
| 186 |
paths = [ |
| 187 |
"src", |
| 188 |
"test/pytest", |
| 189 |
"tools/vulture_suppressions", |
| 190 |
] |
| 191 |
ignore_names = [ |
| 192 |
"do_*", |
| 193 |
"pytest_*", |
| 194 |
"test[A-Z0-9]*", |
| 195 |
"pytestmark", |
| 196 |
] |
| 197 |
ignore_decorators = [ |
| 198 |
"@*.getter", |
| 199 |
"@*.register_function", |
| 200 |
"@bus.Interface.Method", |
| 201 |
"@pytest.fixture", |
| 202 |
"@pytest.hookimpl", |
| 203 |
] |
| 204 |
|
| 205 |
[tool.coverage.paths] |
| 206 |
source = ["src", "*/site-packages"] |
| 207 |
|
| 208 |
[tool.coverage.run] |
| 209 |
concurrency = ["multiprocessing"] |
| 210 |
source_pkgs = ["cockpit"] |
| 211 |
branch = true |
| 212 |
|
| 213 |
[tool.coverage.report] |
| 214 |
show_missing = true |
| 215 |
skip_covered = true |
| 216 |
exclude_lines = [ |
| 217 |
"pragma: no cover", # default |
| 218 |
"raise NotImplementedError", |
| 219 |
] |
| 220 |
|
| 221 |
[tool.tox] |
| 222 |
legacy_tox_ini = """ |
| 223 |
[tox] |
| 224 |
envlist = lint,pytest |
| 225 |
isolated_build = True |
| 226 |
requires = virtualenv<20.22.0 |
| 227 |
labels = |
| 228 |
venv = py3{9,10,11,12,13,14}-pytest |
| 229 |
|
| 230 |
# The default test environments use system packages and never PyPI. |
| 231 |
[testenv:{lint,pytest}] |
| 232 |
sitepackages = True |
| 233 |
install_command = python3 -m pip install --no-index --no-build-isolation {opts} {packages} |
| 234 |
wheel_build_env = pkg |
| 235 |
|
| 236 |
# All other environments (names like py311-lint, py39-pytest, etc) are isolated |
| 237 |
# from the system and get their packages from PyPI, according to the specific |
| 238 |
# test environment being requested. We build the wheel in a common environment. |
| 239 |
# These tests will not run the PCP tests as there is no wheel available. |
| 240 |
# https://github.com/performancecopilot/pcp/issues/2076 |
| 241 |
[testenv] |
| 242 |
package = wheel |
| 243 |
wheel_build_env = venv-pkg |
| 244 |
skip_install = lint: True |
| 245 |
deps = |
| 246 |
lint: mypy |
| 247 |
lint: ruff |
| 248 |
lint: vulture |
| 249 |
pytest |
| 250 |
pytest-asyncio |
| 251 |
pytest: pytest-cov |
| 252 |
pytest: pytest-timeout |
| 253 |
pytest: pytest-xdist |
| 254 |
allowlist_externals = test/common/static-code |
| 255 |
setenv = |
| 256 |
NO_QUNIT=1 |
| 257 |
commands = |
| 258 |
pytest: python3 -m pytest -opythonpath=test/common {posargs} |
| 259 |
lint: test/common/static-code --tap |
| 260 |
""" |
| 261 |
|
| 262 |
[tool.codespell] |
| 263 |
skip = '*.map,*.xml,*.policy,*.key,*.svg,./po,./node_modules,./dist,./vendor,./LICENSES,./selinux,./test,./src,./pkg' |
| 264 |
ignore-words-list = 'outofdate,ND,bu,chage,re-uses,re-use,afile' |