@@ -54,7 +54,7 @@ Finally, install all development dependencies:
54
54
55
55
.. code :: sh
56
56
57
- $ pip install -e " .[dev]"
57
+ $ python -m pip install -e " .[dev]"
58
58
$ pre-commit install
59
59
60
60
@@ -74,64 +74,34 @@ To start up the test environment, run:
74
74
This will build a Docker container set up with an environment to run the
75
75
Python test code.
76
76
77
- .. note ::
78
-
79
- This container does not have `go-ethereum ` installed, so you cannot run
80
- the go-ethereum test suite.
81
-
82
- To run the Python tests from your local machine:
77
+ To run the core tests from your local machine:
83
78
84
79
.. code :: sh
85
80
86
- $ docker compose exec sandbox bash -c ' pytest -n 4 -f -k "not goethereum" '
81
+ $ docker compose exec sandbox bash -c ' pytest tests/core '
87
82
88
83
89
- You can run arbitrary commands inside the Docker container by using the
90
- ` bash -c ` prefix .
84
+ The container does not have `` go-ethereum `` installed, so you can exclude those tests
85
+ by using the `` -k "not goethereum" `` flag .
91
86
92
87
.. code :: sh
93
88
94
- $ docker compose exec sandbox bash -c ' '
89
+ $ docker compose exec sandbox bash -c ' pytest tests/integration -k "not goethereum" '
95
90
96
91
97
- Or, if you would like to open a session to the container, run:
92
+ You can run arbitrary commands inside the Docker container by using the
93
+ ``bash -c `` prefix.
98
94
99
95
.. code :: sh
100
96
101
- $ docker compose exec sandbox bash
102
-
103
-
104
- Code Style
105
- ~~~~~~~~~~
97
+ $ docker compose exec sandbox bash -c ' pwd && ls'
106
98
107
- We value code consistency. To ensure your contribution conforms to the style
108
- being used in this project, we encourage you to read our `style guide `_.
109
99
110
- We use Black for linting. To ignore the commits that introduced Black in
111
- git history, you can configure your git environment like so:
100
+ Or, if you would like to open a session to the container, run:
112
101
113
102
.. code :: sh
114
103
115
- git config blame.ignoreRevsFile .git-blame-ignore-revs
116
-
117
-
118
- Type Hints
119
- ~~~~~~~~~~
120
-
121
- This code base makes use of `type hints `_. Type hints make it easy to prevent
122
- certain types of bugs, enable richer tooling, and enhance the documentation,
123
- making the code easier to follow.
124
-
125
- All new code is required to include type hints, with the exception of tests.
126
-
127
- All parameters, as well as the return type of functions, are expected to be typed,
128
- with the exception of ``self `` and ``cls `` as seen in the following example.
129
-
130
- .. code :: python
131
-
132
- def __init__ (self , wrapped_db : DatabaseAPI) -> None :
133
- self .wrapped_db = wrapped_db
134
- self .reset()
104
+ $ docker compose exec sandbox bash
135
105
136
106
137
107
Running The Tests
@@ -144,7 +114,8 @@ First, install the test dependencies:
144
114
145
115
.. code :: sh
146
116
147
- $ pip install -e " .[test]"
117
+ $ python -m pip install -e " .[test]"
118
+
148
119
149
120
You can run all tests with:
150
121
@@ -161,15 +132,8 @@ Typically, you'll just want to run a subset instead, like:
161
132
$ pytest tests/core/eth-module/test_accounts.py
162
133
163
134
164
- You can use ``tox `` to run all the tests for a given version of Python:
165
-
166
- .. code :: sh
167
-
168
- $ tox -e py38-core
169
-
170
-
171
- Linting is also performed by the CI. You can save yourself some time by checking for
172
- linting errors locally:
135
+ Linting is also performed by the CI and locally with each commit. You can save yourself
136
+ some time by checking for linting errors manually:
173
137
174
138
.. code :: sh
175
139
@@ -256,12 +220,11 @@ Arguments for the script are:
256
220
257
221
258
222
To run the script, you will need the ``py-solc-x `` library for compiling the files
259
- as well as ``black `` for code formatting. You can install those independently or
260
- install the full ``[dev] `` package extra as shown below.
223
+ as well as ``black `` for code formatting. You can install those with:
261
224
262
225
.. code :: sh
263
226
264
- $ pip install " web3[dev] "
227
+ $ python -m pip install py-solc-x black
265
228
266
229
The following example compiles all the contracts and generates their respective
267
230
contract data that is used across our test files for the test suites. This data gets
@@ -304,7 +267,35 @@ you can install it from your development directory:
304
267
305
268
.. code :: sh
306
269
307
- $ pip install -e ../path/to/web3py
270
+ $ python -m pip install -e ../path/to/web3py
271
+
272
+
273
+ Code Style
274
+ ~~~~~~~~~~
275
+
276
+ We use `pre-commit <https://pre-commit.com/ >`_ to enforce a consistent code style across
277
+ the library. This tool runs automatically with every commit, but you can also run it
278
+ manually with:
279
+
280
+ .. code :: sh
281
+
282
+ $ make lint
283
+
284
+
285
+ If you need to make a commit that skips the ``pre-commit `` checks, you can do so with
286
+ ``git commit --no-verify ``.
287
+
288
+ We use Black as part of our linting. To ignore the commits that introduced Black in
289
+ git history, you can configure your git environment like so:
290
+
291
+ .. code :: sh
292
+
293
+ $ git config blame.ignoreRevsFile .git-blame-ignore-revs
294
+
295
+
296
+ This library uses `type hints `_, which are enforced by the ``mypy `` tool (part of the
297
+ ``pre-commit `` checks). All new code is required to land with type hints, with the
298
+ exception of code within the ``tests `` directory.
308
299
309
300
310
301
Documentation
@@ -352,7 +343,7 @@ Before generating new fixtures, make sure you have the test dependencies install
352
343
353
344
.. code :: sh
354
345
355
- $ pip install -e " .[test]"
346
+ $ python -m pip install -e " .[test]"
356
347
357
348
.. note ::
358
349
@@ -436,8 +427,8 @@ Before releasing a new version, build and test the package that will be released
436
427
437
428
.. code :: sh
438
429
439
- git checkout main && git pull
440
- make package-test
430
+ $ git checkout main && git pull
431
+ $ make package-test
441
432
442
433
This will build the package and install it in a temporary virtual environment. Follow
443
434
the instructions to activate the venv and test whatever you think is important.
@@ -446,13 +437,13 @@ Review the documentation that will get published:
446
437
447
438
.. code :: sh
448
439
449
- make docs
440
+ $ make docs
450
441
451
442
Validate and preview the release notes:
452
443
453
444
.. code :: sh
454
445
455
- make validate-newsfragments
446
+ $ make validate-newsfragments
456
447
457
448
Build the release notes
458
449
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -463,7 +454,7 @@ release notes.
463
454
464
455
.. code :: sh
465
456
466
- make notes bump=$$ VERSION_PART_TO_BUMP$$
457
+ $ make notes bump=$$ VERSION_PART_TO_BUMP$$
467
458
468
459
If there are any errors, be sure to re-run make notes until it works.
469
460
@@ -474,7 +465,7 @@ After confirming that the release package looks okay, release a new version:
474
465
475
466
.. code :: sh
476
467
477
- make release bump=$$ VERSION_PART_TO_BUMP$$
468
+ $ make release bump=$$ VERSION_PART_TO_BUMP$$
478
469
479
470
This command will:
480
471
@@ -497,10 +488,10 @@ beta).
497
488
If you are in a beta version, ``make release bump=stage `` will switch to a stable.
498
489
499
490
To issue an unstable version when the current version is stable, specify the new version
500
- explicitly, like ``make release bump="--new-version 4.0.0-alpha.1" ``
491
+ explicitly, like ``make release bump="--new-version 4.0.0-alpha.1" ``.
501
492
502
493
You can see what the result of bumping any particular version part would be with
503
- ``bump-my-version show-bump ``
494
+ ``bump-my-version show-bump ``.
504
495
505
496
.. _Python Discord server : https://discord.gg/GHryRvPB84
506
497
.. _style guide : https://github.com/ethereum/snake-charmers-tactical-manual/blob/main/style-guide.md
0 commit comments