Skip to content

Commit 5760456

Browse files
author
Scott Sanderson
authored
Merge pull request #8 from llllllllll/fix-default
BUG: actually allow people to override defaults
2 parents 489008b + cd8f288 commit 5760456

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

interface/tests/test_interface.py

+16
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,22 @@ def method2(self):
527527
assert C().has_default() == 3
528528

529529

530+
def test_override_default():
531+
532+
class IFace(Interface): # pragma: nocover
533+
534+
@default
535+
def default(self):
536+
return 'ayy'
537+
538+
class C(implements(IFace)): # pragma: nocover
539+
540+
def default(self):
541+
return 'lmao'
542+
543+
assert C().default() == 'lmao'
544+
545+
530546
def test_conflicting_defaults():
531547

532548
class IFace1(Interface): # pragma: nocover

interface/typed_signature.py

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class TypedSignature(object):
2121
"""
2222
def __init__(self, obj):
2323
self._type = type(obj)
24+
if self._type is default:
25+
self._type = type(obj.implementation)
26+
2427
self._signature = signature(extract_func(obj))
2528

2629
@property

0 commit comments

Comments
 (0)