Skip to content

Commit 7c95496

Browse files
authored
Merge pull request #99 from moskupols/issue-98
Match type exactly when checking TYPES_WITH_SAFE_REPR
2 parents c1d189c + 26cc7aa commit 7c95496

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/makefun/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ def _signature_symbol_needs_protection(symbol, evaldict):
466466
:param symbol:
467467
:return:
468468
"""
469-
if symbol is not None and symbol is not Parameter.empty and not isinstance(symbol, TYPES_WITH_SAFE_REPR):
469+
if symbol is not None and symbol is not Parameter.empty and type(symbol) not in TYPES_WITH_SAFE_REPR:
470470
try:
471471
# check if the repr() of the default value is equal to itself.
472472
return eval(repr(symbol), evaldict) != symbol # noqa # we cannot use ast.literal_eval, too restrictive

tests/test_issues.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,19 @@ def test_issue_91():
280280
"""This test should work also in python 2 ! """
281281
assert is_identifier("_results_bag")
282282
assert is_identifier("hello__bag")
283+
284+
285+
def test_issue_98():
286+
class A(str):
287+
def __str__(self):
288+
return 'custom str'
289+
290+
def __repr__(self):
291+
return 'custom repr'
292+
293+
def foo(a=A()):
294+
pass
295+
296+
@wraps(foo)
297+
def test(*args, **kwargs):
298+
return foo(*args, **kwargs)

0 commit comments

Comments
 (0)