Skip to content

Commit 20beb4a

Browse files
committed
Add failing test reproducing #85.
1 parent de9caee commit 20beb4a

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

tests/issue_85_module.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from dataclasses import dataclass
2+
3+
4+
def forwardref_method(foo: "ForwardRef", bar: str) -> "ForwardRef":
5+
return foo.x + bar
6+
7+
8+
@dataclass
9+
class ForwardRef:
10+
x: str = "default"

tests/test_issues.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,19 @@ def test_issue_77_async_generator_partial():
253253
assert inspect.isasyncgenfunction(f_partial)
254254

255255
assert asyncio.get_event_loop().run_until_complete(asyncio.ensure_future(f_partial().__anext__())) == 1
256+
257+
258+
def test_issue_85_wrapped_forwardref_annotation():
259+
import typing
260+
from . import issue_85_module
261+
262+
@wraps(issue_85_module.forwardref_method, remove_args=["bar"])
263+
def decorated(*args, **kwargs):
264+
return issue_85_module.forwardref_method(*args, **kwargs, bar="x")
265+
266+
assert decorated(issue_85_module.ForwardRef()) == "defaultx"
267+
expected_annotations = {
268+
"foo": issue_85_module.ForwardRef,
269+
"return": issue_85_module.ForwardRef,
270+
}
271+
assert typing.get_type_hints(decorated) == expected_annotations

0 commit comments

Comments
 (0)