CarliJoy / intersection_examples

Python Typing Intersection examples
MIT License
33 stars 2 forks source link

The collections section seems incorrect #13

Closed NeilGirdhar closed 1 year ago

NeilGirdhar commented 1 year ago

It reads:

The general idea that an attributes of intersected types become unions holds also for all kinds of collections.

dict[str, int] & dict[bytes, float] => dict[str|bytes, float|int]
list[str] & list[bytes] => list[str|bytes]
tuple[str, float] & tuple[bytes, int] => tuple[str|bytes, float|int]

I think it should be:

dict[str, int] & dict[bytes, float] => Never
list[str] & list[bytes] => Never
tuple[str, float] & tuple[bytes, int] => Never

I think the section should just be removed, or it should read that the rules follow from covariance/invariance/contravariance.

DiscordLiz commented 1 year ago

seems related to #6 It's the same interior union instead of intersection issue.

NeilGirdhar commented 1 year ago

I've removed the collection section