Closed JSAbrahams closed 2 years ago
Cannot create type alias with primitives.
class MyGeneric: String
Produces the following python code:
MyGeneric = str
Which python does not like, it then expect a :, not a =. This does work find though for other aliases.
:
=
It should create a valid type alias.
https://docs.python.org/3/library/typing.html#newtype
For instance, we would then have:
from typing import NewType MyGeneric = NewType('MyGeneric', str)
This is a more safe way to generate type aliases.
Description of Bug
Cannot create type alias with primitives.
How to Reproduce
Produces the following python code:
Which python does not like, it then expect a
:
, not a=
. This does work find though for other aliases.Expected behavior
It should create a valid type alias.
Additional context
https://docs.python.org/3/library/typing.html#newtype
For instance, we would then have:
This is a more safe way to generate type aliases.