Skip to content

Commit 87b9415

Browse files
committed
run lint and clean up __init__ files
convert .format and % strings that pyupgrade can't do drop unnecessary deps, remove unnecessary upper pins remove pre-commit install from ci, it's handled by tox
1 parent c220149 commit 87b9415

File tree

167 files changed

+486
-664
lines changed

Some content is hidden

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

167 files changed

+486
-664
lines changed

.circleci/config.yml

-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ common: &common
5252
command: |
5353
python -m pip install --upgrade pip
5454
python -m pip install tox
55-
- run:
56-
name: install pre-commit
57-
command: python -m pip install --progress-bar=off pre-commit
5855
- run:
5956
name: run tox
6057
command: python -m tox run -r

.deepsource.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ name = "python"
99
enabled = true
1010

1111
[analyzers.meta]
12-
runtime_version = "3.x.x"
12+
runtime_version = "3.x.x"

.git-blame-ignore-revs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ e9049224a98439cc27522e322cc09e402503565a
33
1ee3cce389e48b37895e812692f87aaf4f96e27f
44

55
# ignore SHA that added black
6-
6c958538082fcf6e6d9165c30f289e3c64dbfc5a
6+
6c958538082fcf6e6d9165c30f289e3c64dbfc5a

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ repos:
4747
rev: v1.5.1
4848
hooks:
4949
- id: mypy
50-
exclude: tests/
50+
files: eth/

DEVELOPMENT.md

+18-19
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,26 @@ The following workflows are supported for blocks.
77
Incremental creation
88

99
1. Initialize Block - `Header.from_parent(...)`:
10-
- `coinbase`
11-
- `parent_hash`
12-
- `difficulty`
13-
- `block_number`
14-
- `gas_limit`
15-
- `timestamp`
16-
2. Apply Transaction(s) - `Block.apply_transaction(...)`:
17-
3. Mine Block - `Block.mine(...)`:
18-
- `uncles_hash`
19-
- `state_root`
20-
- `transaction_root`
21-
- `receipts_root`
22-
- `bloom`
23-
- `gas_used`
24-
- `extra_data`
25-
- `mix_hash`
26-
- `nonce`
27-
10+
- `coinbase`
11+
- `parent_hash`
12+
- `difficulty`
13+
- `block_number`
14+
- `gas_limit`
15+
- `timestamp`
16+
1. Apply Transaction(s) - `Block.apply_transaction(...)`:
17+
1. Mine Block - `Block.mine(...)`:
18+
- `uncles_hash`
19+
- `state_root`
20+
- `transaction_root`
21+
- `receipts_root`
22+
- `bloom`
23+
- `gas_used`
24+
- `extra_data`
25+
- `mix_hash`
26+
- `nonce`
2827

2928
## 2. Block Ingestion
3029

3130
> (This is actually just a special case of use case #1.)
3231
33-
Full ingestion of a complete block.
32+
Full ingestion of a complete block.

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ notes:
7171
git commit -m "Compile release notes for v$(UPCOMING_VERSION)"
7272

7373
release: check-bump clean
74-
# require that you be on a branch that's linked to upstream/master
75-
git status -s -b | head -1 | grep "\.\.upstream/master"
74+
# require that you be on a branch that's linked to upstream/main
75+
git status -s -b | head -1 | grep "\.\.upstream/main"
7676
# require that upstream is configured for ethereum/py-evm
7777
@git remote -v | grep -E "upstream\[email protected]:ethereum/py-evm.git \(push\)|upstream\thttps://(www.)?github.com/ethereum/py-evm \(push\)"
7878
# verify that docs build correctly

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
[![Python versions](https://img.shields.io/pypi/pyversions/py-evm.svg)](https://pypi.python.org/pypi/py-evm)
77
[![Docs build](https://readthedocs.org/projects/py-evm/badge/?version=latest)](https://py-evm.readthedocs.io/en/latest/?badge=latest)
88

9-
109
## Py-EVM
1110

1211
Py-EVM is an implementation of the Ethereum protocol in Python. It contains the low level

docs/api/api.chain.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ MiningChain
1717
-----------
1818

1919
.. autoclass:: eth.chains.base.MiningChain
20-
:members:
20+
:members:

docs/api/api.vm.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ Virtual Machine
1818
vm/api.vm.stack
1919
vm/api.vm.state
2020
vm/api.vm.transaction_context
21-
vm/api.vm.forks
21+
vm/api.vm.forks

docs/api/db/api.db.atomic.rst

-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ AtomicDB
1010

1111
.. autoclass:: eth.db.atomic.AtomicDBWriteBatch
1212
:members:
13-

docs/api/db/api.db.backends.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ MemoryDB
1111
--------
1212

1313
.. autoclass:: eth.db.backends.memory.MemoryDB
14-
:members:
14+
:members:

docs/api/db/api.db.diff.rst

-2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,3 @@ DiffMissingError
1818

1919
.. autoclass:: eth.db.diff.DiffMissingError
2020
:members:
21-
22-

docs/api/db/api.db.journal.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ JournalDB
55
---------
66

77
.. autoclass:: eth.db.journal.JournalDB
8-
:members:
8+
:members:

docs/api/db/api.db.schema.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ SchemaV1
55
--------
66

77
.. autoclass:: eth.db.schema.SchemaV1
8-
:members:
8+
:members:

docs/api/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This section aims to provide a detailed description of all APIs. If you are look
1111
:maxdepth: 4
1212
:name: toc-api-eth
1313

14-
14+
1515
api.abc
1616
api.chain
1717
api.db

docs/api/rlp/api.rlp.transactions.rst

-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ BaseUnsignedTransaction
2424

2525
.. autoclass:: eth.rlp.transactions.BaseUnsignedTransaction
2626
:members:
27-

docs/api/tools/api.tools.fixtures.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ Builder Tools
44

55
The JSON test fillers found in `eth.tools.fixtures` is a set of tools which facilitate
66
creating standard JSON consensus tests as found in the
7-
`ethereum/tests repository <https://github.com/ethereum/tests>`_.
7+
`ethereum/tests repository <https://github.com/ethereum/tests>`_.
88

99
.. note:: Only VM and state tests are supported right now.
1010

1111

1212
State Test Fillers
1313
------------------
1414

15-
Tests are generated in two steps.
15+
Tests are generated in two steps.
1616

1717
* First, a *test filler* is written that contains a high level description of the test case.
1818
* Subsequently, the filler is compiled to the actual test in a process called
@@ -52,7 +52,7 @@ sequence of functions.
5252
)
5353
)
5454
55-
.. note::
55+
.. note::
5656

5757
Note that :func:`~eth.tools.fixtures.setup_filler` returns a
5858
dictionary, whereas all of the following functions such as
@@ -68,4 +68,3 @@ sequence of functions.
6868
.. autofunction:: eth.tools.fixtures.fillers.execution
6969

7070
.. autofunction:: eth.tools.fixtures.fillers.expect
71-

docs/api/vm/api.vm.code_stream.rst

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ CodeStream
33

44
.. autoclass:: eth.vm.code_stream.CodeStream
55
:members:
6-

docs/api/vm/api.vm.execution_context.rst

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ ExecutionContext
33

44
.. autoclass:: eth.vm.execution_context.ExecutionContext
55
:members:
6-

docs/api/vm/api.vm.gas_meter.rst

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ GasMeter
33

44
.. autoclass:: eth.vm.gas_meter.GasMeter
55
:members:
6-

docs/api/vm/api.vm.memory.rst

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ Memory
33

44
.. autoclass:: eth.vm.memory.Memory
55
:members:
6-

docs/api/vm/api.vm.message.rst

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ Message
33

44
.. autoclass:: eth.vm.message.Message
55
:members:
6-

docs/api/vm/api.vm.opcode.rst

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ Opcode
33

44
.. autoclass:: eth.vm.opcode.Opcode
55
:members:
6-

docs/api/vm/api.vm.stack.rst

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ Stack
33

44
.. autoclass:: eth.vm.stack.Stack
55
:members:
6-

docs/api/vm/api.vm.transaction_context.rst

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ BaseTransactionContext
33

44
.. autoclass:: eth.vm.transaction_context.BaseTransactionContext
55
:members:
6-

docs/api/vm/api.vm.vm.rst

-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ VM
99
.. autoclass:: eth.vm.base.VM
1010
:members:
1111
:exclude-members: get_prev_hashes
12-

docs/conf.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@
120120

121121

122122
def setup(app):
123-
app.add_stylesheet("css/custom.css")
124-
app.add_javascript("js/matomo.js")
123+
app.add_css_file("css/custom.css")
124+
app.add_js_file("js/matomo.js")
125125

126126

127127
# Allows the mod index to function more helpfully (not everything under 'e')
@@ -133,7 +133,7 @@ def setup(app):
133133
# -- Options for HTMLHelp output ------------------------------------------
134134

135135
# Output file base name for HTML help builder.
136-
htmlhelp_basename = "ethdocs"
136+
htmlhelp_basename = "py-evmdocs"
137137

138138

139139
# -- Options for LaTeX output ---------------------------------------------

docs/contributing.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Code Style
5151

5252
When multiple people are working on the same body of code, it is important that they write code that conforms to a similar style. It often doesn't matter as much which style, but rather that they conform to one style.
5353

54-
To ensure your contribution conforms to the style being used in this project, we encourage you to read our `style guide <https://github.com/pipermerriam/ethereum-dev-tactical-manual/blob/master/style-guide.md>`_.
54+
To ensure your contribution conforms to the style being used in this project, we encourage you to read our `style guide <https://github.com/ethereum/snake-charmers-tactical-manual/blob/main/style-guide.md>`_.
5555

5656

5757

@@ -74,7 +74,7 @@ Documentation
7474
~~~~~~~~~~~~~
7575

7676
Good documentation will lead to quicker adoption and happier users. Please check out our guide
77-
on `how to create documentation for the Python Ethereum ecosystem <https://github.com/ethereum/snake-charmers-tactical-manual/blob/master/documentation.md>`_.
77+
on `how to create documentation for the Python Ethereum ecosystem <https://github.com/ethereum/snake-charmers-tactical-manual/blob/main/documentation.md>`_.
7878

7979

8080
Pull Requests
@@ -92,7 +92,7 @@ do not pass the CI build yet won't get reviewed unless explicitly requested.
9292

9393
If the pull request introduces changes that should be reflected in the release notes,
9494
please add a `newsfragment` file as explained
95-
`here <https://github.com/ethereum/py-evm/blob/master/newsfragments/README.md>`_.
95+
`here <https://github.com/ethereum/py-evm/blob/main/newsfragments/README.md>`_.
9696

9797
If possible, the change to the release notes file should be included in the commit that introduces the
9898
feature or bugfix.
@@ -107,7 +107,7 @@ Before releasing a new version, build and test the package that will be released
107107

108108
.. code:: sh
109109
110-
git checkout master && git pull
110+
git checkout main && git pull
111111
112112
make package
113113

docs/cookbook/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ Building blocks incrementally
104104
------------------------------
105105

106106
The default :class:`~eth.chains.chain.Chain` is stateless and thus does not keep a tip block open
107-
that would allow us to incrementally build a block. However, we can import the
107+
that would allow us to incrementally build a block. However, we can import the
108108
:class:`~eth.chains.chain.MiningChain` which does allow exactly that.
109109

110110
.. doctest::
111111

112112
>>> from eth.chains.base import MiningChain
113113

114114
Please check out the :doc:`Understanding the mining process
115-
</guides/understanding_the_mining_process>` guide for a full example that demonstrates how
115+
</guides/understanding_the_mining_process>` guide for a full example that demonstrates how
116116
to use the :class:`~eth.chains.chain.MiningChain`.

docs/fragments/virtualenv_explainer.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ To activate the virtual directory we have to *source* it
1919

2020
.. code:: sh
2121
22-
. venv/bin/activate
22+
. venv/bin/activate

docs/guides/architecture.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ The term **Computation** is used to encapsulate:
9090

9191
- The computational state during VM execution (e.g. memory, stack, gas metering)
9292
- The computational results of VM execution (e.g. return data, gas consumption and refunds, execution errors)
93-
93+
9494
This abstraction is the interface through which opcode logic is implemented.
9595

9696

docs/guides/building_an_app_that_uses_pyevm.rst

+1-4
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ Next, we'll create a new directory ``app`` and create a file ``main.py`` inside.
9999

100100
>>> mock_address_balance = chain.get_vm().state.get_balance(MOCK_ADDRESS)
101101

102-
>>> print("The balance of address {} is {} wei".format(
103-
... encode_hex(MOCK_ADDRESS),
104-
... mock_address_balance)
105-
... )
102+
>>> print(f"The balance of address {encode_hex(MOCK_ADDRESS)} is {mock_address_balance} wei")
106103
The balance of address 0x0000000000000000000000000000000000000000 is 10000000000000000000000 wei
107104

108105
Running the script

docs/guides/creating_opcodes.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Usage of the :func:`~eth.vm.opcode.as_opcode` helper:
5151
5252
def custom_op(computation):
5353
... # opcode logic here
54-
54+
5555
class ExampleComputation(BaseComputation):
5656
opcodes = {
5757
b'\x01': as_opcode(custom_op, 'CUSTOM_OP', 10),

docs/guides/quickstart.rst

-2
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,3 @@ Finally, install the ``py-evm`` package via pip:
5858

5959
:doc:`Build a first app </guides/building_an_app_that_uses_pyevm>` on top of Py-EVM in under
6060
5 minutes
61-
62-

eth/__init__.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import pkg_resources
21
import sys
32

4-
from eth.chains import ( # noqa: F401
3+
from importlib.metadata import (
4+
version as __version,
5+
)
6+
7+
from eth.chains import (
58
Chain,
69
MainnetChain,
710
MainnetTesterChain,
@@ -15,4 +18,4 @@
1518
sys.setrecursionlimit(max(EVM_RECURSION_LIMIT, sys.getrecursionlimit()))
1619

1720

18-
__version__ = pkg_resources.get_distribution("py-evm").version
21+
__version__ = __version("py-evm")

eth/_utils/blake2/compression.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def blake2b_compress(
8383
'F Compression' from section 3.2 of RFC 7693:
8484
https://tools.ietf.org/html/rfc7693#section-3.2
8585
"""
86-
8786
# Dereference these for [very small] speed improvement.
8887
# Perhaps more than anything, this makes the code
8988
# easier to read.
@@ -107,7 +106,7 @@ def blake2b_compress(
107106
m = (
108107
block
109108
if isinstance(block, tuple)
110-
else struct.unpack_from("<16%s" % Blake2b.WORDFMT, bytes(block))
109+
else struct.unpack_from(f"<16{Blake2b.WORDFMT}", bytes(block))
111110
)
112111

113112
v = [0] * 16

0 commit comments

Comments
 (0)