stenotype.backend package

Submodules

stenotype.backend.elements module

Steno Type Elements

Representations of the fundamental stenotype building blocks. Each element holds the relevant information for both a stenotype and typing conversion.

Note that all elements are represented as values, not types: A Steno encodes stenotype syntax/code, not any concrete types. For example, Identifier('typing', 'List') is not the type typing.List but represents the name typing.List.

class stenotype.backend.elements.Dots[source]

Bases: object

A literal ... placeholder

class stenotype.backend.elements.Identifier[source]

Bases: typing.Tuple

A qualified name, such as typing.Tuple

class stenotype.backend.elements.Generic[source]

Bases: tuple

A generic type, such as typing.List[int]

property base

Alias for field number 0

property parameters

Alias for field number 1

class stenotype.backend.elements.Any[source]

Bases: object

Any type as _, same as typing.Any

class stenotype.backend.elements.Optional[source]

Bases: tuple

Optional type as ?base, equivalent to typing.Optional[base]

property base

Alias for field number 0

class stenotype.backend.elements.Union[source]

Bases: typing.Tuple

Union of types as A or B, equivalent to typing.Union[A, B]

class stenotype.backend.elements.Tuple[source]

Bases: tuple

Typed tuple as (A, B, ...), equivalent to typing.Tuple[A, B, ...]

property elements

Alias for field number 0

class stenotype.backend.elements.List[source]

Bases: tuple

Typed list as [values], equivalent to typing.List[values]

property values

Alias for field number 0

class stenotype.backend.elements.Dict[source]

Bases: tuple

Typed dict as {keys: values}, equivalent to typing.Dict[keys, values]

property keys

Alias for field number 0

property values

Alias for field number 1

class stenotype.backend.elements.Set[source]

Bases: tuple

Typed dict as {values}, equivalent to typing.Set[values]

property values

Alias for field number 0

class stenotype.backend.elements.Literal[source]

Bases: tuple

Literal value, not a type

property value

Alias for field number 0

class stenotype.backend.elements.Iterable[source]

Bases: tuple

Typed iterable as iter base, equivalent to typing.Iterable[base]

property base

Alias for field number 0

class stenotype.backend.elements.Context[source]

Bases: tuple

Typed context manager as with base

property base

Alias for field number 0

class stenotype.backend.elements.Awaitable[source]

Bases: tuple

Typed awaitable as await base, equivalent to typing.Awaitable[base]

property base

Alias for field number 0

class stenotype.backend.elements.AsyncIterable[source]

Bases: tuple

Typed async iterable as async iter base

property base

Alias for field number 0

class stenotype.backend.elements.AsyncContext[source]

Bases: tuple

Typed async context manager as async with base

property base

Alias for field number 0

class stenotype.backend.elements.Parameter[source]

Bases: tuple

Typed parameter of a call signature as name: base

property name

Alias for field number 0

property base

Alias for field number 1

class stenotype.backend.elements.Signature[source]

Bases: tuple

Typed signature as (p: P, /, m: M, *a: A, k: K, **kw: KW) -> R

property positional

B, /)``

Type

positional only parameters, e.g. ``(a

Type

A, b

property mixed

B)``

Type

positional or keyword parameters, e.g. ``(a

Type

A, b

property args

ARGS)``

Type

variadic positional parameters, e.g. ``(*args

property keywords

B)``

Type

keyword only parameters, e.g. ``(*, a

Type

A, b

property kwargs

KWARGS)``

Type

variadic keyword parameters, e.g. ``(**kwargs

property returns

return type, e.g. () -> R

class stenotype.backend.elements.Callable[source]

Bases: tuple

Typed positional signature as (A, B, /, C, D) -> R

property positional

Alias for field number 0

property returns

Alias for field number 1

stenotype.backend.elements.Steno = typing.Union[stenotype.backend.elements.Dots, stenotype.backend.elements.Identifier, stenotype.backend.elements.Any]

Any steno element

stenotype.backend.grammar module

Grammar for parsing stenotype strings to elements

stenotype.backend.grammar.parse(steno_string: str) → Union[stenotype.backend.elements.Dots, stenotype.backend.elements.Identifier, stenotype.backend.elements.Any][source]

Parse a stenotype or typing string to element representation

stenotype.backend.steno module

stenotype.backend.steno.unparse(element: Union[stenotype.backend.elements.Dots, stenotype.backend.elements.Identifier, stenotype.backend.elements.Any]) → str[source]

Unparse element representation to a stenotype string

stenotype.backend.steno.unparse_dots(element: stenotype.backend.elements.Dots) → str[source]
stenotype.backend.steno.unparse_identifier(element: stenotype.backend.elements.Identifier) → str[source]
stenotype.backend.steno.unparse_generic(element: stenotype.backend.elements.Generic) → str[source]
stenotype.backend.steno.unparse_callable(element: stenotype.backend.elements.Callable) → str[source]
stenotype.backend.steno.unparse_any(element: stenotype.backend.elements.Any) → str[source]
stenotype.backend.steno.unparse_optional(element: stenotype.backend.elements.Optional) → str[source]
stenotype.backend.steno.unparse_union(element: stenotype.backend.elements.Union) → str[source]
stenotype.backend.steno.unparse_tuple(element: stenotype.backend.elements.Tuple) → str[source]
stenotype.backend.steno.unparse_list(element: stenotype.backend.elements.List) → str[source]
stenotype.backend.steno.unparse_dict(element: stenotype.backend.elements.Dict) → str[source]
stenotype.backend.steno.unparse_set(element: stenotype.backend.elements.Set) → str[source]
stenotype.backend.steno.unparse_literal(element: stenotype.backend.elements.Literal) → str[source]
stenotype.backend.steno.unparse_shorthand(element: Union[stenotype.backend.elements.Iterable, stenotype.backend.elements.Context, stenotype.backend.elements.Awaitable, stenotype.backend.elements.AsyncIterable, stenotype.backend.elements.AsyncContext]) → str[source]

stenotype.backend.typing module

stenotype.backend.typing.normalize(element: Union[stenotype.backend.elements.Dots, stenotype.backend.elements.Identifier, stenotype.backend.elements.Any]) → Union[stenotype.backend.elements.Dots, stenotype.backend.elements.Identifier][source]

Normalize any element representation to the subset supported by typing

stenotype.backend.typing.normalize_identity(element: ID) → ID[source]
stenotype.backend.typing.normalize_generic(element: stenotype.backend.elements.Generic) → stenotype.backend.elements.Generic[source]
stenotype.backend.typing.normalize_callable(element: stenotype.backend.elements.Callable) → stenotype.backend.elements.Callable[source]
stenotype.backend.typing.normalize_any(element: stenotype.backend.elements.Any) → stenotype.backend.elements.Identifier[source]
stenotype.backend.typing.normalize_optional(element: stenotype.backend.elements.Optional) → stenotype.backend.elements.Generic[source]
stenotype.backend.typing.normalize_union(element: stenotype.backend.elements.Union) → stenotype.backend.elements.Generic[source]
stenotype.backend.typing.normalize_tuple(element: stenotype.backend.elements.Tuple) → stenotype.backend.elements.Generic[source]
stenotype.backend.typing.normalize_list(element: stenotype.backend.elements.List) → stenotype.backend.elements.Generic[source]
stenotype.backend.typing.normalize_dict(element: stenotype.backend.elements.Dict) → stenotype.backend.elements.Generic[source]
stenotype.backend.typing.normalize_set(element: stenotype.backend.elements.Set) → stenotype.backend.elements.Generic[source]
stenotype.backend.typing.normalize_literal(element: stenotype.backend.elements.Literal) → stenotype.backend.elements.Generic[source]
stenotype.backend.typing.normalize_shorthand(element: Union[stenotype.backend.elements.Iterable, stenotype.backend.elements.Context, stenotype.backend.elements.Awaitable, stenotype.backend.elements.AsyncIterable, stenotype.backend.elements.AsyncContext]) → stenotype.backend.elements.Generic[source]
stenotype.backend.typing.normalize_signature(element: stenotype.backend.elements.Signature)[source]