-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyproject.toml
More file actions
201 lines (177 loc) · 6.46 KB
/
pyproject.toml
File metadata and controls
201 lines (177 loc) · 6.46 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
[project]
name = "image-tools"
version = "1.0.0"
description = "A comprehensive, production-grade image processing toolkit with AI-powered background removal, watermark removal, and intelligent image splitting"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"inquirerpy>=0.3.4",
"kornia>=0.8.2",
"numpy>=1.24.0",
"opencv-contrib-python>=4.10.0",
"pillow>=12.0.0",
"pydantic>=2.12.5",
"pydantic-settings>=2.12.0",
"rich>=13.0.0",
"scikit-learn>=1.3.0",
"timm>=1.0.24",
"torch>=2.0.0",
"torchvision>=0.15.0",
"transformers>=4.45.0",
]
# ---------------- Ruff ----------------
[tool.ruff]
line-length = 88
target-version = "py313"
src = ["src"]
exclude = ["tests", ".rewrite"]
[tool.ruff.lint.isort]
combine-as-imports = true
force-single-line = false
lines-after-imports = 2
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"
docstring-code-format = true
[tool.ruff.lint]
# Enable comprehensive linting rules for high code quality
select = [
"E", # pycodestyle errors - PEP 8 outright violations (indentation, whitespace, etc.)
"W", # pycodestyle warnings - stylistic issues like excessive line length
"F", # Pyflakes - logical errors (unused imports, undefined names, etc.)
"UP", # pyupgrade - suggest modern Python syntax (f-strings, pathlib, etc.)
"B", # flake8-bugbear - common bugs and design problems
"SIM", # flake8-simplify - propose simpler, more readable constructs
"I", # isort - import grouping and ordering
"N", # pep8-naming - enforce naming conventions
"C90", # mccabe - cyclomatic complexity checks
"ARG", # flake8-unused-arguments - detect unused or redundant arguments
"S", # flake8-bandit - security-oriented code issues
"T20", # flake8-print - forbid stray print/debug statements
"RET", # flake8-return - ensure explicit and consistent return patterns
"ICN", # flake8-import-conventions - enforce import aliasing rules (e.g., `import numpy as np`)
"PIE", # flake8-pie - miscellaneous correctness & readability improvements
"PL", # Pylint subset - broader code-quality checks (convention, error, refactor, warning)
"TRY", # tryceratops - encourage explicit, focused exception handling
"FLY", # flynt - suggest converting old string formatting to f-strings
"PERF", # perflint - flag patterns with measurable performance overhead
"ANN", # flake8-annotations - enforce type annotations for function signatures
]
ignore = [
"UP047", # Generic function `create_function_with_params` should use type parameters
"E501", # line-too-long
"COM819", # prohibited-trailing-comma
"TRY003", # raise-vanilla-args (avoid specifying long messages outside the exception class)
"PERF203", # try-except-in-loop (try-except within a loop incurs performance overhead)
"ANN204", # missing-return-type-special-method
"ANN401", # any-type (dynamically typed expressions (typing.Any) are disallowed)
]
# Configure pydocstyle to use Google docstring convention
[tool.ruff.lint.pydocstyle]
convention = "google" # Use Google-style docstrings (Args:, Returns:, Raises:)
[tool.ruff.lint.mccabe]
max-complexity = 10
[tool.ruff.lint.per-file-ignores]
"main.py" = ["T201"] # Allow print in main entry point
"src/ui/**" = ["T201"] # Allow print in UI modules
"src/app.py" = ["T201"] # Allow print in application service (user-facing output)
"src/common/preset_config.py" = ["T201"] # Allow print in preset comparison display
"test_presets.py" = ["T201", "PLC0415"] # Allow print and local imports in test script
"test_cuda.py" = ["T201"] # Allow print in CUDA test script
"example_preset_usage.py" = ["T201", "PLR0915"] # Allow print and many statements in example script
"test_with_synthetic_images.py" = ["T201", "S101", "TRY300", "PLR2004"] # Allow print, assert, and style suggestions in test script
"src/features/background_removal/portrait_matting.py" = ["PLC0415", "TRY300"] # Allow dynamic imports for optional dependencies
"src/features/background_removal/ultra.py" = ["PLC0415"] # Allow local imports in classmethod
"src/backends/__init__.py" = ["PLC0415"] # Allow lazy imports to avoid circular dependencies
"scripts/*.py" = ["T201", "PLR2004", "N806", "PLR0915"] # Allow print, magic values, class-like variable names, and many statements in scripts
"tests/*.py" = ["S101", "PLR2004", "PLC0415", "SIM117", "TRY300"] # Allow assert, magic values, local imports, nested with, and try-return in tests
# ---------------- mypy ----------------
[tool.mypy]
python_version = "3.13"
strict = true
plugins = ["pydantic.mypy"]
disallow_untyped_defs = true
disallow_incomplete_defs = true
disallow_untyped_calls = true
disallow_any_generics = true
no_implicit_optional = true
warn_unused_ignores = true
warn_redundant_casts = true
files = ["src"]
exclude = ["tests"]
# ---------------- pytest ----------------
[tool.pytest.ini_options]
minversion = "8.0"
addopts = [
"-ra",
"--strict-markers",
"--strict-config",
"--cov=src",
"--cov-report=term-missing",
"--cov-report=html",
"--cov-report=xml",
"--disable-warnings",
"-v",
]
testpaths = ["tests"]
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"integration: marks tests as integration tests",
"unit: marks tests as unit tests",
"e2e: marks tests as end-to-end tests",
"comparison: marks tests that compare different backends",
]
filterwarnings = [
"ignore::DeprecationWarning",
"ignore::RuntimeWarning",
"ignore::UserWarning",
]
# ---------------- coverage ----------------
[tool.coverage.run]
source = ["src"]
branch = true
parallel = false
omit = [
"tests/*",
"*/venv/*",
"*/__pycache__/*",
"*/site-packages/*",
"*/test_*",
]
[tool.coverage.paths]
source = [
"src/",
"*/site-packages/",
]
[tool.coverage.report]
show_missing = true
skip_covered = false
fail_under = 0
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]
[tool.coverage.html]
directory = "htmlcov"
[dependency-groups]
dev = [
"mypy>=1.19.1",
"pytest>=8.0.0",
"pytest-cov>=4.1.0",
"ruff>=0.15.0",
]