-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpyproject.toml
349 lines (317 loc) Β· 9.39 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
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "algorand-python-testing"
version = "0.5.0"
description = 'Algorand Python testing library'
readme = "README.md"
requires-python = ">=3.12"
license = "AGPL-3.0-or-later"
authors = [
{ name = "Algorand Foundation", email = "contact@algorand.foundation" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Topic :: Software Development :: Testing",
"Programming Language :: Python",
"Programming Language :: Python :: 3.12",
]
dependencies = [
# ==========================================================================
# Below is used for implementing algopy crypto ops matching AVM.
# Versions pinned for compatibility with py-algorand-sdk pre reqs
# https://github.com/algorand/py-algorand-sdk/blob/master/setup.py
# ==========================================================================
"pycryptodomex>=3.6.0,<4",
"pynacl>=1.4.0,<2",
"ecdsa>=0.17.0",
"coincurve>=19.0.1",
"algorand-python>=2.0"
]
[project.urls]
Documentation = "https://github.com/algorandfoundation/puya/tree/main/algopy_testing#README.md"
Issues = "https://github.com/algorandfoundation/puya/issues"
Source = "https://github.com/algorandfoundation/puya/tree/main/algopy_testing"
[tool.hatch.metadata]
allow-direct-references = true
[tool.hatch.build.targets.wheel]
packages = ["src/algopy", 'src/algopy_testing', 'src/_algopy_testing']
[[tool.hatch.envs.all.matrix]]
python = ["3.12"]
# default dev environment
[tool.hatch.envs.default]
type = "virtual"
path = ".venv"
python = "3.12"
dependencies = [
"puyapy>=3.0",
"pytest>=7.4",
"pytest-mock>=3.10.0",
"pytest-xdist[psutil]>=3.3",
"py-algorand-sdk>=2.4.0",
"algokit-utils>=3.0.0",
"pytest-cov>=4.1.0",
"prettytable>=3.9.0",
"mypy==1.10",
]
[tool.hatch.envs.default.env-vars]
COVERAGE_CORE = "sysmon"
[tool.hatch.envs.default.scripts]
refresh_test_artifacts = "python scripts/refresh_test_artifacts.py"
validate_examples = "python scripts/validate_examples.py"
check_stubs_cov = "python scripts/check_stubs_cov.py"
pre_commit = [
"hatch run lint:fix",
"hatch run lint:check",
"mypy_testing",
"hatch run examples:pre_commit",
]
check = [
"hatch run lint:check",
"mypy_testing",
"hatch run examples:check",
]
# type checks algorand-python-testing code
mypy_testing = "mypy . --exclude examples"
tests = "pytest --cov=src --cov-report xml"
tests_cov = [
"pytest --cov=src --cov-report=html",
"python -m webbrowser -t 'file://{root:uri}/htmlcov/index.html'"
]
# isolated environments for dev tooling
[tool.hatch.envs.lint]
detached = true
path = ".venv.lint"
dependencies = [
"black",
"ruff==0.5.6",
"ruff-lsp",
"docformatter>=1.7",
"pydoclint>=0.5.6",
]
[tool.hatch.envs.lint.scripts]
check = [
"black --check .",
"ruff check",
"pydoclint --config=pyproject.toml src",
]
fix = [
"- docformatter -i -r --black --style sphinx src",
"black .",
"ruff check --fix",
]
check_examples = [ 'black --check examples', 'ruff check examples']
fix_examples = [ 'black examples', 'ruff check --fix examples']
# cicd environment
[tool.hatch.envs.cicd]
path = ".venv.cicd"
dependencies = [
"python-semantic-release>=9.8.5",
]
[tool.hatch.envs.cicd.scripts]
clean_dist = "rm -rf dist"
# docs environment
[tool.hatch.envs.docs]
path = ".venv.docs"
type = "virtual"
python = "3.12"
dependencies = [
"sphinx>=7.2.6",
"furo>=2024.1.29",
"myst-parser>=2.0.0",
"sphinx-autodoc2>=0.5.0",
"sphinx-copybutton>=0.5.2",
"sphinx-autobuild>=2024.4.16",
"sphinx-mermaid",
"ipykernel",
"pytest",
"py-algorand-sdk",
]
# environment has algopy_testing included as an editable dependency
# however it also includes the package dependencies
# the stubs can't be in the same as the project when it is editable
# so explicitly remove them
post-install-commands = [
"hatch run docs:pip uninstall -y algorand-python",
]
[tool.hatch.envs.docs.scripts]
test = "sphinx-build -b doctest docs docs/_build -W --keep-going -n -E"
clear = "rm -rf docs/_build"
build = "hatch run docs:clear && sphinx-build docs docs/_build -W --keep-going -n -E"
dev = "hatch run docs:test && sphinx-autobuild docs docs/_build"
# Examples environment
[tool.hatch.envs.examples]
type = "virtual"
path = ".venv.examples"
python = "3.12"
dev-mode = true
skip-install = false
post-install-commands = [
"hatch run examples:reload_algopy_testing",
]
dependencies = [
"algorand-python>=1.2",
"pytest>=7.4",
"pytest-mock>=3.10.0",
"pytest-xdist[psutil]>=3.3",
"py-algorand-sdk>=2.4.0",
"algokit-utils>=3.0.0",
"pytest-cov>=4.1.0",
"mypy==1.10",
]
[tool.hatch.envs.examples.scripts]
tests = "pytest examples"
reload_algopy_testing = "pip install --no-cache-dir -U -e {root:uri}"
pre_commit = [
"hatch run lint:fix_examples",
"hatch run mypy examples",
]
check = [
"hatch run lint:check_examples",
"hatch run mypy examples",
]
# tool configurations
[tool.black]
line-length = 99
[tool.ruff]
target-version = "py312"
line-length = 99
[tool.ruff.lint]
select = [
"F", # pyflakes
"E",
"W", # pycodestyle
"C90", # mccabe
"I", # isort
"N", # PEP8 naming
"UP", # pyupgrade
"YTT", # flake8-2020
"ANN", # flake8-annotations
"ASYNC", # flake8-async
"S", # flake8-bandit
"FBT", # flake8-boolean-trap
"B", # flake8-bugbear
"A", # flake8-builtins
"C4", # flake8-comprehensions
"DTZ", # flake8-datetimez
"T10", # flake8-debugger
"EXE", # flake8-executable
"FA", # flake8-future-annotations
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"INP", # flake8-no-pep420
"PIE", # flake8-pie
"T20", # flake8-print
"PYI", # flake8-pyi
"PT", # flake8-pytest-style
"Q", # flake8-quotes
"RSE", # flake8-raise
"RET", # flake8-return
"SLF", # flake8-self
"SLOT", # flake8-slots
"SIM", # flake8-simplify
"TID", # flake8-tidy-imports
"TCH", # flake8-type-checking
"INT", # flake8-gettext
"ARG", # flake8-unused-arguments
"PTH", # flake8-use-pathlib
"PGH", # pygrep-hooks
"PL", # pylint
"TRY", # tryceratops
"PERF", # Perflint
"LOG", # flake8-logging
"RUF", # Ruff-specific rules
]
ignore = [
"ANN401", # allow typing.Any, used heavily in to align with stubs
"ANN101", # no type for self
"ANN102", # no type for cls
"SIM108", # allow if-else in place of ternary
"SLF001", # allow private member access, used to access context manager internally
"PLR2004", # magic values... can't configure to ignore simple low value ints like 2
"PLW2901", # allow updating loop value...
"PYI025", # I can tell the difference between set and Set thank you very much
"UP040", # TypeAlias -> type keyword, waiting for mypy support
"TRY003", # allow long exception messages in Exception constructor
"RET503", # false negatives when involving typing.Never, covered by mypy anyway
"RET504",
"RET505", # stylistic choices for readability
"S101", # allow asserts
"C901", # allow >10 args in a method
"N805", # allow using `cls` as a firstparameter name
]
unfixable = [
"F841", # don't delete unused local variables automatically
]
[tool.ruff.lint.per-file-ignores]
"src/algopy/**" = [
"PLC0414", # allow explicit alias
"F401", # allow unused imports in module with stubs
"F403" # allow * imports in module with stubs
]
"src/**" = [
"PT", # no pytest rules
]
"tests/**" = [
"FBT003", # allow boolean positional arguments
"S311", # allow using `random`
]
"src/algopy_testing/*" = ["S311"] # allow using `random` in value generators
"src/algopy_testing/models/logicsig.py" = ["ARG002"]
"scripts/**/*.py" = ["T201"]
"scripts/refresh_test_artifacts.py" = ["S603"]
"scripts/validate_examples.py" = ["S603"]
[tool.ruff.lint.flake8-annotations]
allow-star-arg-any = true
suppress-none-returning = true
mypy-init-return = true
[tool.ruff.lint.isort]
combine-as-imports = true
force-wrap-aliases = true
[tool.ruff.lint.flake8-builtins]
builtins-ignorelist = ["id"]
[tool.mypy]
python_version = "3.12"
strict = true
untyped_calls_exclude = [
"algosdk",
]
files = ["src", "tests", "examples"]
exclude = ["tests/artifacts"]
[[tool.mypy.overrides]]
module = [
"tests.artifacts.*",
]
follow_imports = "skip"
[tool.pytest.ini_options]
addopts = "-n auto --cov-config=.coveragerc"
pythonpath = ['src']
# === Semantic releases config ===
[tool.semantic_release]
version_toml = ["pyproject.toml:project.version"]
build_command = "pip install hatch && hatch build"
commit_message = "{version}\n\n[skip ci]"
tag_format = "v{version}"
major_on_zero = true
[tool.semantic_release.branches.main]
match = "main"
prerelease_token = "beta"
prerelease = false
[tool.semantic_release.commit_parser_options]
allowed_tags = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "style", "refactor", "test"]
minor_tags = ["feat"]
patch_tags = ["fix", "perf", "docs", "chore", "ci", "refactor"]
[tool.semantic_release.publish]
dist_glob_patterns = ["dist/*.whl"]
upload_to_vcs_release = true
[tool.semantic_release.remote.token]
env = "GITHUB_TOKEN"
[tool.pydoclint]
style = 'sphinx'
check-return-types = false
skip-checking-raises = true
arg-type-hints-in-docstring = false
[tool.docformatter]
style = "sphinx"