Skip to content

Commit 88598e6

Browse files
committed
update tooling to use ruff & uv
1 parent 87a9e65 commit 88598e6

File tree

160 files changed

+2067
-344
lines changed

Some content is hidden

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

160 files changed

+2067
-344
lines changed

.flake8

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

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

src/ethereum/arrow_glacier/vm/interpreter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def execute_code(message: Message) -> Evm:
290290
try:
291291
op = Ops(evm.code[evm.pc])
292292
except ValueError:
293-
raise InvalidOpcode(evm.code[evm.pc])
293+
raise InvalidOpcode(evm.code[evm.pc]) from ValueError
294294

295295
evm_trace(evm, OpStart(op))
296296
op_implementation[op](evm)

0 commit comments

Comments
 (0)