Skip to main content

Type system extensions for use with the pyre type checker

Project description

Pyre Extensions

This module defines extensions to the standard “typing” module that are supported by the Pyre typechecker.

none_throws

Function to make assumptions about Optionals explicit. The function will raise an assertion error if passed None and return the value otherwise.

ParameterSpecification

ParameterSpecifications are a special kind of type variable that captures callable parameter specifications (known as argspecs in the runtime and inspect library) instead of types, allowing the typing of decorators which transform the return type of the given callable.
For example:

from typing import TypeVar, Callable, List
from pyre_extensions import ParameterSpecification
Tparams = ParameterSpecification("Tparams")
Treturn = TypeVar("Treturn")
def unwrap(f: Callable[Tparams, List[Treturn]) -> Callable[Tparams, Treturn]: ...
@unwrap
def foo(x: int, y: str, z: bool = False) -> List[int]:
    return [1, 2, 3]

decorates foo into a callable that returns int, but still has the same parameters, including their names and whether they are required.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyre-extensions-0.0.15.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

pyre_extensions-0.0.15-py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page