-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathpyproject.toml
More file actions
423 lines (373 loc) · 9.88 KB
/
pyproject.toml
File metadata and controls
423 lines (373 loc) · 9.88 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
[project]
name = "ccproxy-api"
dynamic = ["version"]
description = "API server that provides an Anthropic and OpenAI compatible interface over Claude Code, allowing to use your Claude OAuth account or over the API."
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"aiofiles>=25.1.0",
"fastapi[standard]>=0.119.0",
"httpx[http2]>=0.28.1",
"pydantic>=2.12.2",
"pydantic-settings>=2.11.0",
"rich>=14.2.0",
"rich-toolkit>=0.15.1",
"structlog>=25.4.0",
"typer>=0.19.2",
"typing-extensions>=4.15.0",
"uvicorn>=0.37.0",
"packaging>=25.0",
"sortedcontainers>=2.4.0",
"pyjwt>=2.10.1",
]
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
[tool.hatch]
version.source = "vcs"
build.hooks.vcs.version-file = "ccproxy/core/_version.py"
build.targets.wheel.packages = ["ccproxy"]
build.targets.wheel.include = ["ccproxy/data/*.json"]
build.targets.sdist.include = [
"ccproxy/**/*.py",
"ccproxy/**/*.json",
"ccproxy/static/dashboard/**",
"README.md",
"LICENSE",
"pyproject.toml",
]
[dependency-groups]
all = [
"qrcode>=8.2",
"pyjwt>=2.10.1",
"sqlmodel>=0.0.27",
"SQLAlchemy>=2.0.44",
"duckdb-engine>=0.17.0",
"duckdb>=1.3.2",
"fastapi-mcp>=0.4.0",
"textual>=6.3.0",
"aioconsole>=0.8.2",
"prometheus-client>=0.23.1",
"sse-starlette>=3.0.2",
"claude-agent-sdk>=0.1.4",
]
test = [
"mypy",
"pytest",
"pytest-asyncio",
"pytest-cov",
"pytest-timeout",
"pytest-env",
"pytest-httpx",
"pytest-xdist",
]
docs = [
"mkdocs>=1.5.3",
"mkdocs-material>=9.5.0",
"mkdocstrings[python]>=0.24.0",
"mkdocs-gen-files>=0.5.0",
"mkdocs-literate-nav>=0.6.0",
"mkdocs-section-index>=0.3.0",
"mkdocs-swagger-ui-tag>=0.6.0",
"mkdocs-include-markdown-plugin>=6.0.0",
"mkdocs-mermaid2-plugin>=1.1.0",
"mkdocs-glightbox>=0.3.0",
"mkdocs-minify-plugin>=0.7.0",
"mkdocs-redirects>=1.2.0",
]
dev = [
{ include-group = "test" },
{ include-group = "docs" },
{ include-group = "all" },
"ruff",
"pre-commit",
"mypy",
"tox",
"bandit",
"types-aiofiles>=25.1.0",
"types-PyYAML>=6.0.12.20250915",
"keyring>=25.7.0",
]
[project.optional-dependencies]
plugins-claude = ["claude-agent-sdk>=0.1.4", "qrcode>=8.2", "keyring>=25.7.0"]
plugins-codex = ["qrcode>=8.2", "pyjwt>=2.10.1"]
plugins-storage = [
"sqlmodel>=0.0.27",
"SQLAlchemy>=2.0.44",
"duckdb-engine>=0.17.0",
"duckdb>=1.3.2",
]
plugins-mcp = ["fastapi-mcp>=0.4.0"]
plugins-tui = ["textual>=6.3.0", "aioconsole>=0.8.2"]
plugins-metrics = ["prometheus-client>=0.23.1"]
[project.scripts]
# ccproxy = "ccproxy.cli:app"
ccproxy = "ccproxy.cli:main"
ccproxy-api = "ccproxy.cli:main"
ccproxy-perm = "ccproxy.cli.commands.permission:main"
[project.entry-points."ccproxy.plugins"]
access_log = "ccproxy.plugins.access_log.plugin:factory"
analytics = "ccproxy.plugins.analytics.plugin:factory"
claude_api = "ccproxy.plugins.claude_api.plugin:factory"
claude_sdk = "ccproxy.plugins.claude_sdk.plugin:factory"
codex = "ccproxy.plugins.codex.plugin:factory"
command_replay = "ccproxy.plugins.command_replay.plugin:factory"
copilot = "ccproxy.plugins.copilot.plugin:factory"
dashboard = "ccproxy.plugins.dashboard.plugin:factory"
docker = "ccproxy.plugins.docker.plugin:factory"
duckdb_storage = "ccproxy.plugins.duckdb_storage.plugin:factory"
metrics = "ccproxy.plugins.metrics.plugin:factory"
oauth_claude = "ccproxy.plugins.oauth_claude.plugin:factory"
oauth_codex = "ccproxy.plugins.oauth_codex.plugin:factory"
permissions = "ccproxy.plugins.permissions.plugin:factory"
pricing = "ccproxy.plugins.pricing.plugin:factory"
request_tracer = "ccproxy.plugins.request_tracer.plugin:factory"
max_tokens = "ccproxy.plugins.max_tokens.plugin:factory"
credential_balancer = "ccproxy.plugins.credential_balancer.plugin:factory"
[tool.coverage.run]
source = ["ccproxy/*", "tests/*"]
omit = [
"ccproxy/core/_version.py",
"ccproxy/testing/*",
"ccproxy/__main__.py",
"tests/conftest.py",
"*/migrations/*",
"*/__pycache__/*",
"*/.*",
]
branch = true
parallel = true
concurrency = ["thread", "multiprocessing"]
[tool.coverage.report]
precision = 2
show_missing = true
skip_covered = false
skip_empty = true
sort = "Cover"
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"from typing import",
"VERSION_TUPLE = Tuple",
"class .*Protocol.*:",
"@(abc\\.)?abstractmethod",
]
[tool.coverage.html]
directory = "htmlcov"
[tool.coverage.xml]
output = "coverage.xml"
[tool.ruff]
target-version = "py311"
line-length = 88
src = ["ccproxy", "tests"]
[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # Pyflakes
"I", # isort
"N", # pep8-naming
"UP", # pyupgrade
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"SIM", # flake8-simplify
"PTH", # flake8-use-pathlib
]
ignore = [
"E501", # Line too long (handled by formatter)
"B008", # Do not perform function calls in argument defaults
"N806", # Variable in function should be lowercase (for pandas df, etc)
"SIM108", # Use ternary operator (sometimes less readable)
"F401", # Imported but unused
"F841", # Local variable assigned but never used
"B904", # "Use 'except*' to catch multiple exceptions"
"SIM102", # "Use 'set' operations to compute set intersections"
]
[tool.ruff.lint.per-file-ignores]
"tests/**" = ["TID251"]
# relax on tests
"tests/*" = [
"N802",
"N803",
"B023",
] # arg/function name should be lowercase, allow assert, does not bind loop variable
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
[tool.ruff.lint.isort]
known-first-party = ["ccproxy"]
force-single-line = false
lines-after-imports = 2
[tool.mypy]
python_version = "3.11"
show_column_numbers = true
follow_imports = "normal"
exclude = [
"^[^/]+\\.py$",
"docs/",
"site/",
"examples/",
"scripts/",
"git_ignore/",
]
namespace_packages = true
explicit_package_bases = true
strict = true
# Allow intentionally unreachable branches used for flow control
warn_unreachable = false
[[tool.mypy.overrides]]
module = ["fastapi_mcp"]
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "plugins.permissions.mcp"
disable_error_code = ["unused-ignore"]
[[tool.mypy.overrides]]
module = "tests.*"
ignore_errors = false
disallow_untyped_defs = false
disallow_untyped_calls = false
warn_unused_ignores = false
[tool.pytest.ini_options]
minversion = "6.0"
addopts = [
"-ra",
"--strict-markers",
"--strict-config",
# "--disable-warnings",
"--tb=short",
"-v",
"--import-mode=importlib",
"-m",
"not slow",
# "--cov=ccproxy",
# "--cov=tests",
# "--cov-report=term-missing",
# "--cov-report=html:htmlcov",
# "--cov-report=xml",
# "--cov-branch",
# "--cov-fail-under=80",
]
testpaths = ["tests"]
## Plugin tests are colocated under tests/plugins/<plugin>/
python_files = ["test_*.py", "*_test.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
timeout = 60
timeout_method = "thread"
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
norecursedirs = [
".git",
".tox",
"dist",
"build",
"*.egg",
"venv",
".venv",
".devenv",
"node_modules",
"__pycache__",
"tests_new",
]
# Set test mode to prevent pollution of real credential files
env = ["PYTEST_CURRENT_TEST=true"]
# Use modern import mode to avoid path-based module collisions
# import-mode = "importlib"
# Test markers that are currently exercised in the suite
markers = [
# Primary categories
"unit: Fast unit tests (< 1s each) that don't require external dependencies",
"integration: Integration tests (< 30s each) that test component interactions",
"e2e: End-to-end tests that drive the external API surface",
"slow: Slow tests (> 30s each) - use sparingly",
# External dependency requirements
"real_api: Tests that make real API calls to external services (requires API keys)",
"network: Tests that require general network access",
"docker: Tests that require Docker to be running",
# Feature- or plugin-specific scopes
"auth: Authentication and authorization tests",
"analytics: Analytics plugin tests",
"metrics: Metrics and monitoring plugin tests",
"claude_api: Claude API plugin tests",
"codex: Codex plugin tests",
]
[tool.bandit]
exclude_dirs = ["tests", "docs", "scripts", "examples"]
skips = [
"B101",
"B601",
"B110",
"B113",
] # Skip assert_used, shell_injection_possible, try_except_pass, request_without_timeout
[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py311,py312,py313
[testenv]
deps =
pytest
pytest-asyncio
pytest-cov
pytest-timeout
pytest-env
pytest-httpx
commands = pytest {posargs}
"""
[tool.uv]
package = true
default-groups = ["all"]
[tool.pyright]
pythonVersion = "3.11"
typeCheckingMode = "standard" # or "strict"
include = ["ccproxy", "tests"]
# Exclude unnecessary directories
exclude = [
"**/__pycache__",
".venv",
"venv",
"build",
"dist",
"*.egg-info",
".git",
".tox",
"htmlcov",
".pytest_cache",
".mypy_cache",
".ruff_cache",
".devenv",
]
# Virtual environment configuration
# venvPath = "."
# venv = ".venv" # Adjust if using different name
# Extra paths for import resolution
extraPaths = ["."]
# Type checking settings
reportMissingImports = "warning"
reportMissingTypeStubs = false
reportPrivateImportUsage = false
reportUnusedImport = true
reportUnusedClass = true
reportUnusedFunction = true
reportUnusedVariable = true
reportDuplicateImport = true
reportOptionalMemberAccess = true
reportOptionalCall = true
reportOptionalIterable = true
reportOptionalContextManager = true
reportOptionalOperand = true
reportTypedDictNotRequiredAccess = true
reportPrivateUsage = "warning"
reportUnboundVariable = true
reportUnusedCoroutine = true
reportGeneralTypeIssues = true
reportUnnecessaryTypeIgnoreComment = true
# Stub settings
stubPath = "typings"
useLibraryCodeForTypes = true