Skip to content

Commit 20dcfba

Browse files
committed
Raise deprecation warning only when attribute is accessed
Fixes braintree#148
1 parent 81f2b2b commit 20dcfba

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

braintree/dispute.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55
from braintree.dispute_details import DisputeEvidence, DisputeStatusHistory, DisputePayPalMessage
66
from braintree.configuration import Configuration
77

8-
class Dispute(AttributeGetter):
8+
9+
class _DisputeType(type):
10+
@property
11+
def ChargebackProtectionLevel(cls):
12+
warnings.warn("Use ProtectionLevel enum instead", DeprecationWarning)
13+
return cls._ChargebackProtectionLevel
14+
15+
16+
class Dispute(AttributeGetter, metaclass=_DisputeType):
917
# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
1018
class Status(object):
1119
"""
@@ -72,19 +80,22 @@ class Kind(object):
7280
Retrieval = "retrieval"
7381

7482
# NEXT_MAJOR_VERSION Remove this enum
75-
class ChargebackProtectionLevel(object):
83+
class _ChargebackProtectionLevel(object):
7684
"""
7785
Constants representing dispute ChargebackProtectionLevel. Available types are:
7886
7987
* braintree.Dispute.ChargebackProtectionLevel.EFFORTLESS
8088
* braintree.Dispute.ChargebackProtectionLevel.STANDARD
8189
* braintree.Dispute.ChargebackProtectionLevel.NOT_PROTECTED
8290
"""
83-
warnings.warn("Use ProtectionLevel enum instead", DeprecationWarning)
8491
Effortless = "effortless"
8592
Standard = "standard"
8693
NotProtected = "not_protected"
8794

95+
@property
96+
def ChargebackProtectionLevel(self):
97+
return self.__class__.ChargebackProtectionLevel
98+
8899
# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
89100
class PreDisputeProgram(object):
90101
"""

0 commit comments

Comments
 (0)