trycast
trycast copied to clipboard
trycast parses JSON-like values whose shape is defined by TypedDicts and other standard Python type hints.
`eval_type_str` is an internal function of the trycast module that is used to convert a stringified type annotation (like `"typing.List"`) to a type annotation object (like `typing.List`). ## Why expose?...
Python 3.11 added support for [generic TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). For example, the following generic TypedDict can (probably) be defined now: ``` T = TypeVar('T', bound=Union[int, float, complex]) class Point(TypedDict, Generic[T]): x: T...
Why: * This kind of TypedDict was introduced in the era of Python 3.7, which is [no longer supported by trycast](https://github.com/davidfstr/trycast/issues/21). * It is reasonable (in @davidfstr 's opinion) to...
Why: * It will be [end-of-life](https://endoflife.date/python). * Extra code is required to support this old Python version. Simultaneously: * https://github.com/davidfstr/trycast/issues/23
trycast is currently tested against pytype 2022.3.21, which supports Python 3.8-3.9. The latest version of pytype, 2024.04.11, [supports Python 3.8-3.11](https://github.com/google/pytype?tab=readme-ov-file#requirements) Please upgrade pytype to a more-modern version that includes Python...
In the test suite's `test_callable_p_r` you will see lines like: ``` # NOTE: Cannot introspect constructor for certain built-in types # TODO: Define __signature__ for failing internal types self.assertTryCastFailure(Callable[[], Any],...
The [TypeForm PEP](https://peps.python.org/pep-0747/) draft is nearly done (as of 2025-05-18) and should be implemented soon: * [ ] Alter signatures of public functions to accept `TypeForm` from `typing_extensions` or from...
Milestone: 2.0 * Probably only want to support recent Python versions at the time support for these typecheckers is added, so that probably implies this change should be shipped alongside...
The isassignable API is currently: ``` def isassignable( value: object, tp: TypeForm[T]† | TypeFormString[T]‡, /, *, eval: bool = True ) -> TypeGuard[T]: ... ``` Alter it to return a...