Skip to content
Snippets Groups Projects

Name literals

Merged Frans Skarman requested to merge name_literals into master
b_asic/types.py 0 → 100644
+ 20
0
from typing import NewType
# https://stackoverflow.com/questions/69334475/how-to-hint-at-number-types-i-e-subclasses-of-number-not-numbers-themselv
Num = int | float | complex
Name = str
# # We want to be able to initialize Name with String literals, but still have the
# # benefit of static type checking that we don't pass non-names to name locations.
# # However, until python 3.11 a string literal type was not available. In those versions,
# # we'll fall back on just aliasing `str` => Name.
# if sys.version_info >= (3, 11):
# from typing import LiteralString
# Name: TypeAlias = NewType("Name", str) | LiteralString
# else:
# Name = str
TypeName = NewType("TypeName", str)
GraphID = NewType("GraphID", str)
GraphIDNumber = NewType("GraphIDNumber", int)
Loading