Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What 💻
This PR tries to make some improvement suggestions to this project based on Python Best Practices for a New Project in 2021 and my Python experience with this blog article.
There is only one additional dev dependencies introduced pre-commit, it can be installed into Git Hooks and run automatically before any
git commit
locally. Its configuration file is.pre-commit-config.yaml
, and I have configured some hooks such as notrailing-whitespace
and add new line at the end of file. Other hooks areisort
,flake8
,black
,mypy
. These hooks are installed bypre-commit
at a separate location on the machine and will not interfere with dependency of this repo.isort
groups imports into 3 categories, packages imported from Python own library, external library (web3
) and other local imports. Within each category, it sorts imports in alphabetical order.flake8
is a linter, it can detect things like unused imports, variables; variable use before its creation and etcblack
is a formattermypy
is a static type checker for PythonCurrently, within
.pre-commit-config.yaml
, it does not check any files, you can learn more about the exclude regex here. With refactor going on, we can change the exclude part and check those files slowly.I would also like to explain some changes in this commit:
validate.yml
will be usingpre-commit
to do a comprehensive check. refpyproject.toml
has configs forisort
andblack
. (NOTE: I personally prefers line length 99, as nowadays computer screen is quite wide, but if you don't like it, I can change it to the default 88)setup.cfg
has configs forflake8
andmypy
, mypy config refWhy ✋
When I first start to use this repo, I noticed the
Any
type is returned everywhere, mainly because of #63 , it made the developing experience very bad. Then I dig deeper, and noticed many unused imports, wrong type hints, and some wrong typing issue that could be caught with a linter. I would like to propose my Python practice to this repo. The better this repo is, the smoother my developing experience will be.Evidence 📷
Include screenshots, screen recordings, or
console
output here demonstrating that your changes work as intendedNotes 📝
Sorry for this long PR, basically I would like to try my best to make this repo better, I finally found an open-source project that I feel I can contribute a lot.
CONTRIBUTING.md
with a notes onpre-commit
hook installation and usage.zksync2/account
,zksync2/core
,zksync/manage_contracts
,zksync/signer
andzksync/transaction
. I am thinking of using existing test cases to check the correctness of the refactoring and add more test cases accordingly.