Skip to content

Commit bd5323e

Browse files
Match type exactly when checking TYPES_WITH_SAFE_REPR
This fixes #98
1 parent 525ce1f commit bd5323e

2 files changed

Lines changed: 15 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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,17 @@ 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+
from enum import StrEnum
287+
288+
class A(StrEnum):
289+
a = 'a'
290+
291+
def foo(a=A.a):
292+
pass
293+
294+
@wraps(foo)
295+
def test(*args, **kwargs):
296+
return foo(*args, **kwargs)

0 commit comments

Comments
 (0)