JSAbrahams / mamba

🐍 The Mamba programming language, because we care about safety
MIT License
88 stars 4 forks source link

Cannot create type alias with primitives #324

Closed JSAbrahams closed 2 years ago

JSAbrahams commented 2 years ago

Description of Bug

Cannot create type alias with primitives.

How to Reproduce

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.

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:

from typing import NewType

MyGeneric = NewType('MyGeneric', str)

This is a more safe way to generate type aliases.