-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathpyproject.toml
More file actions
445 lines (405 loc) · 16.7 KB
/
pyproject.toml
File metadata and controls
445 lines (405 loc) · 16.7 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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
[project]
name = "archipy"
description = "Architecture + Python – Perfect for structured design."
authors = [
{ name = "Hossein Nejati", email = "hosseinnejati14@gmail.com" },
{ name = "Mehdi Einali", email = "einali@gmail.com" },
]
readme = "README.md"
version = "0.1.0" # This vesrion set on publish flow!
requires-python = ">=3.14,<4"
dependencies = [
"pydantic>=2.12.5",
"pydantic-settings>=2.13.1",
"requests>=2.32.5",
"jdatetime>=5.2.0",
]
license = { file = "LICENSE" }
[project.optional-dependencies]
# Core optional dependencies
aiosqlite = ["aiosqlite>=0.22.1"]
behave = ["behave>=1.3.3"]
cache = ["cachetools>=7.0.1", "async-lru>=2.2.0"]
dependency-injection = ["dependency-injector>=4.48.3"]
elastic-apm = ["elastic-apm>=6.25.0"]
elasticsearch = ["elasticsearch>=9.3.0"]
elasticsearch-async = ["elasticsearch[async]>=9.3.0"]
fakeredis = ["fakeredis>=2.34.0"]
fastapi = ["fastapi[all]>=0.133.0"]
grpc = ["grpcio>=1.78.1", "grpcio-health-checking>=1.78.1", "protobuf>=6.33.5"]
jwt = ["pyjwt>=2.11.0"]
kafka = ["confluent-kafka>=2.13.0"]
kavenegar = ["kavenegar>=1.1.2"]
keycloak = ["python-keycloak>=7.1.1", "cachetools>=7.0.1", "async-lru>=2.2.0"]
minio = ["boto3>=1.42.56", "cachetools>=7.0.1", "async-lru>=2.2.0"]
parsian-ipg = ["zeep>=4.3.2", "requests[socks]>=2.32.5"]
postgres = ["psycopg[binary,pool]>=3.3.3"]
prometheus = ["prometheus-client>=0.24.1"]
redis = ["redis[hiredis]>=7.2.0"]
scheduler = ["apscheduler>=3.11.2"]
scylladb = ["scylla-driver>=3.29.8", "lz4>=4.4.5", "cachetools>=7.0.1", "async-lru>=2.2.0"]
sentry = ["sentry-sdk>=2.53.0"]
sqlalchemy = ["sqlalchemy>=2.0.47"]
sqlalchemy-async = ["sqlalchemy[asyncio]>=2.0.47"]
starrocks = ["starrocks>=1.3.3", "pymysql>=1.1.2"]
starrocks-async = ["starrocks>=1.3.3", "aiomysql>=0.3.2", "asyncmy>=0.2.11"]
temporalio = ["temporalio>=1.23.0"]
testcontainers = ["testcontainers>=4.14.1"]
[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = 'tests'
markers = []
filterwarnings = [
'error',
'ignore:This is a placeholder until pydantic-settings.*:UserWarning',
'ignore::UserWarning',
'ignore::DeprecationWarning'
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[dependency-groups]
dev = [
"add-trailing-comma>=4.0.0",
"bandit>=1.9.3",
"codespell>=2.4.1",
"ty>=0.0.18",
"pre-commit-hooks>=6.0.0",
"pre-commit>=4.5.1",
"ruff>=0.15.2",
"types-cachetools>=6.2.0.20251022",
"types-grpcio>=1.0.0.20251009",
"types-protobuf>=6.32.1.20260221",
"types-pymysql>=1.1.0.20251220",
"types-regex>=2026.2.19.20260221",
"types-requests>=2.32.4.20260107",
"validate-pyproject>=0.25",
]
docs = [
"mkdocs-autorefs>=1.4.4",
"mkdocs-material>=9.7.3",
"mkdocs>=1.6.1",
"mkdocstrings-python>=2.0.3",
"mkdocstrings>=1.0.3",
"pymdown-extensions>=10.21",
]
[project.urls]
Homepage = "https://syntaxarc.github.io/ArchiPy/"
Documentation = "https://archipy.readthedocs.io/"
"Bug Tracker" = "https://github.com/SyntaxArc/ArchiPy/issues"
"Source Code" = "https://github.com/SyntaxArc/ArchiPy"
"Contributing" = "https://github.com/SyntaxArc/ArchiPy/blob/master/CONTRIBUTING.md"
"Code of Conduct" = "https://github.com/SyntaxArc/ArchiPy/blob/master/CODE_OF_CONDUCT.md"
[tool.ruff]
# Enable automatic fixes for supported rules
fix = true
lint.select = [
"A", # flake8-builtins
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
"ASYNC", # flake8-async
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C4", # flake8-comprehensions
"C901", # complex-structure
"D", # pydocstyle
"E", # pycodestyle errors
"EM", # flake8-errmsg
"ERA", # eradicate
"F", # pyflakes
"FAST", # FastAPI
"FURB", # refurb
"G", # flake8-logging-format
"I", # isort
"ICN", # flake8-import-conventions
"LOG", # flake8-logging
"PERF", # Perflint
"PIE", # flake8-pie
"PL", # Pylint (includes PLC, PLE, PLR, PLW)
"PTH", # flake8-use-pathlib
"PYI", # flake8-pyi
"RUF", # Ruff-specific rules
"S", # flake8-bandit
"SIM", # flake8-simplify
"SLOT", # flake8-slots
"T10", # flake8-debugger
"T20", # flake8-print
"TC", # flake8-type-checking
"TID", # flake8-tidy-imports
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle warnings
]
# Explicitly ignore specific rules
lint.ignore = [
"ANN002", # Missing type annotation for *args
"ANN003", # Missing type annotation for **kwargs
"BLE001", # Do not catch blind exception: `Exception`
"C901", # Function is too complex (McCabe complexity)
"D100", # Missing docstring in public module
"D104", # Missing docstring in public package
"D107", # Missing docstring in `__init__`
"E501", # Line too long (handled by Ruff formatter)
"EM101", # Raw string in exception (conflicts with error handling patterns)
"EM102", # f-string in exception (conflicts with error handling patterns)
"F811", # Redefinition of unused function
"G004", # Logging statement uses f-string
"PERF203", # try-except in loop (sometimes necessary for robust error handling)
"PLR0904", # Too many public methods (adapters may need many methods)
"PLR0913", # Too many arguments in function (e.g., FastAPI Swagger)
"PLR0914", # Too many locals (complex business logic may require this)
"PLR1702", # Too many nested blocks (BDD steps may have nested scenarios)
"PLR2004", # Magic value used in comparison
"Q000", # Allow single quotes (conflicts with Ruff formatter's double-quote preference)
"RUF001", "RUF003", # String contains ambiguous characters
"S101", # Ignore assert used (equivalent to bandit's B101)
"S301", # Ignore pickle usage (equivalent to bandit's B301)
"S403", # Ignore pickle usage (equivalent to bandit's B403)
"SIM102", # Collapsible if (sometimes explicit is clearer)
"SIM108", # Use ternary (sometimes if-else is more readable)
"TC001", # Move typing import to TYPE_CHECKING (may break Pydantic)
"TC002", # Type-checking import issues
"TC003", # Move stdlib import to TYPE_CHECKING (may break runtime)
"TRY003", #Avoid specifying long messages outside the exception class
"TRY301", # Abstract raise into a function
]
# Define source directories
src = ["archipy", "tests", "features"]
exclude = [
"features/*",
"scripts/*",
]
# Set line length for Ruff formatter
line-length = 120
# Target Python version
target-version = "py314"
# Ruff format configuration
[tool.ruff.format]
# Use double quotes for strings
quote-style = "double"
# Use spaces for indentation
indent-style = "space"
# Line ending style
line-ending = "auto"
# Skip magic trailing comma
skip-magic-trailing-comma = false
# Docstring code format
docstring-code-format = true
# Docstring code line length
docstring-code-line-length = "dynamic"
# Per-file ignores
[tool.ruff.lint.per-file-ignores]
# Ignore F811 (redefinition of function) in steps implementations
"archipy/configs/config_template.py" = ["S104"] # Allow binding to all interfaces for containerized deployments
"archipy/models/errors/keycloak_errors.py" = ["ANN401"] # Allow Any type for additional_data
"archipy/helpers/interceptors/grpc/base/client_interceptor.py" = ["ANN401"] # Allow Any type for gRPC message types
# Allow Any type for gRPC message types
"archipy/helpers/decorators/sqlalchemy_atomic.py" = ["BLE001"] # Allow complex decorator patterns
"archipy/helpers/utils/keycloak_utils.py" = ["FBT001", "FBT002", "PLC0415"] # Allow lazy imports for optional dependencies
"archipy/helpers/utils/app_utils.py" = ["PLC0415", "ARG004"] # Allow lazy imports and unused args in FastAPI handlers
"archipy/helpers/utils/jwt_utils.py" = ["S105", "PLC0415"] # Allow lazy imports for optional dependencies
"archipy/helpers/utils/error_utils.py" = ["PLC0415"] # Allow lazy imports for optional dependencies
"archipy/helpers/utils/file_utils.py" = ["S324"] # nginx secure_link requires MD5 (compatibility)
"archipy/adapters/orm/sqlalchemy/ports.py" = ["ANN401", "ARG002", "PLR0913"] # Allow Any, unused args, many params in interfaces
"archipy/adapters/orm/sqlalchemy/adapters.py" = ["ANN401", "ARG002", "PERF401", "PLR0912", "PLR0915"] # Allow Any, unused args, manual comprehensions, complexity
"archipy/adapters/elasticsearch/ports.py" = ["ANN401"] # Allow Any type for **kwargs parameters
"archipy/adapters/keycloak/ports.py" = ["ANN401"] # Allow Any type for **kwargs parameters
"archipy/adapters/redis/ports.py" = ["ANN401", "D102", "FBT001", "FBT002", "A002", "ARG002"] # Interface methods may have unused params
"archipy/adapters/scylladb/ports.py" = ["ANN401"] # Allow Any type for CQL parameters
"archipy/models/dtos/base_protobuf_dto.py" = ["ANN401"]
"archipy//helpers/utils/keycloak_utils.py" = ["B008"]
"archipy/adapters/kafka/adapters.py" = ["BLE001"]
"archipy/adapters/base/sqlalchemy/session_manager_registry.py" = ["PLC0415"] # Circular import workaround
"archipy/adapters/temporal/base.py" = ["ARG002"] # Interface methods may have unused params
"archipy/adapters/postgres/sqlalchemy/session_manager_registry.py" = ["PLC0415"] # Circular import workaround
"archipy/adapters/sqlite/sqlalchemy/session_manager_registry.py" = ["PLC0415"] # Circular import workaround
"archipy/adapters/starrocks/sqlalchemy/session_manager_registry.py" = ["PLC0415"] # Circular import workaround
"archipy/adapters/elasticsearch/adapters.py" = ["ANN401"] # Allow Any type for **kwargs parameters
"archipy/adapters/redis/adapters.py" = ["ANN401", "FBT001", "FBT002", "RET504", "PGH003", "PLC0415"] # Lazy imports for optional dependencies
"archipy/adapters/redis/mocks.py" = ["ARG002", "ARG004", "ARG005", "ANN401", "ARG001", "PLR0913", "PLC0415"] # Lazy imports and mock functions
"archipy/adapters/scylladb/adapters.py" = ["BLE001", "ANN401", "PLC0415"] # Allow broad exceptions, Any types, lazy imports
"archipy/adapters/keycloak/adapters.py" = ["BLE001", "PLC0415"] # Lazy imports for optional dependencies
"archipy/adapters/temporal/*" = ["ANN401", "TRY300", "RUF006", "PLC0415"] # Allow Any types for Temporal's dynamic system, else blocks, asyncio task handling, lazy imports
"archipy/adapters/scylladb/*" = ["S608"] # False positives - using parameterized queries with %s placeholders
"archipy/helpers/decorators/*" = ["ANN401", "ARG001", "PLR0913", "PLC0415"] # Allow Any, unused args, many params, lazy imports in decorators
"archipy/helpers/interceptors/grpc/trace/client_interceptor.py" = ["ANN401", "PLC0415"] # Lazy imports
"archipy/helpers/interceptors/grpc/trace/server_interceptor.py" = ["PLC0415"] # Lazy imports
"archipy/helpers/interceptors/grpc/metric/server_interceptor.py" = ["PLC0415"] # Lazy imports
"archipy/models/errors/base_error.py" = ["PLC0415"] # Circular import workaround
"features/steps/*" = ["F811", "ANN001", "ANN201", "ARG001", "PLR0913"] # Allow redefinition, missing annotations, unused args in BDD steps
"scripts/*" = ["S603", "S607"]
# Configure McCabe complexity
[tool.ruff.lint.mccabe]
max-complexity = 10 # Maximum allowed McCabe complexity
# Configure Pylint rules
[tool.ruff.lint.pylint]
max-args = 5 # Maximum number of function arguments
max-branches = 25 # Maximum number of branches in a function (increased for complex auth/tracing logic)
max-returns = 16 # Maximum number of return statements in a function
max-statements = 75 # Maximum number of statements in a function (increased for decorators/interceptors)
# Configure isort (import sorting)
[tool.ruff.lint.isort]
combine-as-imports = true # Combine `import` and `from ... import` statements
known-first-party = ["archipy"] # Treat `archipy` as a first-party module
section-order = [
"future", # `__future__` imports
"standard-library", # Standard library imports
"third-party", # Third-party imports
"first-party", # First-party imports (e.g., `archipy`)
"local-folder", # Local folder imports
]
[tool.ruff.lint.flake8-quotes]
inline-quotes = "double" # Use double quotes for inline strings
multiline-quotes = "double" # Use double quotes for multiline strings
[tool.ruff.lint.pydocstyle]
convention = "google" # Use Google-style docstrings
# Configure flake8-comprehensions
[tool.ruff.lint.flake8-comprehensions]
allow-dict-calls-with-keyword-arguments = true # Allow dict(a=1, b=2) style
# Configure flake8-errmsg
[tool.ruff.lint.flake8-errmsg]
max-string-length = 80 # Allow reasonable error messages
# Configure flake8-type-checking
[tool.ruff.lint.flake8-type-checking]
runtime-evaluated-base-classes = [
"pydantic.BaseModel",
"pydantic_settings.BaseSettings",
]
runtime-evaluated-decorators = [
"pydantic.validator",
"pydantic.field_validator",
]
exempt-modules = ["typing", "typing_extensions"]
# Configure flake8-unused-arguments
[tool.ruff.lint.flake8-unused-arguments]
ignore-variadic-names = true # Allow unused *args, **kwargs
[tool.ty.environment]
# Target Python version
python-version = "3.14"
[tool.ty.src]
# Include source directories
include = ["archipy"]
# Exclude directories from type checking
exclude = ["features", "scripts"]
[tool.ty.rules]
# Enable strict type checking rules (similar to mypy strict mode)
# Error-level rules (default)
byte-string-type-annotation = "error"
call-non-callable = "error"
conflicting-argument-forms = "error"
conflicting-declarations = "error"
conflicting-metaclass = "error"
cyclic-class-definition = "error"
cyclic-type-alias-definition = "error"
duplicate-base = "error"
duplicate-kw-only = "error"
escape-character-in-forward-annotation = "error"
fstring-type-annotation = "error"
implicit-concatenated-string-type-annotation = "error"
inconsistent-mro = "error"
index-out-of-bounds = "error"
instance-layout-conflict = "error"
invalid-argument-type = "error"
invalid-assignment = "error"
invalid-attribute-access = "error"
invalid-await = "error"
invalid-base = "error"
invalid-context-manager = "error"
invalid-declaration = "error"
invalid-exception-caught = "error"
invalid-explicit-override = "error"
invalid-generic-class = "error"
invalid-key = "error"
invalid-legacy-type-variable = "error"
invalid-metaclass = "error"
invalid-method-override = "error"
invalid-named-tuple = "error"
invalid-newtype = "error"
invalid-overload = "error"
invalid-parameter-default = "error"
invalid-paramspec = "error"
invalid-protocol = "error"
invalid-raise = "error"
invalid-return-type = "error"
invalid-super-argument = "error"
invalid-syntax-in-forward-annotation = "error"
invalid-type-alias-type = "error"
invalid-type-arguments = "error"
invalid-type-checking-constant = "error"
invalid-type-form = "error"
invalid-type-guard-call = "error"
invalid-type-guard-definition = "error"
invalid-type-variable-constraints = "error"
missing-argument = "error"
missing-typed-dict-key = "error"
no-matching-overload = "error"
not-subscriptable = "error"
not-iterable = "error"
override-of-final-method = "error"
parameter-already-assigned = "error"
positional-only-parameter-as-kwarg = "error"
raw-string-type-annotation = "error"
static-assert-error = "error"
subclass-of-final-class = "error"
super-call-in-named-tuple-method = "error"
too-many-positional-arguments = "error"
type-assertion-failure = "error"
unavailable-implicit-super-arguments = "error"
unknown-argument = "error"
unresolved-attribute = "error"
unresolved-import = "error"
unresolved-reference = "error"
unsupported-bool-conversion = "error"
unsupported-operator = "error"
zero-stepsize-in-slice = "error"
# Warning-level rules (default) - set to error for strict checking
ambiguous-protocol-member = "error"
deprecated = "error"
ignore-comment-unknown-rule = "error"
invalid-ignore-comment = "error"
possibly-missing-attribute = "error"
possibly-missing-implicit-call = "error"
possibly-missing-import = "error"
redundant-cast = "error"
undefined-reveal = "error"
unresolved-global = "error"
unsupported-base = "error"
useless-overload-body = "error"
# Ignore-level rules (default) - set to error for strict checking
division-by-zero = "error"
possibly-unresolved-reference = "error"
unused-ignore-comment = "error"
[tool.config]
pyproject_root_var = "pyproject"
[tool.codespell]
ignore-words-list = "exat,convertor"
skip = ".git,__pycache__,build,dist"
[tool.bandit]
# Bandit configuration for security scanning
# https://bandit.readthedocs.io/en/latest/config.html
# Target directories to scan
targets = ["archipy"]
# Exclude directories from scanning
exclude_dirs = ["features", "docs", "scripts"]
# Skip specific test IDs
# B101: assert_used - Allow assert statements in tests
# B301: pickle - Allow pickle usage (needed for some serialization)
# B403: import_pickle - Allow pickle imports
skips = ["B101", "B301", "B403"]
[tool.behave]
# Parallel execution settings
parallel = 8
parallel_scheme = "multiprocessing"
# Output formatting
show_snippets = false
show_source = false
show_timings = true
# Logging and capture
capture = true
capture_stdout = true
capture_stderr = true
capture_log = true
# Test execution
stop = false
dry_run = false
verbose = false