Changelogs » Typeguard



- Fixed ``typechecked`` returning ``None`` when called with ``always=True`` and Python runs in
optimized mode
- Fixed performance regression introduced in v2.7.0 (the ``getattr_static()`` call was causing a 3x


- Added support for ``typing.Protocol`` subclasses
- Added support for ``typing.AbstractSet``
- Fixed the handling of ``total=False`` in ``TypedDict``
- Fixed no error reported on unknown keys with ``TypedDict``
- Removed support of default values in ``TypedDict``, as they are not supported in the spec


- Fixed import errors when using the import hook and trying to import a module that has both a
module docstring and ``__future__`` imports in it
- Fixed ``AttributeError`` when using ``typechecked`` on a metaclass
- Fixed ``typechecked`` compatibility with built-in function wrappers
- Fixed type checking generator wrappers not being recognized as generators
- Fixed resolution of forward references in certain cases (inner classes, function-local classes)
- Fixed ``AttributeError`` when a class has contains a variable that is an instance of a class
that has a ``__call__()`` method
- Fixed class methods and static methods being wrapped incorrectly when ``typechecked`` is applied
to the class
- Fixed ``AttributeError`` when ``typechecked`` is applied to a function that has been decorated
with a decorator that does not properly wrap the original (PR by Joel Beach)
- Fixed collections with mixed value (or key) types raising ``TypeError`` on Python 3.7+ when
matched against unparametrized annotations from the ``typing`` module
- Fixed inadvertent ``TypeError`` when checking against a type variable that has constraints or
a bound type expressed as a forward reference


- Added a :pep:`302` import hook for annotating functions and classes with ``typechecked``
- Added a pytest plugin that activates the import hook
- Added support for ``typing.TypedDict``
- Deprecated ``TypeChecker`` (will be removed in v3.0)


- Fixed incompatibility between annotated ``Iterable``, ``Iterator``, ``AsyncIterable`` or
``AsyncIterator`` return types and generator/async generator functions
- Fixed ``TypeError`` being wrapped inside another TypeError (PR by russok)


- Added yield type checking via ``TypeChecker`` for regular generators
- Added yield, send and return type checking via ``typechecked`` for regular and async generators
- Silenced ``TypeChecker`` warnings about async generators
- Fixed bogus ``TypeError`` on ``Type[Any]``
- Fixed bogus ``TypeChecker`` warnings when an exception is raised from a type checked function
- Accept a ``bytearray`` where ``bytes`` are expected, as per `python/typing552`_
- Added policies for dealing with unmatched forward references
- Added support for using ``typechecked`` as a class decorator
- Added ``check_return_type()`` to accompany ``check_argument_types()``
- Added Sphinx documentation

.. _python/typing552:


- Fixed broken packaging configuration


- Added :pep:`561` support
- Added support for empty tuples (``Tuple[()]``)
- Added support for ``typing.Literal``
- Make getting the caller frame faster (PR by Nick Sweeting)


- Fixed thread safety issue with the type hints cache (PR by Kelsey Francis)


- Added support for ``typing.IO`` and derivatives
- Fixed return type checking for coroutine functions
- Dropped support for Python 3.4


- Fixed false positive when checking a callable against the plain ``typing.Callable`` on Python 3.7


- Argument type annotations are no longer unioned with the types of their default values, except in
the case of ``None`` as the default value (although PEP 484 still recommends against this)
- Fixed some generic types (``typing.Collection`` among others) producing false negatives on
Python 3.7
- Shortened unnecessarily long tracebacks by raising a new ``TypeError`` based on the old one
- Allowed type checking against arbitrary types by removing the requirement to supply a call memo
to ``check_type()``
- Fixed ``AttributeError`` when running with the pydev debugger extension installed
- Fixed getting type names on ``typing.*`` on Python 3.7 (fix by Dale Jung)


- Fixed compatibility with Python 3.7
- Removed support for Python 3.3
- Added support for ``typing.NewType`` (contributed by reinhrst)


- Removed support for backports.typing, as it has been removed from PyPI
- Fixed checking of the numeric tower (complex -> float -> int) according to PEP 484


- Fixed type checks against generic classes


- Fixed leak of function objects (should've used a ``WeakValueDictionary`` instead of
- Fixed obscure failure of TypeChecker when it's unable to find the function object
- Fixed parametrized ``Type`` not working with type variables
- Fixed type checks against variable positional and keyword arguments


- Fixed formatting of README.rst so it renders properly on PyPI


- Added support for ``typings.Type`` (available in Python 3.5.2+)
- Added a third, ``sys.setprofile()`` based type checking approach (``typeguard.TypeChecker``)
- Changed certain type error messages to display "function" instead of the function's qualified


- More Python 3.6 compatibility fixes (along with a broader test suite)


- Fixed additional Python 3.6 compatibility issues


- **BACKWARD INCOMPATIBLE** Dropped Python 3.2 support
- Fixed incompatibility with Python 3.6
- Use ``inspect.signature()`` in place of ``inspect.getfullargspec``
- Added support for ``typing.NamedTuple``


- Fixed ``typechecked`` skipping the check of return value type when the type annotation was


- Fixed checking of homogenous Tuple declarations (``Tuple[bool, ...]``)


- Use ``backports.typing`` when possible to get new features on older Pythons
- Fixed incompatibility with Python 3.5.2


- Fixed argument counting when a class is checked against a Callable specification
- Fixed argument counting when a functools.partial object is checked against a Callable
- Added checks against mandatory keyword-only arguments when checking against a Callable


- Gracefully exit if ``check_type_arguments`` can't find a reference to the current function


- Fixed TypeError when checking a builtin function against a parametrized Callable


- Fixed improper argument counting with bound methods when typechecking callables


- Eliminated the need to pass a reference to the currently executing function to


- Fixed types of default argument values not being considered as valid for the argument


- Fixed type hints retrieval being done for the wrong callable in cases where the callable was
wrapped with one or more decorators


- Initial release