Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 6c95853

Browse files
committed
run black
1 parent fad4851 commit 6c95853

File tree

314 files changed

+9101
-7036
lines changed

Some content is hidden

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

314 files changed

+9101
-7036
lines changed

.git-blame-ignore-revs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# ignore SHA that added isort
2-
2f421ce6049dc74a1520280adf8c350c1c567e9f
2+
e9049224a98439cc27522e322cc09e402503565a

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ lint:
2727

2828
lint-roll:
2929
isort eth tests
30+
black eth tests scripts setup.py
3031
$(MAKE) lint
3132

3233
test:

docs/conf.py

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,85 +15,85 @@
1515
import os
1616

1717
about_fields = [
18-
'author',
19-
'description',
20-
'name',
21-
'url',
22-
'version',
18+
"author",
19+
"description",
20+
"name",
21+
"url",
22+
"version",
2323
]
2424

2525
about = {}
2626

27-
DIR = os.path.dirname('__file__')
28-
with open(os.path.join(DIR, '../setup.py'), 'r') as f:
27+
DIR = os.path.dirname("__file__")
28+
with open(os.path.join(DIR, "../setup.py"), "r") as f:
2929
for line in f:
3030
for field in about_fields:
31-
if ' ' + field + '=' in line:
32-
about['__%s__' % field] = line.split('\'')[1]
31+
if " " + field + "=" in line:
32+
about["__%s__" % field] = line.split('"')[1]
3333

3434

3535
# -- General configuration ------------------------------------------------
3636

3737
# Defined in requirements-docs.txt, force another check here.
3838
# Note: Only refuses to build if sphinx too **old**.
39-
needs_sphinx = '1.5'
39+
needs_sphinx = "1.5"
4040

4141
extensions = [
42-
'sphinx.ext.todo',
43-
'sphinx.ext.autodoc',
44-
'sphinx.ext.doctest',
45-
'sphinx.ext.intersphinx',
46-
'sphinxcontrib.asyncio',
42+
"sphinx.ext.todo",
43+
"sphinx.ext.autodoc",
44+
"sphinx.ext.doctest",
45+
"sphinx.ext.intersphinx",
46+
"sphinxcontrib.asyncio",
4747
]
4848

4949
autodoc_default_options = {
50-
'undoc-members': None,
50+
"undoc-members": None,
5151
}
5252

53-
autodoc_member_order = 'groupwise'
53+
autodoc_member_order = "groupwise"
5454
autodoc_mock_imports = ["snappy"]
5555

5656
# Add any paths that contain templates here, relative to this directory.
57-
templates_path = ['_templates']
57+
templates_path = ["_templates"]
5858

5959
# The suffix(es) of source filenames.
6060
# You can specify multiple suffix as a list of string:
6161
#
6262
# source_suffix = ['.rst', '.md']
63-
source_suffix = '.rst'
63+
source_suffix = ".rst"
6464

6565
# The master toctree document.
66-
master_doc = 'index'
66+
master_doc = "index"
6767

6868
# General information about the project.
69-
project = about['__name__']
70-
copyright = '2017-2018 Ethereum Foundation'
71-
author = about['__author__']
69+
project = about["__name__"]
70+
copyright = "2017-2018 Ethereum Foundation"
71+
author = about["__author__"]
7272

7373
# The version info for the project you're documenting, acts as replacement for
7474
# |version| and |release|, also used in various other places throughout the
7575
# built documents.
7676

7777
# The short X.Y version.
78-
version = about['__version__']
78+
version = about["__version__"]
7979
# The full version, including alpha/beta/rc tags.
80-
release = about['__version__']
80+
release = about["__version__"]
8181

8282
# The language for content autogenerated by Sphinx.
83-
language = 'en'
83+
language = "en"
8484

8585
# List of patterns, relative to source directory, that match files and
8686
# directories to ignore when looking for source files.
8787
# This patterns also effect to html_static_path and html_extra_path
8888
exclude_patterns = [
89-
'_build',
90-
'Thumbs.db',
91-
'.DS_Store',
92-
'modules.rst',
89+
"_build",
90+
"Thumbs.db",
91+
".DS_Store",
92+
"modules.rst",
9393
]
9494

9595
# The name of the Pygments (syntax highlighting) style to use.
96-
pygments_style = 'sphinx'
96+
pygments_style = "sphinx"
9797

9898
# If true, `todo` and `todoList` produce output, else they produce nothing.
9999
todo_include_todos = True
@@ -103,7 +103,7 @@
103103
# The theme to use for HTML and HTML Help pages. See the documentation for
104104
# a list of builtin themes.
105105
#
106-
html_theme = 'sphinx_rtd_theme'
106+
html_theme = "sphinx_rtd_theme"
107107

108108
# Using Alabaster by default, reference for options is:
109109
# http://alabaster.readthedocs.io/en/latest/customization.html
@@ -116,22 +116,24 @@
116116
# Add any paths that contain custom static files (such as style sheets) here,
117117
# relative to this directory. They are copied after the builtin static files,
118118
# so a file named "default.css" will overwrite the builtin "default.css".
119-
html_static_path = ['_static']
119+
html_static_path = ["_static"]
120+
120121

121122
def setup(app):
122123
app.add_stylesheet("css/custom.css")
123124
app.add_javascript("js/matomo.js")
124125

126+
125127
# Allows the mod index to function more helpfully (not everything under 'e')
126-
modindex_common_prefix = ['eth.']
128+
modindex_common_prefix = ["eth."]
127129

128130
##
129131
# Below be monsters, for now. You've been warned.
130132
##
131133
# -- Options for HTMLHelp output ------------------------------------------
132134

133135
# Output file base name for HTML help builder.
134-
htmlhelp_basename = 'py-evmdoc'
136+
htmlhelp_basename = "py-evmdoc"
135137

136138

137139
# -- Options for LaTeX output ---------------------------------------------
@@ -140,15 +142,12 @@ def setup(app):
140142
# The paper size ('letterpaper' or 'a4paper').
141143
#
142144
# 'papersize': 'letterpaper',
143-
144145
# The font size ('10pt', '11pt' or '12pt').
145146
#
146147
# 'pointsize': '10pt',
147-
148148
# Additional stuff for the LaTeX preamble.
149149
#
150150
# 'preamble': '',
151-
152151
# Latex figure (float) alignment
153152
#
154153
# 'figure_align': 'htbp',
@@ -158,8 +157,7 @@ def setup(app):
158157
# (source start file, target name, title,
159158
# author, documentclass [howto, manual, or own class]).
160159
latex_documents = [
161-
(master_doc, 'py-evm.tex', 'py-evm Documentation',
162-
about['__author__'], 'manual'),
160+
(master_doc, "py-evm.tex", "py-evm Documentation", about["__author__"], "manual"),
163161
]
164162

165163

@@ -168,8 +166,7 @@ def setup(app):
168166
# One entry per manual page. List of tuples
169167
# (source start file, name, description, authors, manual section).
170168
man_pages = [
171-
(master_doc, about['__name__'], 'py-evm Documentation',
172-
about['__author__'], 1)
169+
(master_doc, about["__name__"], "py-evm Documentation", about["__author__"], 1)
173170
]
174171

175172

@@ -179,23 +176,30 @@ def setup(app):
179176
# (source start file, target name, title, author,
180177
# dir menu entry, description, category)
181178
texinfo_documents = [
182-
(master_doc, about['__name__'], 'py-evm Documentation',
183-
about['__author__'], about['__name__'], about['__description__'],
184-
'Miscellaneous'),
179+
(
180+
master_doc,
181+
about["__name__"],
182+
"py-evm Documentation",
183+
about["__author__"],
184+
about["__name__"],
185+
about["__description__"],
186+
"Miscellaneous",
187+
),
185188
]
186189

187190
# -- Intersphinx configuration ------------------------------------------------
188191

189192
intersphinx_mapping = {
190-
'python': ('https://docs.python.org/3.9', None),
191-
'eth-typing': ('https://eth-typing.readthedocs.io/en/latest', None),
193+
"python": ("https://docs.python.org/3.9", None),
194+
"eth-typing": ("https://eth-typing.readthedocs.io/en/latest", None),
192195
}
193196

194197
# -- Doctest configuration ----------------------------------------
195198

196199
import doctest
197200

198-
doctest_default_flags = (0
201+
doctest_default_flags = (
202+
0
199203
| doctest.DONT_ACCEPT_TRUE_FOR_1
200204
| doctest.ELLIPSIS
201205
| doctest.IGNORE_EXCEPTION_DETAIL

eth/_utils/address.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313

1414
def force_bytes_to_address(value: bytes) -> Address:
1515
trimmed_value = value[-20:]
16-
padded_value = trimmed_value.rjust(20, b'\x00')
16+
padded_value = trimmed_value.rjust(20, b"\x00")
1717
return Address(padded_value)
1818

1919

2020
def generate_contract_address(address: Address, nonce: int) -> Address:
2121
return force_bytes_to_address(keccak(rlp.encode([address, nonce])))
2222

2323

24-
def generate_safe_contract_address(address: Address,
25-
salt: int,
26-
call_data: bytes) -> Address:
24+
def generate_safe_contract_address(
25+
address: Address, salt: int, call_data: bytes
26+
) -> Address:
2727
return force_bytes_to_address(
28-
keccak(b'\xff' + address + int_to_bytes32(salt) + keccak(call_data))
28+
keccak(b"\xff" + address + int_to_bytes32(salt) + keccak(call_data))
2929
)

eth/_utils/blake2/coders.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@
1414
TMessageBlock,
1515
)
1616

17-
TMessage = Tuple[int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int]
17+
TMessage = Tuple[
18+
int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int
19+
]
1820
TFCompressArgs = Tuple[int, TMessageBlock, TMessage, Tuple[int, int], bool]
1921

2022

2123
def extract_blake2b_parameters(input_bytes: bytes) -> TFCompressArgs:
2224
num_bytes = len(input_bytes)
2325
if num_bytes != 213:
2426
raise ValidationError(
25-
f"input length for Blake2 F precompile should be exactly 213 bytes, got: {num_bytes}"
27+
"input length for Blake2 F precompile should be exactly 213 bytes, got: "
28+
f"{num_bytes}"
2629
)
2730

2831
rounds = to_int(input_bytes[:4])
@@ -31,7 +34,9 @@ def extract_blake2b_parameters(input_bytes: bytes) -> TFCompressArgs:
3134

3235
message = cast(TMessage, _get_64_bit_little_endian_words(input_bytes[68:196]))
3336

34-
t_offset_counters = cast(Tuple[int, int], _get_64_bit_little_endian_words(input_bytes[196:212]))
37+
t_offset_counters = cast(
38+
Tuple[int, int], _get_64_bit_little_endian_words(input_bytes[196:212])
39+
)
3540

3641
final_block_int = to_int(input_bytes[212])
3742
if final_block_int == 0:
@@ -40,7 +45,8 @@ def extract_blake2b_parameters(input_bytes: bytes) -> TFCompressArgs:
4045
final_block_flag = True
4146
else:
4247
raise ValidationError(
43-
f"incorrect final block indicator flag, needed 0 or 1, got: {final_block_int}"
48+
"incorrect final block indicator flag, needed 0 or 1, got: "
49+
f"{final_block_int}"
4450
)
4551

4652
return rounds, h_state, message, t_offset_counters, final_block_flag

eth/_utils/blake2/compression.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030

3131
class Blake2:
32-
""" Blake2 is a base class for Blake2b and Blake2s """
32+
"""Blake2 is a base class for Blake2b and Blake2s"""
3333

3434
# for more than 10 rounds, the schedule wraps around to the beginning
3535
sigma_schedule = (
@@ -47,16 +47,19 @@ class Blake2:
4747

4848

4949
class Blake2b(Blake2):
50-
5150
WORDBITS = 64
52-
MASKBITS = 2 ** WORDBITS - 1
53-
WORDFMT = 'Q'
51+
MASKBITS = 2**WORDBITS - 1
52+
WORDFMT = "Q"
5453

5554
IV = (
56-
0x6a09e667f3bcc908, 0xbb67ae8584caa73b,
57-
0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1,
58-
0x510e527fade682d1, 0x9b05688c2b3e6c1f,
59-
0x1f83d9abfb41bd6b, 0x5be0cd19137e2179
55+
0x6A09E667F3BCC908,
56+
0xBB67AE8584CAA73B,
57+
0x3C6EF372FE94F82B,
58+
0xA54FF53A5F1D36F1,
59+
0x510E527FADE682D1,
60+
0x9B05688C2B3E6C1F,
61+
0x1F83D9ABFB41BD6B,
62+
0x5BE0CD19137E2179,
6063
)
6164

6265
ROT1 = 32
@@ -69,11 +72,12 @@ class Blake2b(Blake2):
6972

7073

7174
def blake2b_compress(
72-
num_rounds: int,
73-
h_starting_state: TMessageBlock,
74-
block: bytes,
75-
t_offset_counters: Tuple[int, int],
76-
final_block_flag: bool) -> bytes:
75+
num_rounds: int,
76+
h_starting_state: TMessageBlock,
77+
block: bytes,
78+
t_offset_counters: Tuple[int, int],
79+
final_block_flag: bool,
80+
) -> bytes:
7781
"""
7882
'F Compression' from section 3.2 of RFC 7693:
7983
https://tools.ietf.org/html/rfc7693#section-3.2
@@ -98,10 +102,10 @@ def blake2b_compress(
98102
sigma_schedule_len = len(sigma_schedule)
99103

100104
# convert block (bytes) into 16 LE words
101-
m = struct.unpack_from('<16%s' % Blake2b.WORDFMT, bytes(block))
105+
m = struct.unpack_from("<16%s" % Blake2b.WORDFMT, bytes(block))
102106

103107
v = [0] * 16
104-
v[0: 8] = h_starting_state
108+
v[0:8] = h_starting_state
105109
v[8:12] = IV[:4]
106110
v[12] = t_offset_counters[0] ^ IV[4]
107111
v[13] = t_offset_counters[1] ^ IV[5]
@@ -177,4 +181,4 @@ def G(a: int, b: int, c: int, d: int) -> None:
177181
G(3, 4, 9, 14)
178182

179183
result_message_words = (h_starting_state[i] ^ v[i] ^ v[i + 8] for i in range(8))
180-
return struct.pack(f'<8{Blake2b.WORDFMT}', *result_message_words)
184+
return struct.pack(f"<8{Blake2b.WORDFMT}", *result_message_words)

0 commit comments

Comments
 (0)