Skip to content

Commit 2b26dcc

Browse files
committed
Switch tooling to use ruff & uv
trade out isort, black, and flake-8 for ruff include tests dir in linting, update some noqas for ruff ruff fixes refactor vulture config clean up pyproject.toml Add and config ruff linting ignores cleanup tox switch to using codespell don't check B905 linting remove old noqa flags Fix A001 & A002 shadowing linting issues fix B904 linting issues remove old spelling noqas allow some special case naming linting exceptions pythonize naming for bls12 functions add more special case exceptions for N806 more N806 exceptions fix naming issues raised by linting fix naming for an exception adding some final linting exceptions switch to using uv for package management post rebase fixes fix t8n
1 parent 15f62f6 commit 2b26dcc

File tree

161 files changed

+1687
-359
lines changed

Some content is hidden

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

161 files changed

+1687
-359
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: 116 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,12 @@ test = [
162162
"requests",
163163
"requests-cache>=1.2.1,<2",
164164
]
165-
166165
lint = [
167-
"isort==5.13.2",
166+
"codespell==2.4.1",
168167
"mypy==1.17.0",
169-
"black==23.12.0",
170-
"flake8==6.1.0",
171-
"flake8-bugbear==23.12.2",
172-
"flake8-docstrings==1.7.0",
173-
"flake8-spellcheck==0.28.0",
174-
"flake8-unused-arguments==0.0.13",
168+
"ruff==0.11.8",
175169
"vulture==2.14.0",
176170
]
177-
178171
tools = [
179172
"platformdirs>=4.2,<5",
180173
]
@@ -187,7 +180,6 @@ optimized = [
187180
"ethash>=1.1.0,<2",
188181
]
189182

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

@@ -210,14 +202,6 @@ ethereum-spec-fill = "cli.pytest_commands.fill:fill"
210202
"ethereum_spec_tools.docc:BeforeNode" = "ethereum_spec_tools.docc:render_before_after"
211203
"ethereum_spec_tools.docc:AfterNode" = "ethereum_spec_tools.docc:render_before_after"
212204

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

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+
b_hash = 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(b_hash[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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def calculate_memory_gas_cost(size_in_bytes: Uint) -> Uint:
140140
try:
141141
return total_gas_cost
142142
except ValueError:
143-
raise OutOfGasError
143+
raise OutOfGasError from ValueError
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+
k_hash = keccak256(data)
6060

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

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

0 commit comments

Comments
 (0)