Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
255 lines (223 loc) · 7.32 KB
/
Copy pathpyproject.toml
File metadata and controls
255 lines (223 loc) · 7.32 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
[build-system]
requires = ["setuptools>=75.6.0"]
build-backend = "setuptools.build_meta"
[project]
name = "pydgraph"
authors = [
{ name = "Istari Digital, Inc.", email = "dgraph-admin@istaridigital.com" },
]
license = "Apache-2.0"
description = "Official Dgraph client implementation for Python"
readme = "README.md"
requires-python = ">=3.9"
classifiers = [
'Intended Audience :: Developers',
'Operating System :: OS Independent',
'Topic :: Database',
'Topic :: Software Development',
'Programming Language :: Python :: 3.9',
'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',
]
dependencies = ["grpcio>=1.65.0,<2.0.0", "protobuf>=4.23.0,<7.0.0"]
dynamic = ["version"]
[tool.setuptools.dynamic]
version = { attr = "pydgraph.meta.VERSION" }
[dependency-groups]
dev = [
"grpc-stubs>=1.53.0.6",
"mypy>=1.14.1",
"mypy-protobuf>=4.0.0",
"pydantic-settings>=2.8.1",
"ruff>=0.8.4",
"ty>=0.0.8",
"types-grpcio>=1.0.0.20251009",
"types-protobuf>=6.32.1.20251210",
"types-requests>=2.32.0.20241016",
]
[project.optional-dependencies]
dev = [
"build>=1.2.2.post1",
"grpcio-tools>=1.66.2",
"pytest>=8.3.3",
"pytest-asyncio>=0.23.0",
"pytest-benchmark>=4.0.0",
"pygal>=3.0.0",
"ruff>=0.8.4",
"ty>=0.0.8",
]
[project.urls]
"Homepage" = "https://github.com/dgraph-io/pydgraph"
[tool.pytest.ini_options]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
[tool.ruff]
target-version = "py39"
exclude = [
".venv",
"build",
"pydgraph/proto/api_pb2.py",
"pydgraph/proto/api_pb2.pyi",
"pydgraph/proto/api_pb2_grpc.py",
"pydgraph/proto/api_pb2_grpc.pyi",
"examples/embeddings/",
"examples/notebook/",
]
[tool.ruff.lint]
# Maximal best-practices ruleset
select = [
"A", # flake8-builtins (shadowing builtins)
"ARG", # flake8-unused-arguments
"ASYNC", # flake8-async
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"C90", # mccabe complexity
"E", # pycodestyle errors
"ERA", # eradicate (commented-out code)
"F", # pyflakes
"FURB", # refurb (modernize idioms)
"G", # flake8-logging-format
"I", # isort (import sorting)
"ICN", # flake8-import-conventions
"N", # pep8-naming
"PERF", # perflint (performance)
"PGH", # pygrep-hooks (blanket noqa, blanket type-ignore)
"PIE", # flake8-pie (misc lints)
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"RET", # flake8-return
"RSE", # flake8-raise
"RUF", # ruff-specific rules
"S", # flake8-bandit (security)
"SIM", # flake8-simplify
"TID", # flake8-tidy-imports
"TRY", # tryceratops (exception handling)
"UP", # pyupgrade
"W", # pycodestyle warnings
]
ignore = [
"E501", # line-too-long (handled by formatter)
"S101", # assert-used (OK in tests, configured per-file below)
"TRY003", # Avoid specifying long messages outside exception class
"SIM108", # Use ternary operator (can reduce readability)
"RET504", # Unnecessary variable assignment before return
"PTH123", # open() should be replaced by Path.open() (too strict)
"G004", # Logging statement uses f-string (acceptable in modern Python)
]
[tool.ruff.lint.mccabe]
max-complexity = 10
[tool.ruff.lint.isort]
known-first-party = ["pydgraph"]
[tool.ruff.lint.per-file-ignores]
"tests/**" = [
"S101", # assert allowed in tests
"S106", # hardcoded passwords OK in tests
"S110", # try-except-pass OK in tests
"S112", # try-except-continue OK in tests
"A001", # variable name shadowing builtins OK in tests
"A004", # import shadowing builtins OK in tests (pydgraph.open)
"ARG001", # unused function arguments OK in tests (fixtures)
"B017", # pytest.raises(Exception) OK in tests
"N802", # camelCase function names OK in tests (legacy)
"N806", # camelCase variable names OK in tests
"PERF203", # try-except in loop OK in tests (performance not critical)
"PLR2004", # magic values OK in tests
"PT011", # pytest.raises() is too broad OK in tests
"PT012", # pytest.raises() block complexity OK in tests
"PT027", # unittest-style assertRaises OK in tests (legacy)
"SIM105", # try-except-pass patterns OK in tests
]
"examples/**" = [
"S101", # assert OK in examples
"T201", # print statements OK in examples
"ERA001", # commented-out code OK in examples (docs/demos)
"N802", # camelCase function names OK in examples
"N803", # camelCase argument names OK in examples
"N806", # camelCase variable names OK in examples
"SIM300", # Yoda conditions OK in examples
"ARG001", # unused arguments OK in examples
"ARG002", # unused method arguments OK in examples
"C901", # complex functions OK in examples
"PIE808", # unnecessary range(0, x) OK in examples
]
[tool.ty.src]
exclude = [
"pydgraph/proto/api_pb2.py",
"pydgraph/proto/api_pb2.pyi",
"pydgraph/proto/api_pb2_grpc.py",
"pydgraph/proto/api_pb2_grpc.pyi",
]
[[tool.ty.overrides]]
include = ["pydgraph/async_client_stub.py"]
[tool.ty.overrides.rules]
# DgraphStub assigned as DgraphAsyncStub (runtime gRPC compatibility)
invalid-assignment = "ignore"
[[tool.ty.overrides]]
include = ["pydgraph/async_txn.py"]
[tool.ty.overrides.rules]
# protobuf str fields accept bytes at runtime (.encode("utf8"))
invalid-assignment = "ignore"
[[tool.ty.overrides]]
include = ["pydgraph/retry.py"]
[tool.ty.overrides.rules]
# BaseException→Exception narrowing in __exit__, functools.wraps return type
invalid-assignment = "ignore"
invalid-return-type = "ignore"
[tool.mypy]
python_version = "3.9"
warn_unused_configs = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
no_site_packages = true
exclude = [".venv", "build", "pydgraph/proto/", "examples/embeddings/"]
[[tool.mypy.overrides]]
module = "pydgraph.proto.api_pb2"
follow_imports = "skip"
[[tool.mypy.overrides]]
module = "pydgraph.proto.api_pb2_grpc"
follow_imports = "skip"
disable_error_code = ["overload-cannot-match"]
[[tool.mypy.overrides]]
module = "examples.embeddings.computeEmbeddings"
ignore_errors = true
[[tool.mypy.overrides]]
module = "grpc_tools.*"
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "packaging.*"
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "pytest.*"
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "pytest_benchmark.*"
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "grpc.*"
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "pydgraph.client"
# Disable arg-type: protobuf enum type mismatch with grpc-stubs; ty handles this correctly
disable_error_code = ["arg-type"]
[[tool.mypy.overrides]]
module = "pydgraph.async_client_stub"
# DgraphStub is assigned as DgraphAsyncStub (runtime gRPC compatibility)
disable_error_code = ["assignment"]
[[tool.mypy.overrides]]
module = "pydgraph.async_txn"
# protobuf str fields accept bytes at runtime (.encode("utf8"))
disable_error_code = ["assignment"]
[[tool.mypy.overrides]]
module = "pydgraph.retry"
# BaseException→Exception narrowing in __exit__, functools.wraps return type
disable_error_code = ["assignment", "return-value"]
[[tool.mypy.overrides]]
module = "google.*"
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "google.protobuf.*"
ignore_missing_imports = true