This repository was archived by the owner on Sep 12, 2024. It is now read-only.

Description
Describe the bug
To ensure that validation of attributes happens every time they're set, we should use @property getters/setters for attributes requiring validation.
To Reproduce
n/a
Expected behavior
Use @property getters/setters to validate instance attributes - e.g. here:
def __init__(self, client, order_id):
"""Instantiate an order change request creation."""
self._client = client
self._order_id = order_id
self._slices = []
OrderChangeRequestCreate._validate_order_id(self._order_id)
def _validate_order_id(order_id):
"""Set order ID"""
if type(order_id) is not str:
raise OrderChangeRequestCreate.InvalidOrderId(order_id)
can be changed to:
def __init__(self, client, order_id):
"""Instantiate an order change request creation."""
self.client = client
self.order_id = order_id
self.slices = []
@property
def order_id(self):
return self._order_id
@order_id.setter
def order_id(self, value):
if not isinstance(value, str):
raise OrderChangeRequestCreate.InvalidOrderId(value)
self._order_id = value
System (please complete the following information):
n/a
Additional context
Could also fix this issue at the same time!