Skip to content

Commit 8405348

Browse files
committed
update tooling to use ruff & uv
1 parent ea802a0 commit 8405348

File tree

163 files changed

+2546
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+2546
-388
lines changed

.flake8

Lines changed: 0 additions & 32 deletions
This file was deleted.

eest_tests/execution-spec-tests

network-upgrades/mainnet-upgrades/dao-fork.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,17 @@ At the beginning of block 1920000, all ether throughout all accounts in `L` will
156156
// Deployed on mainnet at 0xbf4ed7b27f1d666546e30d74d50d173d20bca754
157157
158158
contract DAO {
159-
function balanceOf(address addr) returns (uint);
160-
function transferFrom(address from, address to, uint balance) returns (bool);
161-
uint public totalSupply;
159+
function balanceOf(address addr) returns (uInt);
160+
function transferFrom(address from, address to, uInt balance) returns (bool);
161+
uInt public totalSupply;
162162
}
163163
164164
contract WithdrawDAO {
165165
DAO constant public mainDAO = DAO(0xbb9bc244d798123fde783fcc1c72d3bb8c189413);
166166
address public trustee = 0xda4a4626d3e16e094de3225a751aab7128e96526;
167167
168168
function withdraw(){
169-
uint balance = mainDAO.balanceOf(msg.sender);
169+
uInt balance = mainDAO.balanceOf(msg.sender);
170170
171171
if (!mainDAO.transferFrom(msg.sender, this, balance) || !msg.sender.send(balance))
172172
throw;
@@ -199,4 +199,4 @@ Blocks with block numbers in the range [1_920_000, 1_920_009] **MUST** have `0x6
199199

200200
## Copyright
201201

202-
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
202+
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).

pyproject.toml

Lines changed: 118 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,12 @@ test = [
163163
"requests",
164164
"requests-cache>=1.2.1,<2",
165165
]
166-
167166
lint = [
168-
"isort==5.13.2",
167+
"codespell==2.4.1",
169168
"mypy==1.17.0",
170-
"black==23.12.0",
171-
"flake8==6.1.0",
172-
"flake8-bugbear==23.12.2",
173-
"flake8-docstrings==1.7.0",
174-
"flake8-spellcheck==0.28.0",
175-
"flake8-unused-arguments==0.0.13",
169+
"ruff==0.11.8",
176170
"vulture==2.14.0",
177171
]
178-
179172
tools = [
180173
"platformdirs>=4.2,<5",
181174
]
@@ -188,7 +181,6 @@ optimized = [
188181
"ethash>=1.1.0,<2",
189182
]
190183

191-
192184
[tool.setuptools.dynamic]
193185
version = { attr = "ethereum.__version__" }
194186

@@ -211,14 +203,6 @@ ethereum-spec-fill = "cli.pytest_commands.fill:fill"
211203
"ethereum_spec_tools.docc:BeforeNode" = "ethereum_spec_tools.docc:render_before_after"
212204
"ethereum_spec_tools.docc:AfterNode" = "ethereum_spec_tools.docc:render_before_after"
213205

214-
[tool.isort]
215-
profile = "black"
216-
multi_line_output = 3
217-
line_length = 79
218-
219-
[tool.black]
220-
line-length = 79
221-
222206
[tool.pytest.ini_options]
223207
markers = [
224208
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
@@ -241,7 +225,6 @@ context = [
241225
"docc.search.context",
242226
"docc.html.context",
243227
]
244-
245228
discovery = [
246229
"docc.search.discover",
247230
"docc.html.discover",
@@ -250,15 +233,13 @@ discovery = [
250233
"docc.listing.discover",
251234
"docc.files.discover",
252235
]
253-
254236
build = [
255237
"docc.search.build",
256238
"ethereum_spec_tools.docc.build",
257239
"docc.files.build",
258240
"docc.listing.build",
259241
"docc.resources.build",
260242
]
261-
262243
transform = [
263244
"docc.python.transform",
264245
"docc.verbatim.transform",
@@ -280,7 +261,6 @@ excluded_references = [
280261
paths = [
281262
"src",
282263
]
283-
284264
excluded_paths = [
285265
"src/ethereum_optimized",
286266
"src/ethereum_spec_tools",
@@ -299,3 +279,119 @@ files = [
299279
[tool.docc.output]
300280
path = "docs"
301281
extension = ".html"
282+
283+
[tool.vulture]
284+
exclude = ["tests/fixtures/", "eest_tests/"]
285+
ignore_names = ["pytest_*"]
286+
287+
[tool.ruff]
288+
exclude = [
289+
'^\.cache/',
290+
'^\.git/',
291+
'^\.pytest_cache/',
292+
'^\.ruff_cache/',
293+
'^\.tox/',
294+
'^\.venv/',
295+
'^\.vscode/',
296+
'tests/fixtures/*',
297+
'eest_tests/*',
298+
'vulture_whitelist.py',
299+
]
300+
line-length = 79
301+
302+
[tool.ruff.lint]
303+
select = [
304+
"E", # pycodestyle errors
305+
"F", # Pyflakes
306+
"B", # flake8-bugbear
307+
"W", # pycodestyle warnings
308+
"I", # isort
309+
"A", # flake8-builtins
310+
"N", # pep8-naming
311+
"ARG", # flake8-unused-arguments
312+
]
313+
fixable = [
314+
"E", # pycodestyle errors
315+
"F", # Pyflakes
316+
"B", # flake8-bugbear
317+
"W", # pycodestyle warnings
318+
"I", # isort
319+
"D", # pydocstyle
320+
]
321+
ignore = [
322+
# Common to STEEL
323+
"D205", # Missing blank line after summary
324+
"D203", # 1 blank line required before class docstring
325+
"D212", # Multi-line docstring summary should start at the first line
326+
"D415", # First line should end with a ".", "?", or "!"
327+
328+
# Specific to EELS
329+
"D107", # Missing docstring in __init__
330+
"D200", # One-line docstring should fit on one line with quotes
331+
"D205", # 1 blank line required between summary and description
332+
"D400", # First line should end with a period
333+
"D401", # First line should be in imperative mood ("Do", not "Does")
334+
"D410", # Missing blank line after last section (Args, Returns, Raises)
335+
"D411", # Missing blank line before last section
336+
"D412", # No blank lines between sections
337+
"D413", # Missing blank line after last section (same as 410)
338+
"D414", # Section should end with a period
339+
"D416", # Section names should be in the correct order
340+
"E203", # Whitespace before ':'
341+
]
342+
343+
[tool.ruff.lint.per-file-ignores]
344+
"tests/*" = [
345+
"D100", # Missing docstring in public module
346+
"D101", # Missing docstring in public class
347+
"D103", # Missing docstring in public function
348+
"D104", # Missing docstring in public package
349+
"E501", # Line too long
350+
]
351+
"src/ethereum_spec_tools/evm_tools/loaders/fork_loader.py" = [
352+
"N802" # Property names do not need to be lowercase
353+
]
354+
"src/ethereum_spec_tools/lint/*" = [
355+
"N802" # Special linting code absolved of function naming reqs
356+
]
357+
"src/ethereum/crypto/*" = [
358+
"N806", # Special crypto code absolved of variable naming reqs
359+
"N802" # Special crypto code absolved of function naming reqs
360+
]
361+
"src/ethereum_spec_tools/evm_tools/t8n/evm_trace/eip3155.py" = [
362+
"N815" # The traces must use camel case in JSON property names
363+
]
364+
"src/ethereum_spec_tools/evm_tools/t8n/evm_trace.py" = [
365+
"N815" # The traces must use camel case in JSON property names
366+
]
367+
368+
[tool.ruff.lint.mccabe]
369+
# Set the maximum allowed cyclomatic complexity. C901 default is 10.
370+
max-complexity = 7
371+
372+
[tool.codespell]
373+
builtin = "clear,code,usage" # Built-in dictionaries to use
374+
skip = [ # Don't check these files/folders
375+
".git/*",
376+
".tox/*",
377+
".venv/*",
378+
"build/*",
379+
"dist/*",
380+
"*.pyc",
381+
"ethereum_execution.egg-info/*",
382+
"*.coverage*",
383+
"__pycache__",
384+
".ruff_cache",
385+
"fixtures",
386+
"tests/fixtures/*",
387+
"eest_tests",
388+
"src/ethereum_spec_tools/evm_tools/t8n/*" # Temporary while being re-written
389+
]
390+
count = true # Display counts of errors
391+
check-hidden = false # Don't check hidden files (starting with .)
392+
393+
[tool.uv]
394+
required-version = ">=0.7.0"
395+
396+
[tool.uv.sources]
397+
"ethereum-spec-evm-resolver" = { git = "https://github.com/spencer-tb/ethereum-spec-evm-resolver", rev = "aec6a628b8d0f1c791a8378c5417a089566135ac" }

src/ethereum/arrow_glacier/bloom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ def add_to_bloom(bloom: bytearray, bloom_entry: Bytes) -> None:
4242
bloom_entry :
4343
An entry which is to be added to bloom filter.
4444
"""
45-
hash = keccak256(bloom_entry)
45+
hashed = keccak256(bloom_entry)
4646

4747
for idx in (0, 2, 4):
4848
# Obtain the least significant 11 bits from the pair of bytes
4949
# (16 bits), and set this bit in bloom bytearray.
5050
# The obtained bit is 0-indexed in the bloom filter from the least
5151
# significant bit to the most significant bit.
52-
bit_to_set = Uint.from_be_bytes(hash[idx : idx + 2]) & Uint(0x07FF)
52+
bit_to_set = Uint.from_be_bytes(hashed[idx : idx + 2]) & Uint(0x07FF)
5353
# Below is the index of the bit in the bytearray (where 0-indexed
5454
# byte is the most significant byte)
5555
bit_index = 0x07FF - int(bit_to_set)

src/ethereum/arrow_glacier/fork_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Introduction
1010
------------
1111
12-
Types re-used throughout the specification, which are specific to Ethereum.
12+
Types reused throughout the specification, which are specific to Ethereum.
1313
"""
1414

1515
from dataclasses import dataclass

src/ethereum/arrow_glacier/trie.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@
4747
#
4848
# keccak256(RLP(b''))
4949
# ==
50-
# 56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 # noqa: E501,SC10
50+
# 56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 # noqa: E501
5151
#
5252
# also:
5353
#
5454
# keccak256(RLP(()))
5555
# ==
56-
# 1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347 # noqa: E501,SC10
56+
# 1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347 # noqa: E501
5757
#
5858
# which is the sha3Uncles hash in block header with no uncles
5959
EMPTY_TRIE_ROOT = Root(

src/ethereum/arrow_glacier/vm/gas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ def calculate_memory_gas_cost(size_in_bytes: Uint) -> Uint:
139139
total_gas_cost = linear_cost + quadratic_cost
140140
try:
141141
return total_gas_cost
142-
except ValueError:
143-
raise OutOfGasError
142+
except ValueError as e:
143+
raise OutOfGasError from e
144144

145145

146146
def calculate_gas_extend_memory(

src/ethereum/arrow_glacier/vm/instructions/block.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ def block_hash(evm: Evm) -> None:
4646
# Default hash to 0, if the block of interest is not yet on the chain
4747
# (including the block which has the current executing transaction),
4848
# or if the block's age is more than 256.
49-
hash = b"\x00"
49+
b_hash = b"\x00"
5050
else:
51-
hash = evm.message.block_env.block_hashes[
51+
b_hash = evm.message.block_env.block_hashes[
5252
-(current_block_number - block_number)
5353
]
5454

55-
push(evm.stack, U256.from_be_bytes(hash))
55+
push(evm.stack, U256.from_be_bytes(b_hash))
5656

5757
# PROGRAM COUNTER
5858
evm.pc += Uint(1)

src/ethereum/arrow_glacier/vm/instructions/keccak.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ def keccak(evm: Evm) -> None:
5656
# OPERATION
5757
evm.memory += b"\x00" * extend_memory.expand_by
5858
data = memory_read_bytes(evm.memory, memory_start_index, size)
59-
hash = keccak256(data)
59+
hashed = keccak256(data)
6060

61-
push(evm.stack, U256.from_be_bytes(hash))
61+
push(evm.stack, U256.from_be_bytes(hashed))
6262

6363
# PROGRAM COUNTER
6464
evm.pc += Uint(1)

0 commit comments

Comments
 (0)