diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..5464672 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include spgci/py.typed diff --git a/pyproject.toml b/pyproject.toml index 7d965ab..57dd42a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "spgci" -version = "0.0.50" +version = "0.0.51" description = "SPGCI is an API Client for the S&P Commodity Insights REST API" authors = ["S&P Global Commodity Insights "] license = "Apache-2.0" @@ -34,4 +34,4 @@ build-backend = "poetry.core.masonry.api" [tool.pytest.ini_options] markers = [ "integtest", -] \ No newline at end of file +] diff --git a/spgci/auth.py b/spgci/auth.py index a7ea6a3..6659c29 100644 --- a/spgci/auth.py +++ b/spgci/auth.py @@ -12,13 +12,30 @@ # See the License for the specific language governing permissions and # limitations under the License. -from functools import lru_cache + import spgci.config as config import requests from requests.exceptions import HTTPError, SSLError import warnings from tenacity import retry, retry_if_exception_type, wait_fixed from spgci.exceptions import AuthError, PerSecondLimitError, DailyLimitError +from typing import TYPE_CHECKING + + +if TYPE_CHECKING: + from collections.abc import Callable + from typing import TypeVar + + + _CachedFn = TypeVar("_CachedFn", bound=Callable) + + def lru_cache() -> Callable[[_CachedFn], _CachedFn]: + """Ensure that the type hints still work after calling the lru_cache decorator.""" + pass + +else: + from functools import lru_cache + _throttle_retry = retry( retry=retry_if_exception_type(PerSecondLimitError), reraise=True, wait=wait_fixed(1) diff --git a/spgci/py.typed b/spgci/py.typed new file mode 100644 index 0000000..e69de29