Skip to content

Commit

Permalink
Fixed forward references in TypedDict not being resolved
Browse files Browse the repository at this point in the history
Fixes #130.
  • Loading branch information
agronholm committed Jun 3, 2020
1 parent eda2c32 commit a298151
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/versionhistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This library adheres to `Semantic Versioning 2.0 <https://semver.org/#semantic-v
**UNRELEASED**

- Added support for ``typing.NoReturn``
- Fixed forward references in ``TypedDict`` not being resolved

**2.8.0** (2020-06-02)

Expand Down
2 changes: 2 additions & 0 deletions tests/test_typeguard_py38.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Literal, TypedDict, Union

import pytest
Expand Down
2 changes: 1 addition & 1 deletion typeguard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def check_typed_dict(argname: str, value, expected_type, memo: Optional[_CallMem
keys_formatted = ', '.join('"{}"'.format(key) for key in sorted(missing_keys))
raise TypeError('required key(s) ({}) missing from {}'.format(keys_formatted, argname))

for key, argtype in expected_type.__annotations__.items():
for key, argtype in get_type_hints(expected_type).items():
argvalue = value.get(key, _missing)
if argvalue is not _missing:
check_type('dict item "{}" for {}'.format(key, argname), argvalue, argtype)
Expand Down

0 comments on commit a298151

Please sign in to comment.