This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
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.
Add missing type hints for tests.unittest. #13397
Add missing type hints for tests.unittest. #13397
Changes from 9 commits
1674b7f
6c0344a
e36b12d
e4012f0
4853dd5
76270c3
5a21ef7
700dfcf
aca8cf6
603d70a
74d6acb
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
A minor nitpick: Is this strictly correct? From the perspective of type annotations only:
code
is the wrapper function which is being decorated by@around(target)
.code
isorig
.new
is alsoorig
.code(...)
on line +117 passes inorig
twice. But that's not what the source code does.I think
code: Callable[Concatenate[object, P], R]
might be more accurate (whereobject
representsorig
).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 might be more accurate, yes. I'll check that!
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 this is correct -- the code would fail in this case because
setUp
doesn't accept*args
.new
needs to match the signature oforig
, not ofcode
. I believe this is what the current code does.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 think we're agreeing with each other, but I didn't express myself well. Perhaps instead of
I should have said
Putting that aside for the moment, however, I entirely agree with your summary here:
but I don't think this is what the current set of annotations mean. At present, both
new
andcode
are of typeCallable[P, R]
. But this doesn't make sense, becausecode
takesorig
as an extra argument!I still think that
code: Callable[Concatenate[object, P], R]
is correct here. Have I managed to convince you?(You could try writing/casting
orig: Callable[P, R] = ...
; I think mypy would detect the inconsistency I've tried to describe above.)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 believe 603d70a fixes this?