Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
157 lines (136 loc) · 5.69 KB
/
Copy pathpyproject.toml
File metadata and controls
157 lines (136 loc) · 5.69 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
[build-system]
requires = ["setuptools>=84.2.1", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "ethlib"
version = "0.3.0"
description = "Formally verified Ethereum primitives, written in Lean"
readme = { file = "README.md", content-type = "text/markdown" }
license = "CC0-1.0 AND MIT AND Apache-2.0 AND Unicode-3.0"
license-files = ["LICENSE", "EthLib/Cryptography/Unicode/LICENSE"]
requires-python = ">=3.10"
authors = [{ name = "ethereum" }]
urls = { homepage = "https://github.com/ethereum/ethlib" }
[project.optional-dependencies]
test = [
"pytest==9.2.0",
"pytest-xdist==3.8.0",
"ruamel.yaml==0.19.1",
"py_ecc==8.0.0",
# The suites read TOML, and tomllib is in the standard library from Python 3.11.
"tomli==2.5.0; python_version < '3.11'",
"hypothesis==6.168.5",
]
[dependency-groups]
lint = [
"codespell==2.4.3",
"ruff==0.17.6",
"ty==0.0.113",
]
[tool.uv]
# Rebuild the native extension only when its source or build inputs change.
cache-keys = [
{ file = "pyproject.toml" },
{ file = "setup.py" },
{ file = "README.md" },
{ file = "MANIFEST.in" },
{ file = "lean-toolchain" },
{ file = "lakefile.lean" },
{ file = "lake-manifest.json" },
{ file = "EthLib.lean" },
{ file = "EthLib/**/*.lean" },
{ file = "bindings/python/**/*.c" },
{ file = "bindings/python/**/*.h" },
{ file = "bindings/python/**/*.py" },
]
[tool.pytest.ini_options]
testpaths = ["bindings/python/tests"]
# The tests of the scripts import the scripts by bare name, as the type checker resolves them.
pythonpath = ["bindings/python/tests", "scripts"]
# importlib import mode keeps the per-suite fixtures.py files from
# clashing in sys.modules during collection.
addopts = "--import-mode=importlib"
markers = [
"archive(name, *paths): reads the paths of a release archive of tests/sources.toml; skipped unless ETHLIB_ARCHIVES names a cache directory",
"archive_cases(argnames, cases): parametrizes the test with the cases that cases() builds from a release archive, when pytest collects it",
]
[tool.ruff]
line-length = 100
# The modules of these directories are first-party, as for the type checker.
src = ["bindings/python", "bindings/python/tests", "scripts"]
# The scripts run on Python 3.12. The package supports Python 3.10, and the test of each wheel
# runs the suites, the vector check and the archive fetcher on the Python of the wheel.
target-version = "py312"
# `lake exe gen-bindings` writes the stub, and its check compares it byte for byte.
# It also writes every `_types.py` module, formatted as ruff formats it, so ruff checks those.
# The relay-spec documents are vendored byte for byte and pinned by their digests.
extend-exclude = [
"bindings/python/ethlib/cryptography/_native.pyi",
"tests/consensus/large_amounts/generator/",
"tests/consensus/relay_api/specs/",
]
[tool.ruff.per-file-target-version]
"bindings/python/ethlib/**" = "py310"
"setup.py" = "py310"
"bindings/python/tests/**" = "py310"
"tests/**" = "py310"
"scripts/fetch_archives.py" = "py310"
[tool.ruff.format]
docstring-code-format = true
[tool.ruff.lint]
# D213 is selected by exact code: the google convention would otherwise disable it.
select = ["E", "F", "B", "W", "I", "A", "N", "D", "D213", "C", "TID", "UP"]
ignore = ["D205", "D203", "D212", "D415", "C901", "A005", "C420"]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"
[tool.ruff.lint.isort]
combine-as-imports = true
known-first-party = ["ethlib"]
# The SSZ limit generator imports ssz-specs, whose name a suite shares.
known-third-party = ["ssz"]
[tool.ruff.lint.per-file-ignores]
# Each suite imports its own `fixtures` module, which shares its name with the other suites',
# so a suite reaches it by a relative import.
"bindings/python/tests/**" = ["D", "TID252"]
"scripts/test_*.py" = ["D"]
# The regressions of the Lake pipeline are tests too; their name keeps them out of unit discovery.
"scripts/build_pipeline_regressions.py" = ["D"]
"tests/**" = ["D"]
# The evaluator dispatches on the name of each `ast` node class.
"bindings/python/tests/precompile/execution_specs/extract_alt_bn128_cases.py" = ["N802"]
[tool.codespell]
# Names in the code: a re-encoding, plural data, a serializer, a truncated status, a regex,
# "Caf" before the escaped byte of "Café", and a two-letter client code of the Engine API.
ignore-words-list = "bu,caf,datas,ommit,reencode,ser,statu"
[tool.ty.environment]
python-version = "3.12"
# The package, and the directories whose modules the suites and the scripts import by bare name.
root = ["bindings/python", "bindings/python/tests", "scripts", "tests/cryptography"]
[tool.ty.src]
# The SSZ limit and proof generators import ssz-specs as `ssz`, which resolves here to the tests.
# Only their own environments install ssz-specs.
# The generator of the large-amount vectors runs inside the consensus specification.
# The extractor of the OpenRPC examples runs in its own environment, with PyYAML.
exclude = [
".claude/",
"tests/serialization/ssz_limits/generate.py",
"tests/serialization/ssz_proofs/generate.py",
"tests/consensus/large_amounts/generator",
"tests/engine/extract_openrpc.py",
]
[tool.ty.analysis]
# setup.py runs in the build environment, which installs setuptools.
allowed-unresolved-imports = ["setuptools", "setuptools.**"]
[tool.ty.rules]
# Flag any suppression comment that no longer matches a real diagnostic.
unused-ignore-comment = "error"
# Every rule of ty is an error in the package, its tests, the scripts under tests/ and setup.py.
# The scripts of scripts/ keep the default rules until they are typed as strictly.
[[tool.ty.overrides]]
include = ["bindings/**", "tests/**", "setup.py"]
[tool.ty.overrides.rules]
all = "error"
[tool.ty.terminal]
error-on-warning = true