[Hotfix] Make Use class callable to resolve mypy type errors with And/Or #337
[Hotfix] Make Use class callable to resolve mypy type errors with And/Or #337skorokithakis merged 4 commits intokeleshev:masterfrom
Conversation
Signed-off-by: Alvaro Frias <alvaro.frias@eclypsium.com>
Signed-off-by: Alvaro Frias <alvaro.frias@eclypsium.com>
| Hmm, how did calling work before without the class being callable? |
| there was no call definition but this is mostly a static type check error in execution time there are no changes. the implementation of call seems more suitable given that is a wrapper of the callable being used but it could be left unimplemented and I think mypy would pass given that it would be callable |
| Hmm, I'm confused. The proper way to use |
| I don't think so given that the Use class has the validate method and that calls the callable method it wraps and in the _priority method its checked first that has the validate method than the it's callable (https://github.com/keleshev/schema/blob/master/schema/__init__.py#L335) Use class will always be used via validate method that's why didn't need the |
| Makes sense, thank you! |
When using
UsewithAndorOrcombinators, mypy reported a type error:Error:
Solution
Added
__call__method to theUseclass, making it properly callable:Closes #336