Hi Patrick,

I think you are on the right track. I don't think that anyone is working on this.

You probably need to find a collaborator who is well versed in one of the type checker implementations -- adding a new construct like this is not a simple task!

Regarding your questions:

- int&str probably can't be satisfied because it would require multiple inheritance from two different C types (the instance layouts are incompatible). But if you had two unrelated classes C1 and C2 defined with class statements in Python, multiple inheritance could produce a type that satisfies C1&C2. Mypy doesn't generally take constraints due to object layout into account, since in the type stubs int and str are also defined using class statements. So it will probably have to accept int&str, but no type you can construct will satisfy it -- it acts as an effective bottom type (has no instances).

- The example with two typeddicts could be satisfied by creating a third typed dict that has both fields. This works:

from typing import *

class A(TypedDict):
    x: int
   
class B(TypedDict):
    y: str

class AB(TypedDict):
    x: int
    y: str

def f(a: A): ...
def g(b: B): ...

ab: AB = {'x': 1, 'y': ''}
f(ab)
g(ab)



On Tue, Nov 16, 2021 at 3:48 PM Patrick Arminio <patrick.arminio@gmail.com> wrote:
Hi folks!

I'm sending this email because I'd love to work on introduction support for Intersection to python's typing capabilities.
I'd love to know if someone is already working on this and if not, I'd like to try and work on it, but I'd need some support if
possible ^^

I've sketched out a basic plan[0], basically the initial idea is to write an initial PEP based on the discussion[1] around typing.Intersection,
make a prototype implementation and then try to get feedback on the PEP and implementation.

Does that make sense? Would someone be able to help me with this?
And, again, if someone is already working on this, let me know, I'm ok with that too :D

[0] My rough plan and basic notes: https://hackmd.io/0ymmrUtGTG-CEiw32qVfiQ
[1] Issues regarding typing.Intersection: https://github.com/python/typing/issues/213
_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: guido@python.org


--
--Guido van Rossum (python.org/~guido)
Pronouns: he/him (why is my pronoun here?)