Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
314 lines (284 loc) · 7.99 KB
/
Copy pathpyproject.toml
File metadata and controls
314 lines (284 loc) · 7.99 KB
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
308
309
310
311
312
313
314
[project]
name = "ops"
description = "The Python library behind great charms"
readme = "README.md"
requires-python = ">=3.10"
authors = [
{name="The Charm Tech team at Canonical Ltd."},
]
license = "Apache-2.0"
license-files = ["LICENSE.txt"]
classifiers = [
"Programming Language :: Python :: 3",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX :: Linux",
]
dependencies = [
"PyYAML==6.*",
"websocket-client==1.*",
# Wide version range to preempt conflicts when charms pin a version.
"opentelemetry-api~=1.0",
]
dynamic = ["version"]
[project.optional-dependencies]
testing = [
"ops-scenario==8.10.0.dev0",
]
tracing = [
"ops-tracing==3.10.0.dev0",
]
# Empty for now, because Harness is bundled with the base install, but allow
# specifying the extra to ease transition later.
harness = []
[dependency-groups]
lint = [
"ruff==0.17.2",
"codespell==2.4.2",
"zizmor==1.30.1",
"ops[testing,tracing]",
"pyright~=1.1",
"typing_extensions~=4.2",
]
# The mypy, pyrefly, and ty groups are used to type check example charms in CI.
mypy = [
"mypy>=1.19",
"types-PyYAML",
]
pyrefly = [
"pyrefly>=1.3",
]
ty = [
"ty==0.0.91",
]
unit = [
"ops[testing,tracing]",
"pytest~=9.0",
"pydantic~=2.10",
]
xdist = [
"pytest-xdist~=3.6",
]
coverage = [
"coverage[toml]~=7.0",
]
benchmark = [
"pytest-benchmark~=5.0",
]
integration = [
"ops[testing,tracing]",
"pytest~=9.0",
"jubilant~=1.5",
"jubilant-backports",
"minio~=7.2",
"httpx~=0.28",
]
tiobe = [
"flake8==7.4.1",
"pylint==4.1.3",
]
[project.urls]
"Homepage" = "https://canonical.com/juju/docs/ops/latest/"
"Repository" = "https://github.com/canonical/operator"
"Issues" = "https://github.com/canonical/operator/issues"
"Documentation" = "https://canonical.com/juju/docs/ops/latest/"
"Changelog" = "https://github.com/canonical/operator/blob/main/CHANGES.md"
[build-system]
requires = ["hatchling>=1.27"]
build-backend = "hatchling.build"
[tool.hatch.version]
source = "code"
path = "ops/version.py"
expression = "version"
[tool.hatch.build.targets.sdist]
# Only include ops, not docs, examples, or testing and tracing packages.
include = [
"/ops",
"/test",
"/*.md", # Include changelog and contributor docs.
]
[tool.hatch.build.targets.wheel]
packages = ["ops"]
[tool.uv.workspace]
members = ["tracing", "testing"]
[tool.uv.sources]
ops = { workspace = true }
ops-scenario = { workspace = true }
ops-tracing = { workspace = true }
# Testing tools configuration
[tool.coverage.run]
branch = true
[tool.coverage.report]
show_missing = true
# Formatting tools configuration
[tool.autopep8]
max-line-length = 99
ignore = ["W503"]
recursive = true
jobs = -1
aggressive = 3
# Linting tools configuration
[tool.ruff]
line-length = 99
exclude = ["examples"]
target-version = "py310"
extend-exclude = ["docs/conf.py", "docs/_dev/", "docs/tutorial/"]
# Ruff formatter configuration
[tool.ruff.format]
quote-style = "single"
[tool.ruff.lint]
select = [
# Pyflakes
"F",
# Pycodestyle
"E",
"W",
# isort
"unsorted-imports", # I001
# pep8-naming
"N",
# flake8-builtins
"A",
# flake8-copyright
"CPY",
# pyupgrade
"UP",
# flake8-2020
"YTT",
# flake8-bandit
"S",
# flake8-bugbear
"B",
# flake8-simplify
"SIM",
# Ruff specific
"RUF",
# Perflint
"PERF",
# pyflakes-docstrings
"D",
# flake8-future-annotations
"FA",
# flake8-type-checking
"TC",
]
ignore = [
"typing-only-first-party-import", # TC001
"typing-only-third-party-import", # TC002
"typing-only-standard-library-import", # TC003
"assert", # S101
"assert-false", # B011
"suspicious-pickle-import", # S403
"suspicious-subprocess-import", # S404
"no-explicit-stacklevel", # B028
# We prefer the readability of returning the condition explicitly.
"needless-bool", # SIM103
"suppressible-exception", # SIM105
"multiple-with-statements", # SIM117
"undocumented-magic-method", # D105
"undocumented-public-init", # D107
"manual-list-comprehension", # PERF401
"manual-dict-comprehension", # PERF403
# Since we have some `TypedDict`s that cannot use the class syntax, we're
# currently choosing to be consistent in syntax even though some can be
# moved to the class syntax.
"convert-typed-dict-functional-to-class", # UP013
## Likely worth doing, but later.
"subprocess-without-shell-equals-true", # S603
]
exclude = ["tracing/ops_tracing/vendor/*"]
[tool.ruff.lint.per-file-ignores]
"test/*" = [
# All documentation linting.
"D",
"hardcoded-password-string", # S105
"hardcoded-password-func-arg", # S106
"useless-expression", # B018
# Tests check round-tripped exact-literal config values; pytest.approx
# isn't appropriate here.
"float-equality-comparison", # RUF069
]
"testing/tests/*" = [
# All documentation linting.
"D",
]
"testing/src/scenario/_charmcraft_extensions.py" = [
"line-too-long", # E501: Auto-generated file; long description strings are unavoidable.
]
".github/generate_charmcraft_extensions.py" = [
"start-process-with-partial-path", # S607: Intentionally calls charmcraft/tox by name.
]
"ops/_private/timeconv.py" = [
# `µ` (MICRO SIGN) rather than `μ` (GREEK SMALL LETTER MU).
"ambiguous-unicode-character-string", # RUF001
"ambiguous-unicode-character-docstring", # RUF002
]
"ops/__init__.py" = [
"non-empty-init-module", # RUF067: Wraps main() and imports ops_tracing at the bottom.
]
"ops/_private/__init__.py" = [
"non-empty-init-module", # RUF067: Exposes a module-level tracer.
]
"ops/lib/__init__.py" = [
"non-empty-init-module", # RUF067: Legacy library loader.
]
"test/test_helpers.py" = [
# Seems safe, but may be changed in the future.
"start-process-with-a-shell", # S605
"start-process-with-partial-path", # S607
]
".github/patch-charm-deps.py" = [
"start-process-with-partial-path", # S607
]
".github/release/propose-release-version.py" = [
"line-too-long", # E501: The failure messages read best kept whole.
]
"docs/custom_conf.py" = [
"undocumented-public-module", # D100
"undocumented-public-class", # D101
"undocumented-public-method", # D102
"undocumented-public-function", # D103
"multiple-leading-hashes-for-block-comment", # E266
"unsorted-imports", # I001
"ambiguous-unicode-character-comment", # RUF003: EN DASH, RIGHT SINGLE QUOTATION MARK
"mutable-class-default", # RUF012
"printf-string-formatting", # UP031
]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.flake8-builtins]
builtins-ignorelist = ["id", "min", "map", "range", "type", "TimeoutError", "ConnectionError", "Warning", "input", "format"]
[tool.pyright]
# Whole trees rather than a list of directories, so that a new package or test
# charm is checked from the day it's added. What isn't checked yet is listed
# explicitly below instead.
include = [".github/release", "ops", "test", "testing"]
exclude = [
"tracing/*",
# Legacy, and not yet clean.
"ops/lib",
# A symlink to ops, which is already checked as itself.
"test/charms/test_main/lib",
# Not yet clean: mostly Any from the juju and jubilant APIs.
"test/integration",
"test/smoke",
"testing/tests/benchmark",
]
extraPaths = ["testing", "tracing"]
pythonVersion = "3.10" # check no python > 3.10 features are used
pythonPlatform = "All"
typeCheckingMode = "strict"
reportIncompatibleMethodOverride = false
reportImportCycles = false
reportMissingModuleSource = false
reportPrivateUsage = false
reportUnnecessaryIsInstance = false
reportUnnecessaryComparison = false
reportUnnecessaryTypeIgnoreComment = "error"
disableBytesTypePromotions = true
stubPath = ""
[tool.codespell]
skip = './docs/_build,./docs/_dev,.venv,venv,build,examples,uv.lock'
quiet-level = 3