Cereal2nd / velbus-aio

Velbus Asyncio
Apache License 2.0
15 stars 10 forks source link

Add type anotations everywhere #4

Open Cereal2nd opened 3 years ago

Cereal2nd commented 3 years ago

a mypy run results in a lot of errors, we should solve all these:

helpers.py:26: error: Incompatible return value type (got "bool", expected "Dict[Any, Any]") helpers.py:65: error: Need type annotation for "result" (hint: "result: Dict[, ] = ...") helpers.py:97: error: Argument 1 to "join" has incompatible type "Optional[str]"; expected "Union[str, PathLike[str]]" command_registry.py:12: error: Need type annotation for "_default_commands" (hint: "_default_commands: Dict[, ] = ...") command_registry.py:13: error: Need type annotation for "_overrides" (hint: "_overrides: Dict[, ] = ...") command_registry.py:16: error: Incompatible default for argument "module_name" (default has type "int", argument has type "str") command_registry.py:30: error: Argument 3 to "_register_override" of "CommandRegistry" has incompatible type "Optional[Any]"; expected "str" command_registry.py:71: error: Incompatible default for argument "module_type" (default has type "int", argument has type "str") message.py:42: error: Incompatible types in assignment (expression has type "int", variable has type "None") message.py:43: error: Incompatible types in assignment (expression has type "int", variable has type "bool") message.py:69: error: Incompatible types in assignment (expression has type "int", variable has type "None") message.py:130: error: Incompatible return value type (got "List[int]", expected "str") handler.py:48: error: Unsupported operand types for & ("str" and "int") handler.py:49: error: Unsupported operand types for & ("str" and "int") handler.py:61: error: Incompatible types in assignment (expression has type "ModuleSubTypeMessage", variable has type "ModuleTypeMessage") handler.py:74: error: Argument 1 to "get_command" of "CommandRegistry" has incompatible type "str"; expected "int" handler.py:75: error: "None" not callable handler.py:97: error: Need type annotation for "result" (hint: "result: Dict[, ] = ...") handler.py:99: error: Incompatible types in assignment (expression has type "str", variable has type "int") handler.py:147: error: "Message" has no attribute "module_type" handler.py:149: error: "Message" has no attribute "module_type" handler.py:154: error: "Message" has no attribute "module_type" handler.py:156: error: "Message" has no attribute "memory_map_version" handler.py:157: error: "Message" has no attribute "build_year" handler.py:158: error: "Message" has no attribute "build_week" handler.py:159: error: "Message" has no attribute "serial" handler.py:166: error: "Message" has no attribute "sub_address_1" handler.py:167: error: "Message" has no attribute "sub_address_2" handler.py:168: error: "Message" has no attribute "sub_address_3" handler.py:169: error: "Message" has no attribute "sub_address_4" handler.py:182: error: Unsupported operand types for & ("str" and "int") channels.py:169: error: Incompatible return value type (got "int", expected "str") channels.py:172: error: Incompatible return value type (got "None", expected "str") channels.py:189: error: "None" not callable channels.py:195: error: "None" not callable channels.py:201: error: "None" not callable channels.py:207: error: "None" not callable channels.py:261: error: "None" not callable channels.py:312: error: Incompatible return value type (got "None", expected "str") channels.py:313: error: Incompatible return value type (got "None", expected "str") channels.py:316: error: Unsupported left operand type for / ("None") channels.py:319: error: Incompatible return value type (got "None", expected "str") channels.py:366: error: "None" not callable channels.py:377: error: "None" not callable channels.py:409: error: Incompatible return value type (got "None", expected "int") channels.py:414: error: Incompatible return value type (got "None", expected "int") channels.py:478: error: Incompatible return value type (got "None", expected "bool") channels.py:494: error: "None" not callable channels.py:503: error: "None" not callable channels.py:524: error: "None" not callable channels.py:531: error: "None" not callable module.py:90: error: Need type annotation for "_name" (hint: "_name: Dict[, ] = ...") module.py:91: error: Need type annotation for "_sub_address" (hint: "_sub_address: Dict[, ] = ...") module.py:97: error: Need type annotation for "_channels" (hint: "_channels: Dict[, ] = ...") module.py:167: error: Incompatible return value type (got "Dict[Any, Any]", expected "str") module.py:260: error: Argument 1 to "_translate_channel_name" of "Module" has incompatible type "int"; expected "str" module.py:267: error: Argument 1 to "_translate_channel_name" of "Module" has incompatible type "int"; expected "str" module.py:276: error: Argument 1 to "_translate_channel_name" of "Module" has incompatible type "int"; expected "str" module.py:304: error: Argument 1 to "_translate_channel_name" of "Module" has incompatible type "int"; expected "str" module.py:319: error: Argument 1 to "_translate_channel_name" of "Module" has incompatible type "int"; expected "str" module.py:324: error: Argument 1 to "_translate_channel_name" of "Module" has incompatible type "int"; expected "str" module.py:329: error: Argument 1 to "_translate_channel_name" of "Module" has incompatible type "int"; expected "str" module.py:334: error: Argument 1 to "_translate_channel_name" of "Module" has incompatible type "int"; expected "str" module.py:358: error: Incompatible return value type (got "Dict[Any, Any]", expected "List[Any]") module.py:420: error: Incompatible types in assignment (expression has type "str", variable has type "Dict[Any, Any]") module.py:509: error: Incompatible types in assignment (expression has type "None", variable has type "Dict[Any, Any]") discovery.py:15: error: Argument 1 of "connection_made" is incompatible with supertype "BaseProtocol"; supertype defines the argument type as "BaseTransport" discovery.py:15: note: This violates the Liskov substitution principle discovery.py:15: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides controller.py:11: error: Skipping analyzing "serial": found module but no type hints or library stubs controller.py:11: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports controller.py:12: error: Skipping analyzing "serial_asyncio": found module but no type hints or library stubs controller.py:38: error: Need type annotation for "_modules" (hint: "_modules: Dict[, ] = ...") controller.py:39: error: Need type annotation for "_submodules" (hint: "_submodules: List[] = ...") controller.py:40: error: Need type annotation for "_send_queue" controller.py:41: error: Need type annotation for "_tasks" (hint: "_tasks: List[] = ...") controller.py:65: error: Argument 1 to "Module" has incompatible type "str"; expected "int" controller.py:66: error: Argument 2 to "Module" has incompatible type "str"; expected "int" controller.py:85: error: Missing return statement controller.py:117: error: "None" has no attribute "close" controller.py:118: error: "None" has no attribute "wait_closed" controller.py:132: error: Incompatible types in assignment (expression has type "None", variable has type "SSLContext") controller.py:134: error: Incompatible types in assignment (expression has type "StreamReader", variable has type "None") controller.py:134: error: Incompatible types in assignment (expression has type "StreamWriter", variable has type "None") controller.py:217: error: "None" has no attribute "write" controller.py:228: error: "None" has no attribute "read"