Typing errors after downtime
Closed this issue · 3 comments
qstokkink commented
Our mypy
check was silently passing after the Jenkins upgrade. I fixed this today and uncovered several hidden type inconsistencies:
Outdated inconsistencies (see below for recent ones)
ipv8/REST/base_endpoint.py:35: error: Argument "middlewares" to "Application" has incompatible type "Iterable[Union[Callable[[Request, Callable[[Request], Awaitable[StreamResponse]]], Awaitable[StreamResponse]], Callable[[Application, Callable[[Request], Awaitable[StreamResponse]]], Awaitable[Callable[[Request], Awaitable[StreamResponse]]]]]]"; expected "Iterable[Callable[[Request, Callable[[Request], Awaitable[StreamResponse]]], Awaitable[StreamResponse]]]" [arg-type]
ipv8/messaging/anonymization/tunnel.py:645: error: Argument 1 to "sum" has incompatible type "list[Union[list[IntroductionPoint], BaseException]]"; expected "Iterable[list[Union[list[IntroductionPoint], BaseException]]]" [arg-type]
ipv8/messaging/anonymization/tunnel.py:646: error: Argument 1 to "on_success" has incompatible type "list[Union[list[IntroductionPoint], BaseException]]"; expected "list[IntroductionPoint]" [arg-type]
ipv8/dht/community.py:640: error: Incompatible types in assignment (expression has type "list[Union[list[Node], list[tuple[bytes, Optional[bytes]]], tuple[list[tuple[bytes, Optional[bytes]]], Crawl]]]", variable has type "Union[list[list[Node]], list[list[tuple[bytes, Optional[bytes]]]], list[tuple[list[tuple[bytes, Optional[bytes]]], Crawl]]]") [assignment]
ipv8/messaging/anonymization/hidden_services.py:175: error: List comprehension has incompatible type List[Union[list[IntroductionPoint], None, BaseException]]; expected List[Optional[IntroductionPoint]] [misc]
ipv8/messaging/anonymization/exit_socket.py:14: error: Module "ipv8.messaging.anonymization.tunnel" has no attribute "RoutingObject" [attr-defined]
ipv8/messaging/anonymization/exit_socket.py:263: error: "Hop" has no attribute "address" [attr-defined]
ipv8/messaging/anonymization/crypto.py:19: error: Module "ipv8.messaging.anonymization.tunnel" has no attribute "BACKWARD" [attr-defined]
ipv8/messaging/anonymization/crypto.py:19: error: Module "ipv8.messaging.anonymization.tunnel" has no attribute "FORWARD" [attr-defined]
ipv8/messaging/anonymization/crypto.py:210: error: "RelayRoute" has no attribute "hop" [attr-defined]
ipv8/messaging/anonymization/crypto.py:211: error: "RelayRoute" has no attribute "hop" [attr-defined]
ipv8/messaging/anonymization/crypto.py:214: error: "RelayRoute" has no attribute "direction" [attr-defined]
ipv8/messaging/anonymization/crypto.py:216: error: "RelayRoute" has no attribute "hop" [attr-defined]
ipv8/messaging/anonymization/crypto.py:218: error: "RelayRoute" has no attribute "hop" [attr-defined]
ipv8/messaging/anonymization/crypto.py:226: error: "RelayRoute" has no attribute "hop" [attr-defined]
ipv8/messaging/anonymization/crypto.py:243: error: "Circuit" has no attribute "hop"; maybe "hops"? [attr-defined]
ipv8/messaging/anonymization/crypto.py:243: error: Argument 2 to "Hop" has incompatible type "SessionKeys"; expected "Optional[list[int]]" [arg-type]
ipv8/messaging/anonymization/crypto.py:249: error: "RelayRoute" has no attribute "hop" [attr-defined]
ipv8/messaging/anonymization/crypto.py:253: error: "RelayRoute" has no attribute "direction" [attr-defined]
ipv8/messaging/anonymization/crypto.py:253: error: "RelayRoute" has no attribute "hop" [attr-defined]
ipv8/messaging/anonymization/crypto.py:279: error: "Circuit" has no attribute "hop"; maybe "hops"? [attr-defined]
ipv8/messaging/anonymization/crypto.py:279: error: Argument 2 to "Hop" has incompatible type "SessionKeys"; expected "Optional[list[int]]" [arg-type]
ipv8/messaging/anonymization/crypto.py:295: error: "Hop" has no attribute "keys" [attr-defined]
ipv8/messaging/anonymization/crypto.py:300: error: "Hop" has no attribute "keys" [attr-defined]
ipv8/messaging/anonymization/crypto.py:315: error: "Hop" has no attribute "keys" [attr-defined]
ipv8/messaging/anonymization/crypto.py:320: error: "Hop" has no attribute "keys" [attr-defined]
Found 26 errors in 6 files (checked 233 source files)
This will fail every PR that is introduced on IPv8: high priority. Not quite a network-wide catastrophe but still very bad.
qstokkink commented
Actually, these might not be type inconsistencies at all:
ipv8/messaging/anonymization/crypto.py:19: error: Module "ipv8.messaging.anonymization.tunnel" has no attribute "BACKWARD" [attr-defined]
ipv8/messaging/anonymization/crypto.py:19: error: Module "ipv8.messaging.anonymization.tunnel" has no attribute "FORWARD" [attr-defined]
These attributes are defined in tunnel
.
qstokkink commented
I forced a workspace clear before running, now we have less inconsistencies:
ipv8/REST/base_endpoint.py:35: error: Argument "middlewares" to "Application" has incompatible type "Iterable[Union[Callable[[Request, Callable[[Request], Awaitable[StreamResponse]]], Awaitable[StreamResponse]], Callable[[Application, Callable[[Request], Awaitable[StreamResponse]]], Awaitable[Callable[[Request], Awaitable[StreamResponse]]]]]]"; expected "Iterable[Callable[[Request, Callable[[Request], Awaitable[StreamResponse]]], Awaitable[StreamResponse]]]" [arg-type]
ipv8/messaging/anonymization/tunnel.py:645: error: Argument 1 to "sum" has incompatible type "list[Union[list[IntroductionPoint], BaseException]]"; expected "Iterable[list[Union[list[IntroductionPoint], BaseException]]]" [arg-type]
ipv8/messaging/anonymization/tunnel.py:646: error: Argument 1 to "on_success" has incompatible type "list[Union[list[IntroductionPoint], BaseException]]"; expected "list[IntroductionPoint]" [arg-type]
ipv8/dht/community.py:640: error: Incompatible types in assignment (expression has type "list[Union[list[Node], list[tuple[bytes, Optional[bytes]]], tuple[list[tuple[bytes, Optional[bytes]]], Crawl]]]", variable has type "Union[list[list[Node]], list[list[tuple[bytes, Optional[bytes]]]], list[tuple[list[tuple[bytes, Optional[bytes]]], Crawl]]]") [assignment]
ipv8/messaging/anonymization/hidden_services.py:175: error: List comprehension has incompatible type List[Union[list[IntroductionPoint], None, BaseException]]; expected List[Optional[IntroductionPoint]] [misc]
Found 5 errors in 4 files (checked 231 source files)
qstokkink commented
I can verify the above locally: these are actual inconsistencies.