Skip to content

Commit

Permalink
Raise deprecation warning only when attribute is accessed
Browse files Browse the repository at this point in the history
  • Loading branch information
cedk committed Jun 8, 2024
1 parent 81f2b2b commit 20dcfba
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions braintree/dispute.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
from braintree.dispute_details import DisputeEvidence, DisputeStatusHistory, DisputePayPalMessage
from braintree.configuration import Configuration

class Dispute(AttributeGetter):

class _DisputeType(type):
@property
def ChargebackProtectionLevel(cls):
warnings.warn("Use ProtectionLevel enum instead", DeprecationWarning)
return cls._ChargebackProtectionLevel


class Dispute(AttributeGetter, metaclass=_DisputeType):
# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
class Status(object):
"""
Expand Down Expand Up @@ -72,19 +80,22 @@ class Kind(object):
Retrieval = "retrieval"

# NEXT_MAJOR_VERSION Remove this enum
class ChargebackProtectionLevel(object):
class _ChargebackProtectionLevel(object):
"""
Constants representing dispute ChargebackProtectionLevel. Available types are:
* braintree.Dispute.ChargebackProtectionLevel.EFFORTLESS
* braintree.Dispute.ChargebackProtectionLevel.STANDARD
* braintree.Dispute.ChargebackProtectionLevel.NOT_PROTECTED
"""
warnings.warn("Use ProtectionLevel enum instead", DeprecationWarning)
Effortless = "effortless"
Standard = "standard"
NotProtected = "not_protected"

@property
def ChargebackProtectionLevel(self):
return self.__class__.ChargebackProtectionLevel

# NEXT_MAJOR_VERSION this can be an enum! they were added as of python 3.4 and we support 3.5+
class PreDisputeProgram(object):
"""
Expand Down

0 comments on commit 20dcfba

Please sign in to comment.