Closed
Description
Feature
The typing
module needs to be updated to 3.12. It seems that it was last updated to 3.9, so it's missing several major versions worth of features, like Unpack, generics, and type aliases using the type
keyword.
Not having these typing features impedes the process of updating modules that use, which presumably will be most new stuff going forward.
I estimate that updating will require:
- Moving some abstract base classes from
typing.py
into a new native moduletyping.rs
, specificallyTypeVar
,ParamSpec
,TypeVarTuple
,ParamSpecArgs
,ParamSpecKwards
,TypeAliasType
, andGeneric
. Adding new syntax likeIt seems like this is already included in https://github.com/RustPython/Parser/blob/main/parser/src/python.lalrpoptype
type aliases and generics to the parser.- Adding new instructions which generate/consume type information to
compiler.rs
andframe.rs
. For example,def foo[T](x: T): ...
must create a newTypeVar(T)
and inject it into the correct scope so that it is available as an argument annotation. This requires a new instruction defined inbytecode.rs
which is emitted bycompiler.rs
and consumed byframe.rs
. - Copying
typing.py
andtest_typing.py
from the CPython code base.