Skip to content

Commit

Permalink
Fixed @TypeChecked returning None in certain circumstances
Browse files Browse the repository at this point in the history
Fixes #103.
  • Loading branch information
agronholm committed Dec 25, 2019
1 parent 1faec9d commit 47a2f5c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/versionhistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Version history

This library adheres to `Semantic Versioning 2.0 <https://semver.org/#semantic-versioning-200>`_.

**UNRELEASED**

- Fixed ``@typechecked`` returning ``None`` when called with ``always=True`` and Python runs in
optimized mode

**2.7.0** (2019-12-10)

- Added support for ``typing.Protocol`` subclasses
Expand Down
6 changes: 3 additions & 3 deletions typeguard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,12 +774,12 @@ class with this decorator.
:param always: ``True`` to enable type checks even in optimized mode
"""
if not __debug__ and not always: # pragma: no cover
return func

if func is None:
return partial(typechecked, always=always, _localns=_localns)

if not __debug__ and not always: # pragma: no cover
return func

if isclass(func):
prefix = func.__qualname__ + '.'
for key, attr in func.__dict__.items():
Expand Down

0 comments on commit 47a2f5c

Please sign in to comment.