-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyproject.toml
413 lines (346 loc) · 10.6 KB
/
pyproject.toml
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
# ----------------------------------------------------------------------
# Packaging
# https://packaging.python.org/en/latest/tutorials/packaging-projects
# ----------------------------------------------------------------------
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
# ----------------------------------------------------------------------
# peotry
# https://python-poetry.org/docs/pyproject/
# ----------------------------------------------------------------------
[tool.poetry]
name = "shrinkix"
version = "0.3.0"
description = "Reduces the size of images for the web."
license = "MIT"
authors = [
"Dashstrom <dashstrom.pro@gmail.com>"
]
maintainers = [
"Dashstrom <dashstrom.pro@gmail.com>",
]
readme = "README.rst"
homepage = "https://github.com/Dashstrom/shrinkix"
repository = "https://github.com/Dashstrom/shrinkix"
documentation = "https://dashstrom.github.io/shrinkix"
keywords = [
"python",
"cli",
"image",
"optimizer",
"reduce",
"color-reduction"
]
# See https://pypi.org/classifiers/
classifiers = [
#"Development Status :: 1 - Planning",
#"Development Status :: 2 - Pre-Alpha",
"Development Status :: 3 - Alpha",
#"Development Status :: 4 - Beta",
#"Development Status :: 5 - Production/Stable",
#"Development Status :: 6 - Mature",
#"Development Status :: 7 - Inactive",
# Default usage
"Environment :: Console",
# Framework used
"Framework :: Pytest",
"Framework :: Sphinx",
"Framework :: tox",
# Indicate who your project is intended for
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
# Target OS
"Operating System :: OS Independent",
# What is the language used in this project
"Natural Language :: English",
# Version available for this project
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
# What is the language used in the project
"Natural Language :: English",
# License used in this project
"License :: OSI Approved :: MIT License",
# The project is typed
"Typing :: Typed"
]
packages = [
{ include = "shrinkix" },
]
[tool.poetry.dependencies]
python = ">=3.8"
typing-extensions = ">=4.8.0"
pillow = "*"
tqdm = "*"
piexif = "*"
scikit-learn = [
{ version = "<1.4.0", python = ">=3.8,<3.9"},
{ version = ">=1.4.0", python = ">=3.9"}
]
numpy = [
{ version = "<1.25.0", python = ">=3.8,<3.9"},
{ version = ">=1.25.0", python = ">=3.9"}
]
pytest = { version = "8.2.0", optional = true }
pytest-mock = { version = "3.14.0", optional = true }
coverage = { extras = ["toml"], version = "7.5.0", optional = true }
pytest-cov = { version = "5.0.0", optional = true }
mypy = { version = "1.10.0", optional = true }
ruff = { version = "0.4.3", optional = true }
pre-commit = { version = "3.5.0", optional = true }
sphinx = { version = "7.1.2", optional = true }
sphinx-rtd-theme = { version = "2.0.0", optional = true }
sphinxcontrib-mermaid = { version = "0.9.2", optional = true }
poethepoet = { version = "0.26.1", optional = true }
commitizen = { version = "3.25.0", optional = true }
types-tqdm = { version = "4.66.0.20240417", optional = true }
[tool.poetry.extras]
test = ["pytest", "pytest-mock"]
cov = ["pytest", "pytest-mock", "coverage", "pytest-cov"]
lint = ["pytest", "pytest-mock", "mypy", "ruff", "types-tqdm"]
format = ["pytest", "pytest-mock", "mypy", "ruff"]
docs = ["sphinx", "sphinx-rtd-theme", "sphinxcontrib-mermaid"]
tasks = ["poethepoet", "pre-commit", "commitizen"]
[tool.poetry.scripts]
shrinkix = "shrinkix.cli:entrypoint"
# ----------------------------------------------------------------------
# Poe the Poet
# https://poethepoet.natn.io/index.html
# ----------------------------------------------------------------------
[tool.poe.tasks.test]
help = "Run test suite."
cmd = "pytest"
[tool.poe.tasks.lint]
help = "Run linters: ruff checker and ruff formatter and mypy."
sequence = [
{ cmd = "ruff check ." },
{ cmd = "ruff format --diff ." },
{ cmd = "mypy ." },
]
ignore_fail = true
[tool.poe.tasks.format]
help = "Run linters in fix mode."
sequence = [
{ cmd = "ruff check --fix ." },
{ cmd = "ruff format ." },
{ cmd = "mypy ." },
]
ignore_fail = true
[tool.poe.tasks.check]
help = "Run all checks: lint, test and docs."
sequence = [
{ ref = "lint" },
{ ref = "test" },
{ ref = "docs" },
]
[tool.poe.tasks.cov]
help = "Run coverage for generate report and html."
sequence = [
{ cmd = "coverage run -m pytest" },
{ cmd = "coverage report" },
{ cmd = "coverage html" },
]
[tool.poe.tasks.open-cov]
help = "Open html coverage report in webbrowser."
deps = ["cov"]
expr = "webbrowser.open('file:'+urllib.request.pathname2url(os.path.abspath('htmlcov/index.html')),new=2)"
imports = ["os", "webbrowser", "sys", "urllib.request"]
[tool.poe.tasks.docs]
help = "Build documentation."
cmd = "sphinx-build -W -b html docs public"
[tool.poe.tasks.open-docs]
help = "Open documentation in webbrowser."
deps = ["docs"]
expr = "webbrowser.open('file:'+urllib.request.pathname2url(os.path.abspath('public/index.html')),new=2)"
imports = ["os", "webbrowser", "sys", "urllib.request"]
[tool.poe.tasks.setup]
help = "Setup pre-commit."
cmd = "pre-commit install"
[tool.poe.tasks.pre-commit]
help = "Run pre-commit."
cmd = "pre-commit run --all-files"
[tool.poe.tasks.clean]
help = "Clean cache files."
expr = """[
shutil.rmtree(path, ignore_errors=False)
if path.is_dir()
else path.unlink()
for pattern in [
'build/',
'dist/',
'public/',
'.eggs/',
'.tox/',
'.coverage',
'htmlcov/',
'.pytest_cache',
'.mypy_cache',
'.ruff_cache',
'**/*.egg-info',
'**/*.egg',
'**/__pycache__',
'**/*~',
'**/*.pyc',
'**/*.pyo'
]
for path in pathlib.Path().resolve().glob(pattern)
]"""
imports = ["shutil", "sys", "pathlib"]
# ----------------------------------------------------------------------
# Pytest
# https://docs.pytest.org
# ----------------------------------------------------------------------
[tool.pytest.ini_options]
log_cli = true
log_cli_level = "INFO"
addopts = "-vv --doctest-modules"
doctest_optionflags = "DONT_ACCEPT_TRUE_FOR_1 NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL ELLIPSIS"
#asyncio_mode = "auto"
# ----------------------------------------------------------------------
# Coverage
# https://coverage.readthedocs.io/en/7.3.2/config.html
# ----------------------------------------------------------------------
[tool.coverage.run]
source = ["shrinkix"]
# ----------------------------------------------------------------------
# Mypy
# https://pypi.org/project/mypy
# ----------------------------------------------------------------------
[tool.mypy]
python_version = 3.8
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]
enable_error_code = ["ignore-without-code", "truthy-bool", "redundant-expr"]
# Disallow dynamic typing
disallow_any_unimported = false
disallow_any_expr = false # All attribut of argparse.Namespace are Any
disallow_any_decorated = false # Too many package doesn't have typed decorator
disallow_any_generics = true
disallow_subclassing_any = true
# Disallow untyped definitions and calls
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = false # Too many decorator are untyped
# None and optional handling
no_implicit_optional = true
# Configuring warnings
warn_unused_ignores = true
warn_no_return = true
warn_return_any = true
warn_redundant_casts = true
# Misc things
strict_equality = true
# Config file
warn_unused_configs = true
# Exemple for missing types
[[tool.mypy.overrides]]
module = ["sklearn.*", "piexif.*"]
ignore_missing_imports = true
# ----------------------------------------------------------------------
# Ruff
# https://pypi.org/project/ruff
# ----------------------------------------------------------------------
[tool.ruff]
line-length = 79
target-version = "py38"
[tool.ruff.lint]
select = ["ALL"]
# D203 and D211 are incompatible
# D212 and D213 are incompatible
# D400 [*] First line should end with a period
# D101 Missing docstring in public class
# SIM117 multiple context managers is not available in 3.8
# We dont use ANN : flake8-annotations because we already have mypy
ignore = ["D203", "D213", "D400", "D101", "SIM117", "ANN", "COM812", "ISC001"]
fixable = ["ALL"]
unfixable = []
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
[tool.ruff.lint.per-file-ignores]
# INP001 File `docs\conf.py` is part of an implicit namespace package. Add an `__init__.py`.
# A001 Variable `copyright` is shadowing a python builtin
# PTH100 `os.path.abspath()` should be replaced by `Path.resolve()`
"docs/conf.py" = ["INP001", "A001", "PTH100"]
# S101 Use of `assert` detected
# S603 `subprocess` call: check for execution of untrusted input
"tests/*.py" = ["S101", "S603"]
# Q003 [*] Change outer quotes to avoid escaping inner quotes
# E501 Line too long
"*/info.py" = ["Q003", "E501"]
# E501 Line too long
"*/__main__.py" = ["E501"]
# INP001 File `benchmarks/*.py` is part of an implicit namespace package. Add an `__init__.py`.
"benchmarks/*.py" = ["INP001"]
# INP001 File `scripts/*.py` is part of an implicit namespace package. Add an `__init__.py`.
"scripts/*.py" = ["INP001"]
[tool.ruff.lint.isort]
known-first-party = ["shrinkix"]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.pyupgrade]
# Preserve types, even if a file imports `from __future__ import annotations`.
keep-runtime-typing = true
[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 12.
max-complexity = 12
# ----------------------------------------------------------------------
# Pylint
# https://pylint.pycqa.org/en/latest/index.html
# ----------------------------------------------------------------------
# We dont use pylint, so we disabled it
[tool.pylint.main]
ignore-patterns = ["*"]
# ----------------------------------------------------------------------
# Black
# https://black.readthedocs.io/en/stable/
# ----------------------------------------------------------------------
[tool.black]
exclude="*"