-
Notifications
You must be signed in to change notification settings - Fork 285
/
pyproject.toml
307 lines (272 loc) · 11.5 KB
/
pyproject.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# https://packaging.python.org/en/latest/specifications/pyproject-toml/
[project]
name = "xen-api"
requires-python = ">=3.6.0"
license = {file = "LICENSE"}
keywords = ["xen-project", "Xen", "hypervisor", "libraries"]
maintainers = [
{name = "Christian Lindig"},
{name = "Edwin Török"},
{name = "Rob Hoes"},
{name = "Pau Ruiz Safont"},
]
readme = "README.markdown"
# https://pypi.org/classifiers/
classifiers = [
"Development Status :: 5 - Production/Stable",
"Operating System :: POSIX :: Linux :: XenServer Dom0",
"Operating System :: POSIX :: Linux :: XCP-ng Dom0",
"Programming Language :: ML",
"Programming Language :: Python :: Implementation :: CPython",
]
[project.urls]
homepage = "https://github.com/xapi-project/xen-api"
repository = "https://github.com/xapi-project/xen-api"
[tool.black]
line-length = 88
# -----------------------------------------------------------------------------
# Coverage.py - https://coverage.readthedocs.io/en/coverage-5.5/config.html
#
# [tool.coverage.run] and [tool.coverage.report] configure these commands:
# coverage run && coverage report
#
# These work in conjunction with [tool.pytest.ini_options] to set defaults
# for running pytest (on its own) and for running Coverage.py with pytest:
#
# Examples for Python test development with Coverage.py:
#
# Run the default tests and check coverage:
# coverage run && coverage report
#
# Run a custom set of tests and check coverage:
# coverage run -m pytest python3/tests/test_*.py && coverage report
# -----------------------------------------------------------------------------
[tool.coverage.report]
# Here, developers can configure which lines do not need to be covered by tests:
# fail_under: minimum code coverage percentage
fail_under = 50
# exclude_lines: lines that are not required to be covered
exclude_lines = [
"pragma: no cover", # standard pragma for not covering a line or block
"if TYPE_CHECKING:", # imports for type checking only
"pass",
# Other specific lines that do not need to be covered, comment in which file:
"raise NbdDeviceNotFound", # python3/libexec/usb_scan.py
"params = xmlrpc.client.loads", # static-vdis
"assert.*# must not be None", # static-vdis
"except Exception:", # static-vdis
]
# precision digits to use when reporting coverage (sub-percent-digits are not reported):
precision = 0
# skip_covered: Skip reporting files with 100% coverage:
skip_covered = true
[tool.coverage.run]
# Default command line for "coverage run": Run pytest in non-verbose mode
command_line = "-m pytest -v -ra"
# Default data file for "coverage run": Store coverage data in .git/.coverage
data_file = ".git/.coverage"
# Default context for "coverage run": Use the name of the test function
dynamic_context = "test_function"
# Default omit patterns for "coverage run": Omit test files and test directories
omit = [
"python3/bin/__init__.py",
"python3/packages/__init__.py",
# omit tests anything in a test directory (focus on the code)
"python3/tests",
"scripts/test_*.py",
# omit anything in a .local directory anywhere
"*/.local/*",
# omit everything in /usr
"/usr/*",
]
relative_files = true
# Default output when writing "coveragle xml" data. This needs to match what
# diff-cover and coverage upload to Codecov expect
[tool.coverage.xml]
output = ".git/coverage3.11.xml"
# Default output directory for writing "coverage html" data.
# Create it outside the source tree to avoid cluttering the source tree
[tool.coverage.html]
directory = ".git/coverage_html"
show_contexts = true
[tool.isort]
line_length = 88
py_version = 36
profile = "black"
combine_as_imports = true
ensure_newline_before_comments = false
# -----------------------------------------------------------------------------
# Mypy static analysis - https://mypy.readthedocs.io/en/stable/config_file.html
# -----------------------------------------------------------------------------
[tool.mypy]
# Note mypy has no config setting for PYTHONPATH, so you need to call it with:
# PYTHONPATH="scripts/examples/python:.:scripts:scripts/plugins:scripts/examples"
files = [
"python3",
"scripts/examples/python",
]
exclude = [
"python3/packages",
"python3/stubs",
"python3/tests",
]
pretty = true
mypy_path = "python3/packages:python3/stubs:scripts/examples/python"
error_summary = true
# default_return = false sets the default return type of functions to 'Any'.
# It makes mypy less noisy on untyped code makes it more usable now:
default_return = false
strict_equality = true
show_error_codes = true
show_error_context = true
# Check the contents of untyped functions in all modules by default:
check_untyped_defs = true
scripts_are_modules = true
python_version = "3.11"
warn_return_any = true
warn_unreachable = true
warn_unused_configs = true
warn_redundant_casts = true
disallow_any_explicit = false
disallow_any_generics = true
disallow_any_unimported = true
disallow_subclassing_any = true
disable_error_code = [
"explicit-override",
"misc",
"no-any-decorated",
"no-any-expr",
"no-untyped-call",
"no-untyped-def",
"no-untyped-usage",
"import-untyped", # XenAPI is not typed yet
]
[[tool.mypy.overrides]]
module = ["packages.observer"]
disable_error_code = [
"arg-type", # mypy does not know that the Context class is actually a dict
"override", # Typing problem in the used library
"misc",
"no-any-unimported",
]
# -----------------------------------------------------------------------------
# Pylint - https://pylint.pycqa.org/en/latest/technical_reference/features.html
# -----------------------------------------------------------------------------
[tool.pylint.design]
max-branches = 43 # perfmon has 43 branches in a function
[tool.pylint.messages_control]
# These are safe to disable, fixing them is best done during a later code cleanup phases
disable = [
"broad-exception-caught",
"no-else-break",
"no-else-return",
"consider-using-f-string", # f-strings is the big new feature of Python 3.6,
"consider-using-with", # but like with, best done during code cleanup phase
"duplicate-code", # likewise. This is a code cleanup task
"import-error", # pylint does not do inter-procedural analysis
"invalid-name", # doesn't conform to snake_case naming style
"missing-function-docstring", # Best done in the code documentation phase
"missing-module-docstring", # Likewise, best done in the code documentation phase
"missing-class-docstring", # Likewise, best done in the code documentation phase
"no-member", # Existing code breaches this, not part of porting
"no-else-break", # else clause following a break statement
"protected-access", # Best done during the code cleanup phase
"super-with-arguments", # Consider using Python 3 style super(no args) calls
"too-few-public-methods", # Some classes only overload private methods, is fine
"too-many-branches", # Existing code breaches this, not part of porting
"too-many-arguments", # Likewise, not part of porting
"too-many-lines", # Likewise, not part of porting
"too-many-locals", # Likewise, not part of porting
"too-many-statements", # Likewise, not part of porting
"unnecessary-pass", # Cosmetic, best done during the code cleanup phase
"useless-object-inheritance", # Useless object inheritance from object, likewise
]
# -----------------------------------------------------------------------------
# Pyright is the static analysis behind the VSCode Python extension / Pylance
# https://microsoft.github.io/pyright/#/configuration
# -----------------------------------------------------------------------------
[tool.pyright]
# include: directories to include in checking
# strict: paths for which strict checking works
# typeCheckingMode: set the standard type checking mode
include = ["python3", "ocaml/xcp-rrdd"]
strict = ["python3/tests/observer"]
stubPath = "python3/stubs"
pythonPlatform = "Linux"
typeCheckingMode = "standard"
reportMissingImports = false
reportMissingModuleSource = false
pythonVersion = "3.6"
exclude = [
"ocaml/xcp-rrdd/scripts/rrdd/rrdd.py",
"ocaml/xcp-rrdd/scripts/rrdd/rrdd-example.py",
"python3/packages/observer.py",
"python3/examples/XenAPI/XenAPI.py",
"python3/examples/XenAPIPlugin.py",
]
# -----------------------------------------------------------------------------
# Pytest is the test framework, for discovering and running tests, fixtures etc
# https://pytest.readthedocs.io/en/latest/customize.html, https://docs.pytest.org
# -----------------------------------------------------------------------------
[tool.pytest.ini_options]
# -----------------------------------------------------------------------------
# addopts: Options to add to all pytest calls:
# -v show what happens
# -ra show short summary after running tests
#
# addopts are added to all pytest calls. We don't add options that would force
# testing specific paths. To be flexible, we use use testpaths instead(see below)
# -----------------------------------------------------------------------------
addopts = "-v -ra"
# -----------------------------------------------------------------------------
# Other pytest config options:
# log_cli: show logger messages
# log_cli_level: log level to show
# python_files: pattern for test files
# python_functions: pattern for test functions
# testpaths: directories to search for tests(by default, used for CI)
# For development, developers can test only specific files:
# Example: pytest python3/tests/test_perfmon.py
# minversion: this config requires pytest>=7 to configure pythonpath
# pythonpath: path to stub files and typing stubs for tests
# xfail_strict: require to remove pytext.xfail marker when test is fixed
# required_plugins: require that these plugins are installed before testing
# -----------------------------------------------------------------------------
testpaths = ["python3", "ocaml/xcp-rrdd", "ocaml/xenopsd"]
required_plugins = ["pytest-mock"]
log_cli_level = "INFO"
log_cli = true
minversion = "7.0"
pythonpath = "python3/stubs" # Allow to import the XenAPI module
python_files = ["test_*.py", "it_*.py"]
python_functions = ["test_", "it_", "when_"]
xfail_strict = true # is used to fail tests that are marked as xfail but pass(for TDD)
[tool.pytype_reporter]
default_branch = "master"
discard_messages_matching = [
"Couldn't import pyi for 'xml.dom.minidom'",
"No attribute '.*' on RRDContentHandler",
"No attribute 'group' on None",
"No Node.TEXT_NODE in module xml.dom.minidom, referenced from 'xml.dom.expatbuilder'"
]
expected_to_fail = [
]
# -----------------------------------------------------------------------------
# pytype: Google's static type analyzer - https://google.github.io/pytype/
# -----------------------------------------------------------------------------
[tool.pytype]
inputs = [
"python3/",
"ocaml/xcp-rrdd",
"ocaml/xenopsd",
"ocaml/xapi-storage/python",
"ocaml/xapi-storage-script",
"ocaml/vhd-tool",
]
disable = [
# Reduce noise from python scripts(import yum, xenfsimage, xcp, urlgrabber)
"import-error",
]
platform = "linux"
# Allow pytype to find the XenAPI module, the rrdd module and python3 modules:
pythonpath = "python3/examples:."