Two small changes to help the mypy test suite pass#355
Conversation
| def skipIf(condition: bool, reason: str) -> Callable[[_FT], _FT]: ... | ||
| def skipUnless(condition: bool, reason: str) -> Callable[[_FT], _FT]: ... | ||
| def skipIf(condition: object, reason: str) -> Callable[[_FT], _FT]: ... | ||
| def skipUnless(condition: object, reason: str) -> Callable[[_FT], _FT]: ... |
There was a problem hiding this comment.
Could you just write
def skipIf(condition, reason: str) -> ...
?
There was a problem hiding this comment.
Because this is a stub, there's really no difference between leaving the type out, using Any, or using object. I like object because the truthiness check is actually defined there (other objects just override it). But I'm flexible. What's your preference?
There was a problem hiding this comment.
I usually prefer leaving the type out, but I see your point about __nonzero__ in this particular case.
There was a problem hiding this comment.
I think it's better to always write down a type in a stub when you know what it is, because otherwise it's not clear if the absence of a type is purposeful or if the stub is incomplete. If we left the type out here, for example, I could imagine someone in the future trying to change it back to bool, thinking it was accidentally left out.
Also, I'd strongly prefer object to Any in this case, even though they have the same effect: Any implies the use of an escape hatch is necessary/the function can't be properly typed, which isn't the case here.
There was a problem hiding this comment.
This is an alternative to python/mypy#1841. @matthiaskramm What do you think?