Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
159 lines (141 loc) · 7.06 KB
/
Copy pathpyproject.toml
File metadata and controls
159 lines (141 loc) · 7.06 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
[build-system]
requires = [
# 70.1 is when bdist_wheel moved into setuptools proper; see the fallback
# import in pycbc_build_setup.py. Also comfortably new enough to treat
# setup.py's SPDX `license="Apache-2.0"` as a real license expression.
"setuptools>=70.1",
"wheel",
]
build-backend = "setuptools.build_meta"
[tool.pytest.ini_options]
minversion = "8.0"
#addopts = "-ra -q"
testpaths = [
"tests",
"acouchbase/tests",
"couchbase/tests",
"txcouchbase/tests",
]
python_classes = [
"*Tests"
]
python_files = [
"*_t.py"
]
asyncio_default_fixture_loop_scope = "session"
asyncio_default_test_loop_scope = "session"
markers = [
"pycbc_couchbase: marks a test for the couchbase API (deselect with '-m \"not pycbc_couchbase\"')",
"pycbc_acouchbase: marks a test for the acouchbase API (deselect with '-m \"not pycbc_acouchbase\"')",
"pycbc_txcouchbase: marks a test for the txcouchbase API (deselect with '-m \"not pycbc_txcouchbase\"')",
"pycbc_slow_mgmt: marks a test as a management API test that is slow",
"unsupported_protocol(*protocols): skip this test under any of the given TestProtocol values",
"covers_protocols(*protocols): this test checks each given TestProtocol itself, so it runs only under the first",
"known_issue(*protocols, ticket=, note=): skip this test as a known issue under any of the given TestProtocol values",
"testgen_exclude(*apis, reason=...): do not generate this test for the named APIs",
]
[tool.autopep8]
max_line_length = 120
in-place = true
recursive = true
[tool.mypy]
# Kept here rather than in a separate mypy.ini so tool config stays in one file, matching
# autopep8 / isort / pytest above. Semantically identical to the [mypy] ini form.
# `couchbase/_version.py` is written by the build, so the check needs a built tree.
files = ["tests", "couchbase", "acouchbase", "txcouchbase"]
disallow_untyped_defs = true
disallow_incomplete_defs = true
# Every `# type: ignore` here suppresses a defect that is fixed somewhere other than the
# line holding the ignore: an annotation in the SDK tree, or a test defect with a ticket of
# its own. Both are temporary, and neither fix is made by anyone reading this file. This
# turns "remember to delete it" into a hard failure naming the exact line, the moment the
# ignore stops being needed.
warn_unused_ignores = true
# A bare `# type: ignore` silences every error the line will ever produce rather than the
# one its author saw, so what it suppresses is whatever the file grows into. Requiring the
# code keeps each suppression pinned to the defect it was written for.
#
# `tools/audit_type_ignores.py` holds the same requirement for the test trees, and both
# halves earn their place: the audit reads the source, so it can see that the brackets are
# empty but not what belongs inside them. mypy has the error in hand when it reports this,
# so it names the code as well.
enable_error_code = ["ignore-without-code"]
# `googleapis-common-protos` ships a `.pyi` beside every module but no `py.typed`, so mypy has to be
# told to read them.
[[tool.mypy.overrides]]
module = ["google.rpc", "google.rpc.*"]
follow_untyped_imports = true
# protoc and mypy-protobuf output, regenerated rather than edited, and checked like the rest.
# mypy-protobuf's stubs carry ignores that types-grpcio leaves unused. protoc leaves `**kwargs`
# unannotated on `HookAction.__init__`.
[[tool.mypy.overrides]]
module = ["couchbase.protocol.couchbase2._generated.*"]
warn_unused_ignores = false
[[tool.mypy.overrides]]
module = ["couchbase.protocol.couchbase2._generated.internal.hooks.v1.hooks_pb2"]
disable_error_code = ["no-untyped-def"]
# Third-party packages that ship no stubs. These are test-only dependencies and none of
# them appear in an annotation we care about checking.
[[tool.mypy.overrides]]
module = ["faker.*", "faker_vehicle.*", "faker_vehicle", "xdist.*"]
ignore_missing_imports = true
# The FIT performer's protobuf code, generated by `tools/fit_performer/bin/generate.sh` into a
# gitignored directory that `tools/fit_performer/bin/typecheck.sh` puts on the search path, so it is
# imported under these top-level names. The `.pyi` stubs type the messages and the service the
# performer uses; what is wrong inside generated code is not ours to fix.
[[tool.mypy.overrides]]
module = [
"hooks.*", "meta.*", "metrics.*", "observability.*", "performer.*", "performer_pb2",
"performer_pb2_grpc", "run.*", "sdk.*", "shared.*", "streams.*", "transactions.*",
]
ignore_errors = true
# Ruff enforces two things here: annotations are spelled the way python_requires>=3.11 allows,
# `X | None` and `dict[...]` rather than `Optional[X]` and `Dict[...]`, and the user-facing package
# has Google-style docstrings, the style Sphinx's napoleon reads. flake8, isort and autopep8 still
# own linting, import order and formatting, so `select` names only these rules.
[tool.ruff]
target-version = "py311"
line-length = 120
# pre-commit passes file names, and ruff checks a named file even when `exclude` matches it
# unless this is set.
force-exclude = true
extend-exclude = ["deps", "src", "examples", "couchbase/protocol/couchbase2/_generated"]
[tool.ruff.lint]
select = ["UP006", "UP007", "UP035", "UP045", "TID251", "D"]
# A class's docstring documents its constructor's arguments, so `__init__` and the other dunders
# need none of their own. Module docstrings are not required.
ignore = ["D100", "D104", "D105", "D107"]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.per-file-ignores]
# Docstrings are checked on the user-facing package: not the tests, the tools, the protocol
# implementations or a private module.
"{tests,tools,docs}/**" = ["D"]
"**/{tests,protocol}/**" = ["D"]
"**/_[!_]*.py" = ["D"]
"{setup,conftest,couchbase_version,pycbc_build_setup}.py" = ["D"]
# UP035 rejects importing the aliases PEP 585 replaced, but `Optional` and `Union` are not among
# them, and a `# type:` comment, which ruff does not read, can keep either alive. Banning the
# import catches every use, the comments included.
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"typing.Optional".msg = "Write `X | None`."
"typing.Union".msg = "Write `X | Y`."
[tool.isort]
multi_line_output = 1
force_grid_wrap = 3
use_parentheses = true
ensure_newline_before_comments = true
line_length = 120
order_by_type = true
# isort infers first-party membership from what is on disk, so tools/testgen/resolver.py
# sorts one way in a checkout that carries the `tests` package and another way in one
# that does not. Stating the membership makes the sort the same everywhere.
known_first_party = ["tests"]
# The FIT performer's generated protobuf modules, imported under the top-level names the mypy
# override above lists. Naming them keeps their sort off the disk as well, where `src/transactions`
# would pass `transactions` for first-party, and gives them one block of their own after the SDK's.
known_fit_generated = [
"hooks", "meta", "metrics", "observability", "performer", "performer_pb2", "performer_pb2_grpc",
"run", "sdk", "shared", "streams", "transactions",
]
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "FIT_GENERATED", "LOCALFOLDER"]