_______________________________________________I'm beginning implementation work for PEP 585. I've got a little pure Python class that I'll use to guide me. (See attached proxy.py.) Then I'll start the work, roughly like this:
- Create a cpython fork (gvanrossum/pep585 where to do the work).
- Write a simple _Py_Class_GetItem(origin, parameters) function that just returns origin (after INCREF).
- Add that function to list, tuple and dict to show it works.
- Write some tests.
- Write a simple Proxy object to hold origin and parameters and return it from _Py_Class_GetItem.
- Update tests.
- Add __repr__ implementation and getattr forwarding functionality.
- Update tests.
- Deploy more widely to other builtin classes (set, frozenset, type).
- Update tests.
- Add specific methods that are supposed to fail (__class_getitem__, __instancecheck__, __subclasscheck__).
- Update tests.
At this point we're ready to start using the proxy class in typing.py, instead of the current implementation of _GenericAlias. We'll need to debate whether all the error checks we currently have in typing.py we *really* need to keep (usually these will also be detected by running a static type checker, so there's little harm in allowing nonsense like `list[1, 2, 3]`). Alternatively I'll need volunteers to implement those checks.I expect the implementation work to result in proposed improvements to PEP 585. (I already have some -- I don't think `isinstance(x, list[int])` should work, and I don't think we should strive for `list[int] == list`.)
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/