From fa4debc01e9f68c2c544187c3215a777a430ecd9 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Thu, 19 Oct 2023 17:02:29 -0600 Subject: [PATCH] refactor: remove custom cached_property we are only supporting 3.8 going forward --- netsuite/client.py | 2 +- netsuite/rest_api.py | 2 +- netsuite/rest_api_base.py | 2 +- netsuite/restlet.py | 2 +- netsuite/util.py | 28 ---------------------------- 5 files changed, 4 insertions(+), 32 deletions(-) delete mode 100644 netsuite/util.py diff --git a/netsuite/client.py b/netsuite/client.py index 598e87f..6efa4d4 100644 --- a/netsuite/client.py +++ b/netsuite/client.py @@ -4,7 +4,7 @@ from .rest_api import NetSuiteRestApi from .restlet import NetSuiteRestlet from .soap_api import NetSuiteSoapApi -from .util import cached_property +from functools import cached_property __all__ = ("NetSuite",) diff --git a/netsuite/rest_api.py b/netsuite/rest_api.py index 680647d..affdfe4 100644 --- a/netsuite/rest_api.py +++ b/netsuite/rest_api.py @@ -3,7 +3,7 @@ from . import rest_api_base from .config import Config -from .util import cached_property +from functools import cached_property logger = logging.getLogger(__name__) diff --git a/netsuite/rest_api_base.py b/netsuite/rest_api_base.py index a54f7bc..cbcadfe 100644 --- a/netsuite/rest_api_base.py +++ b/netsuite/rest_api_base.py @@ -9,7 +9,7 @@ from . import json from .exceptions import NetsuiteAPIRequestError, NetsuiteAPIResponseParsingError -from .util import cached_property +from functools import cached_property __all__ = ("RestApiBase",) diff --git a/netsuite/restlet.py b/netsuite/restlet.py index 0533ea2..ef5a330 100644 --- a/netsuite/restlet.py +++ b/netsuite/restlet.py @@ -2,7 +2,7 @@ from . import rest_api_base from .config import Config -from .util import cached_property +from functools import cached_property logger = logging.getLogger(__name__) diff --git a/netsuite/util.py b/netsuite/util.py deleted file mode 100644 index 437592a..0000000 --- a/netsuite/util.py +++ /dev/null @@ -1,28 +0,0 @@ -__all__ = ("cached_property",) - - -try: - from functools import cached_property # Python 3.8+ -except ImportError: - - class cached_property: # type: ignore[no-redef] - """Decorator that turns an instance method into a cached property - From https://speakerdeck.com/u/mitsuhiko/p/didntknow, slide #69 - """ - - __NOT_SET = object() - - def __init__(self, func): - self.func = func - self.__name__ = func.__name__ - self.__doc__ = func.__doc__ - self.__module__ = func.__module__ - - def __get__(self, obj, type=None): - if obj is None: - return self - value = obj.__dict__.get(self.__name__, self.__NOT_SET) - if value is self.__NOT_SET: - value = self.func(obj) - obj.__dict__[self.__name__] = value - return value