All Projects → ilevkivskyi → Typing_inspect

ilevkivskyi / Typing_inspect

Licence: mit
Runtime inspection utilities for Python typing module

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects
introspection
24 projects

Labels

Projects that are alternatives of or similar to Typing inspect

Falling Words Typing Game
This is the source code for a Falling Words Typing Game created in Unity during a Twitch Livestream.
Stars: ✭ 31 (-83.94%)
Mutual labels:  typing
Norman
Norman keyboard layout - alternative to QWERTY for touch typing in English
Stars: ✭ 112 (-41.97%)
Mutual labels:  typing
Turingtype
⌨️ Simple human typing effect
Stars: ✭ 137 (-29.02%)
Mutual labels:  typing
Typical
Animated typing in ~400 bytes 🐡 of JavaScript
Stars: ✭ 986 (+410.88%)
Mutual labels:  typing
Typical
Typical: Fast, simple, & correct data-validation using Python 3 typing.
Stars: ✭ 111 (-42.49%)
Mutual labels:  typing
Typedload
Python library to load dynamically typed data into statically typed data structures
Stars: ✭ 120 (-37.82%)
Mutual labels:  typing
Typet
Types that make coding in Python quick and safe.
Stars: ✭ 15 (-92.23%)
Mutual labels:  typing
Tinytyper
⌨️ A tiny library for creating a typing effect on specified text element.
Stars: ✭ 173 (-10.36%)
Mutual labels:  typing
Typer
A JavaScript typing library with sexy syntax and diddly dependencies.
Stars: ✭ 111 (-42.49%)
Mutual labels:  typing
Typescript Vs Flowtype
Differences between Flowtype and TypeScript -- syntax and usability
Stars: ✭ 1,671 (+765.8%)
Mutual labels:  typing
Vscode Smoothtype
VS Code extension to add cursor transitions while typing, similar to MS Office and the Windows 10 Mail app.
Stars: ✭ 54 (-72.02%)
Mutual labels:  typing
Ducky
Duck-Typed Value Handling for JavaScript
Stars: ✭ 71 (-63.21%)
Mutual labels:  typing
Tt
A terminal based typing test.
Stars: ✭ 125 (-35.23%)
Mutual labels:  typing
Mob Suite
MOB-suite: Software tools for clustering, reconstruction and typing of plasmids from draft assemblies
Stars: ✭ 32 (-83.42%)
Mutual labels:  typing
Ghosttypewriter
👻 A UILabel subclass that adds a typewriting animation effect
Stars: ✭ 159 (-17.62%)
Mutual labels:  typing
Keystroke dynamics
a keystroke dynamics algorithm in python (recognizes a person by the way s/he types)
Stars: ✭ 21 (-89.12%)
Mutual labels:  typing
Dataclass factory
Modern way to convert python dataclasses or other objects to and from more common types like dicts or json-like structures
Stars: ✭ 116 (-39.9%)
Mutual labels:  typing
Typeshed
Typeshed contains external type annotations for the Python standard library and Python builtins, as well as third party packages as contributed by people external to those projects.
Stars: ✭ 2,501 (+1195.85%)
Mutual labels:  typing
Supertextview
🎀 SuperTextView for Android 是一个在TextView的基础上扩展了几种动画效果的控件。
Stars: ✭ 165 (-14.51%)
Mutual labels:  typing
Mypy
Optional static typing for Python
Stars: ✭ 11,995 (+6115.03%)
Mutual labels:  typing

Typing Inspect

Build Status

The typing_inspect module defines experimental API for runtime inspection of types defined in the Python standard typing module. Works with typing version 3.7.4 and later. Example usage:

from typing import Generic, TypeVar, Iterable, Mapping, Union
from typing_inspect import is_generic_type

T = TypeVar('T')

class MyCollection(Generic[T]):
    content: T

assert is_generic_type(Mapping)
assert is_generic_type(Iterable[int])
assert is_generic_type(MyCollection[T])

assert not is_generic_type(int)
assert not is_generic_type(Union[int, T])

Note: The API is still experimental, if you have ideas/suggestions please open an issue on tracker. Currently typing_inspect only supports latest version of typing. This limitation may be lifted if such requests will appear frequently.

Currently provided functions (see functions docstrings for examples of usage):

  • is_generic_type(tp): Test if tp is a generic type. This includes Generic itself, but excludes special typing constructs such as Union, Tuple, Callable, ClassVar.
  • is_callable_type(tp): Test tp is a generic callable type, including subclasses excluding non-generic types and callables.
  • is_tuple_type(tp): Test if tp is a generic tuple type, including subclasses excluding non-generic classes.
  • is_union_type(tp): Test if tp is a union type.
  • is_optional_type(tp): Test if tp is an optional type (either type(None) or a direct union to it such as in Optional[int]). Nesting and TypeVars are not unfolded/inspected in this process.
  • is_literal_type(tp): Test if tp is a literal type.
  • is_final_type(tp): Test if tp is a final type.
  • is_typevar(tp): Test if tp represents a type variable.
  • is_new_type(tp): Test if tp represents a distinct type.
  • is_classvar(tp): Test if tp represents a class variable.
  • get_origin(tp): Get the unsubscripted version of tp. Supports generic types, Union, Callable, and Tuple. Returns None for unsupported types.
  • get_last_origin(tp): Get the last base of (multiply) subscripted type tp. Supports generic types, Union, Callable, and Tuple. Returns None for unsupported types.
  • get_parameters(tp): Return type parameters of a parameterizable type tp as a tuple in lexicographic order. Parameterizable types are generic types, unions, tuple types and callable types.
  • get_args(tp, evaluate=False): Get type arguments of tp with all substitutions performed. For unions, basic simplifications used by Union constructor are performed. If evaluate is False (default), report result as nested tuple, this matches the internal representation of types. If evaluate is True, then all type parameters are applied (this could be time and memory expensive).
  • get_last_args(tp): Get last arguments of (multiply) subscripted type tp. Parameters for Callable are flattened.
  • get_generic_type(obj): Get the generic type of obj if possible, or its runtime class otherwise.
  • get_generic_bases(tp): Get generic base types of tp or empty tuple if not possible.
  • typed_dict_keys(td): Get TypedDict keys and their types, or None if td is not a typed dict.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].