From c59d2c66efd6c1b40d763f93d072116fd5ef0ffc Mon Sep 17 00:00:00 2001 From: achristie Date: Mon, 19 Aug 2024 11:42:01 -0400 Subject: [PATCH] remove urllib dep, fix bug in mdd --- poetry.lock | 17 +++++++++-------- pyproject.toml | 1 - spgci/config.py | 2 +- spgci/market_data.py | 3 ++- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/poetry.lock b/poetry.lock index 42027cc..b85c3f3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2306,19 +2306,20 @@ dev = ["flake8", "flake8-annotations", "flake8-bandit", "flake8-bugbear", "flake [[package]] name = "urllib3" -version = "1.26.15" +version = "2.2.2" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" +python-versions = ">=3.8" files = [ - {file = "urllib3-1.26.15-py2.py3-none-any.whl", hash = "sha256:aa751d169e23c7479ce47a0cb0da579e3ede798f994f5816a74e4f4500dcea42"}, - {file = "urllib3-1.26.15.tar.gz", hash = "sha256:8a388717b9476f934a21484e8c8e61875ab60644d29b9b39e11e4b9dc1c6b305"}, + {file = "urllib3-2.2.2-py3-none-any.whl", hash = "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472"}, + {file = "urllib3-2.2.2.tar.gz", hash = "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168"}, ] [package.extras] -brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"] -secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)", "urllib3-secure-extra"] -socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] +brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] +h2 = ["h2 (>=4,<5)"] +socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] +zstd = ["zstandard (>=0.18.0)"] [[package]] name = "wcwidth" @@ -2391,4 +2392,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", [metadata] lock-version = "2.0" python-versions = "^3.9.0" -content-hash = "7322eaf00ab1a848b459141f88fb4e41c6fa6bb4ed53ae083764890ff6cdbb8e" +content-hash = "119b9d489d7da9d6b5724eb83c334c955ca2f2baa8452e5afddc4d4606ea5e16" diff --git a/pyproject.toml b/pyproject.toml index b850ad1..bda7fde 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,6 @@ requests = "^2.27.1" tqdm = "^4.64.1" typing-extensions = "^4.4.0" tenacity = "^8.2.2" -urllib3 = "^1.26.15" packaging = "^24.1" diff --git a/spgci/config.py b/spgci/config.py index bd68db9..b280455 100644 --- a/spgci/config.py +++ b/spgci/config.py @@ -57,7 +57,7 @@ def get_token() -> str: auth: Union[AuthBase, None] = None #: Version of the SPGCI Pkg -version = "0.0.42" +version = "0.0.43" #: time to sleep between api calls sleep_time = 0 diff --git a/spgci/market_data.py b/spgci/market_data.py index dba476b..efbcfc3 100644 --- a/spgci/market_data.py +++ b/spgci/market_data.py @@ -84,7 +84,8 @@ def _convert_to_df(resp: Response) -> pd.DataFrame: j = resp.json() df = pd.json_normalize(j["results"], record_path=["data"], meta="symbol") # type: ignore - df.columns = df.columns.str.replace("change.", "", regex=True) # type: ignore + if len(df) > 0: + df.columns = df.columns.str.replace("change.", "", regex=True) # type: ignore if "assessDate" in df.columns: df["assessDate"] = pd.to_datetime(df["assessDate"]) # type: ignore