New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change linting to use pre-commit #3297
Conversation
fb4daeb
to
235871f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvements! lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a few comments. I don't think turning off noqa B008
on whole files is ideal. Also, should we ignore large json spec files for ENS? I don't see a benefit in formatting those but could go either way. I don't see a specific json formatter in pre-commit, just yaml and toml.
According to the github merge check there's a conflict too that likely needs to be resolved before merging.
web3/providers/rpc/rpc.py
Outdated
@@ -63,7 +63,7 @@ def __init__( | |||
request_kwargs: Optional[Any] = None, | |||
session: Optional[Any] = None, | |||
exception_retry_configuration: Optional[ExceptionRetryConfiguration] = ( | |||
ExceptionRetryConfiguration( | |||
ExceptionRetryConfiguration( # noqa: B008 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing as the async_rpc.py
case here. This feels like a valid B008
case. I think we should set it to None
here and below:
self.exception_retry_configuration = (
exception_retry_configuration
or ExceptionRetryConfiguration(
errors=(
ConnectionError,
requests.HTTPError,
requests.Timeout,
)
)
)
ens/async_ens.py
Outdated
@@ -1,3 +1,4 @@ | |||
# flake8: noqa: B008 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should ignore whole files like this unless we have good reason to. We can resolve the three specific issues by setting arguments to None
and addressing them in the method with if x is None: {{set the default value}}
.
This guarantees it's not just set once. Even if that's intended behavior, we should add noqa: B008
to single lines and explain why they're there with a comment instead of whole files. That would make it easy to mask future errors since it's sneakily up at the top of the file.
Specifically, in this file, we can address:
provider
in__init__()
address
insetup_address()
new_owner
insetup_owner()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put those there instead of inline because I made a note "talk to Felipe about the B008 ignores". And then forgot about it.
b871c90
to
c9d5284
Compare
I've cleaned up per comments. All added There are 4 remaining The other 2 are related to HTTP provider retry config. Removing them fails: I tried a few things to fix them but no dice. Let me know if you'd like to try to fix them here or open a new issue to deal with them separately. |
…s.rst to match template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a terrifying cute animal picture, lol. I think the typing changes will be breaking, so I think that this can only go into v7. I may be thinking about that wrong though, so let me know if I am. Thanks for getting this done, it will be so nice to have precommit in web3 finally! The commits made it super easy(/manageable :) ) to review, thank you!
…rule, ignore the few places we do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks for clearing up those comments! 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! This will be amazing to get in, ty.
What was wrong?
pre-commit
is totally rad and we should use it for web3 v7!How was it fixed?
Added pre-commit, removed previous linting setup, moved config to
pyproject.toml
where possible.To aid in review, I've made one commit for each new lint tool. It's still a big pr but should be more manageable that way.
Todo:
Cute Animal Picture