Contents

runtype 0.5.1

0

Type dispatch and validation for run-time Python

Type dispatch and validation for run-time Python

Stars: 161, Watchers: 161, Forks: 2, Open Issues: 1

The erezsh/runtype repo was created 4 years ago and the last code push was 4 weeks ago.
The project is popular with 161 github stars!

How to Install runtype

You can install runtype using pip

pip install runtype

or add it to a project with poetry

poetry add runtype

Package Details

Author
Erez Shinan
License
MIT
Homepage
https://github.com/erezsh/runtype
PyPi:
https://pypi.org/project/runtype/
GitHub Repo:
https://github.com/erezsh/runtype

Classifiers

  • Software Development/Libraries/Python Modules
  • Software Development/Quality Assurance
  • Utilities
No  runtype  pypi packages just yet.

Errors

A list of common runtype errors.

Code Examples

Here are some runtype code examples and snippets.

GitHub Issues

The runtype package has 1 open issues on GitHub

  • No support for type Literal error when using typing_extensions >= 4.6.0
  • Refactor base_types to use dispatch (WIP)

See more issues on GitHub

Related Packages & Articles

pydantic-gen generates pydantic schemas from YAML files

pydantic-gen is a code generation python package that takes a YML file containing a OpenAPI Schema and generates python pydantic models. pydantic-gen can get used in your codebase to dynamically regenerate your pydantic models or it can be used one time to generator python code. The author of the pydantic-gen module is Mikhail Beliansky.

typing - Support for type hints

This module provides runtime support for type hints as specified by PEP 484, PEP 526, PEP 544, PEP 586, PEP 589, PEP 591, PEP 612 and PEP 613. The most fundamental support consists of the types Any, Union, Tuple, Callable, TypeVar, and Generic. For full specification please see PEP 484. For a simplified introduction to type hints see PEP 483.

import typing

# preferred
from typing import Dict, List, Union, Any

myvar: Dict = {}
# non-preferred
import typing

myvar: typing.Dict = {}

Code examples


from typing import Mapping, Dict, Any, Union

example1: Dict = {}

example2: Dict[str, Any]

example2: Mapping[str, int]

example3: Union[Dict[str, int], None]

example4: Union[str, None]

def hello(name: str) -> str:
    return f"Hello {name}"

Reference