You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromtypingimportProtocolclassHandler(Protocol):
def__call__(self, value: int, name: str) ->int:
passdefinvalid_func_arg_type_mismatch(value: str, name: str) ->int:
returnvalue*2definvalid_func_return_type_mismatch(value: int, name: str) ->str:
returnvalue*2classAsyncHandler(Protocol):
asyncdef__call__(self, value: int, name: str) ->int:
passasyncdefinvalid_async_func_arg_type_mismatch(value: str, name: str) ->int:
returnvalue*2asyncdefinvalid_async_func_return_type_mismatch(value: int, name: str) ->str:
returnvalue*2# None of the following lines triggers a pylint issue regarding# mismatch of the return-type or argument-type from the defined Protocol.# My IntelliJ IDE complains on all 4 lines, because either an argument-type# or the return-type of the function will not match the `Protocol` I try to assign# to.# Expected type 'Handler', got '(value: str, name: str) -> int' insteadmy_handler_a: Handler=invalid_func_arg_type_mismatch# Expected type 'Handler', got '(value: int, name: str) -> str' insteadmy_handler_b: Handler=invalid_func_return_type_mismatch# Expected type 'AsyncHandler', got '(value: str, name: str) -> Coroutine[Any, Any, int]' insteadmy_handler_c: AsyncHandler=invalid_async_func_arg_type_mismatch# Expected type 'AsyncHandler', got '(value: int, name: str) -> Coroutine[Any, Any, str]' instead my_handler_d: AsyncHandler=invalid_async_func_return_type_mismatch
Bug description
Configuration
Command used
Pylint output
Expected behavior
Assignment with mismatched types should result in output of pylint complaining about the mismatch with the given Protocol.
Pylint version
OS / Environment
MacOS, 15.3.1 (24D70), Apple M1 Pro
Additional dependencies
The text was updated successfully, but these errors were encountered: