-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathpyproject.toml
More file actions
202 lines (181 loc) · 5.81 KB
/
Copy pathpyproject.toml
File metadata and controls
202 lines (181 loc) · 5.81 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
[project]
name = "protovalidate"
version = "2.0.0"
description = "Protocol Buffer Validation for Python"
readme = "README.md"
requires-python = ">=3.10"
license = "Apache-2.0"
license-files = ["LICENSE"]
keywords = ["protobuf", "protocol buffer", "validate"]
classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Typing :: Typed",
]
dependencies = [
"protobuf-py>=0.2.0",
]
[project.urls]
Documentation = "https://protovalidate.com"
Homepage = "https://github.com/bufbuild/protovalidate-py"
Issues = "https://github.com/bufbuild/protovalidate-py/issues"
Source = "https://github.com/bufbuild/protovalidate-py"
[dependency-groups]
# We ensure all dependencies are installed by default so IDE works properly for development.
dev = [
{ include-group = "dev-optional" },
{ include-group = "dev-required" },
]
# All dependencies required for CI and development, including running baseline tests.
dev-required = [
"buf-bin==1.73.0",
"fix-protobuf-imports==0.1.7",
"license-header==0.0.1",
"maturin==1.15.0",
"poethepoet==0.48.0",
"pydantic==2.13.5",
"pytest==9.1.1",
"pytest-benchmark==5.3.0",
"ruff==0.16.10",
"tombi==1.7.2",
"ty==0.0.84",
"types-protobuf==6.32.1.20260221",
]
# Optional dependencies, used for development of optional features. We run tests without
# these installed to ensure missing optional dependencies does not introduce breakage.
# Unlike most dev dependencies, we don't pin to allow testing old and new
# versions.
dev-optional = [
"protobuf>=6.31.0",
]
docs = ["mkdocstrings-python==2.0.9", "zensical==0.0.67"]
[build-system]
requires = ["maturin>=1.12,<2.0"]
build-backend = "maturin"
## License headers
[tool.licenseheader]
copyright-holder = "Buf Technologies, Inc."
year-range = "2023-2026"
ignore = [
".github",
"buf.yaml",
"buf.gen.yaml",
"test/conformance/nonconforming.yaml",
"**/third_party/**",
]
[tool.maturin]
# A submodule keeps its own .git directory, which is not part of the source.
exclude = [
{ path = "crates/**/.git/**/*", format = "sdist" },
{ path = "crates/**/.git", format = "sdist" },
]
features = ["pyo3/extension-module", "pyo3/abi3-py310"]
# The C++ sources are submodules, so they are picked up from the working tree
# rather than from `git ls-files`, which stops at a submodule boundary.
include = [
{ path = "crates/**/*", format = "sdist" },
{ path = "build.rs", format = "sdist" },
{ path = "Cargo.lock", format = "sdist" },
]
module-name = "protovalidate._protovalidate"
# Mixed project: Rust in src/, the Python package alongside it.
python-source = "."
[tool.pytest]
addopts = [
"--benchmark-disable",
"--benchmark-group-by=func,param:_id",
]
# Turn all warnings into errors,
# except DeprecationWarnings (which we knowingly tolerate due to using old `protobuf` APIs).
filterwarnings = ["error", "ignore::DeprecationWarning"]
strict = true
# restrict testpaths to speed up test discovery
testpaths = ["test"]
[tool.ruff]
target-version = "py310"
exclude = ["*_pb2.py", "*_pb2.pyi", "third_party"]
[tool.ruff.format]
skip-magic-trailing-comma = true
docstring-code-format = true
[tool.ruff.lint]
typing-extensions = false
select = ["ALL"]
ignore = [
# Rules recommended to ignore when using ruff formatting
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"W191",
"E111",
"E114",
"E117",
"E501",
"D206",
"D300",
"Q",
"COM812",
"COM819",
"TRY003", # Avoid specifying long messages outside the exception class
"SLF001", # Private member accessed
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
"PLR2004", # Magic value used in comparison - not helpful to name obvious constants
# Complexity rules: humans reviewing code can judge whether complexity is justified.
"C901", # McCabe complexity
"PLR0911", # Too many return statements
"PLR0912", # Too many branches
"PLR0913", # Too many arguments in function definition
"PLR0914", # Too many local variables
"PLR0915", # Too many statements
"PLR0916", # Too many boolean expressions
"PLR0917", # Too many positional arguments
"PLR1702", # Too many nested blocks
# TODO rules
"TD",
"FIX002", # Line contains TODO, consider resolving the issue
]
[tool.ruff.lint.per-file-ignores]
"**/test/**/*.py" = [
# missing docstrings; unnecessary in tests.
"D1",
"INP001", # File is part of an implicit namespace package
"FBT001", # boolean positional args are fine in tests
"FBT002", # boolean default positional args are fine in tests
"FBT003", # boolean positional values are fine in tests
"S101", # assert is expected in tests
]
"**/scripts/*.py" = [
"D1", # missing docstrings; unnecessary in scripts.
"T201", # print is the user interface of a CLI script
"S603", # subprocess with list args and no shell is the tool-running pattern
"S607", # bazel and git are expected on PATH, not at a fixed location
]
"protovalidate/_protovalidate.pyi" = [
# Generated by `poe generate-stub`. The docstrings come from the Rust doc
# comments and are the point of generating the stub.
"PYI021",
]
[tool.ruff.lint.flake8-type-checking]
# Pydantic resolves annotations at runtime, so their imports can't be deferred.
runtime-evaluated-base-classes = ["pydantic.BaseModel"]
[tool.ruff.lint.isort]
required-imports = ["from __future__ import annotations"]
combine-as-imports = true
known-third-party = []
split-on-trailing-comma = false
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.tombi]
files.exclude = [
"**/third_party/**",
]
[tool.uv]
cache-keys = [
{ file = "pyproject.toml" },
{ file = "Cargo.toml" },
{ file = "Cargo.lock" },
{ file = "build.rs" },
{ file = "src/**" },
{ file = "crates/**" },
]