Repository navigation
test: Correct MyPy typing for subtest decorator - #23420
Merged
Merged
Conversation
Contributor
Author
|
@MarcoFalke Do you still think this should be merged, despite the parent issue has been closed? |
Member
|
@prius yes this should be left open. |
Member
|
Code review ACK 83b32fe599c91fc52d89f4172c0b064d643620d8 I would prefer for the |
Contributor
Author
|
@laanwj Good catch! Removed |
Member
It's still in the commit message. |
Contributor
Author
|
@fanquake Commit message changed to be the same as PR title. |
fanquake
approved these changes
Nov 11, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This is the part of the effort to make python typing correct #19389
The typing of the
subtestdecorator withinp2p_segwit.pytest file was incorrect.Since
subtestfunction is defined as a member of the class, it expectsselfas a first argument, and it is not provided. Hence the typing errors (that are currently suppressed bytype: ignore).However, the tests are passing, because there is no
selfargument passed when it is called as a decorator.There is also suppressed pylint error
# noqa: N805pointing to the same issue.So the solution is to move the
subtestdefinition outside the class, so theselfargument is no longer required.After doing so, both mypy and unittests are successfully passing: