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
The reason is that collapse_addresses uses the type variable _N whereas ip_network returns Union[IPv4Network, IPv6network]
The both type hint definitions look reasonable. But unfortunately it will cause error messages when using mypy because _N is not the same as Union[IPv4Network, IPv6Network].
I was briefly running this through my head:
Changing collapse_addresses to use "Union" as well could cause false negatives for iterables of mixed types.
Changing ip_network to return _N might wreak havoc on existing code-bases
Replacing _N with two overloaded type-hints for collapse_addresses might work?
I'm not quite sure how to address this. It might even make sense to not change this at all and force users of the ipaddress to address this on the "client-side"?
I'm willing to open a PR and test it against my existing code-base which uses ipaddress quite heavily and I am in the process of adding type-hints. But I first wanted to get some feedback as to which course of action was appropriate.
The text was updated successfully, but these errors were encountered:
The following script will not type-check, but it should:
The reason is that
collapse_addresses
uses the type variable_N
whereasip_network
returnsUnion[IPv4Network, IPv6network]
The both type hint definitions look reasonable. But unfortunately it will cause error messages when using
mypy
because_N
is not the same asUnion[IPv4Network, IPv6Network]
.I was briefly running this through my head:
collapse_addresses
to use "Union" as well could cause false negatives for iterables of mixed types.ip_network
to return_N
might wreak havoc on existing code-bases_N
with two overloaded type-hints forcollapse_addresses
might work?I'm not quite sure how to address this. It might even make sense to not change this at all and force users of the
ipaddress
to address this on the "client-side"?I'm willing to open a PR and test it against my existing code-base which uses
ipaddress
quite heavily and I am in the process of adding type-hints. But I first wanted to get some feedback as to which course of action was appropriate.The text was updated successfully, but these errors were encountered: