From 1e146c9bdca7f0b40a146c94fac7c5d794b05d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Fri, 21 Jun 2024 12:51:23 +0200 Subject: [PATCH] refactor: Replace `inflection` dependency with `pyhumps` * [`inflection` last version](https://pypi.org/project/inflection/) is from 2020/08/20 * [`pyhumps` last version](https://pypi.org/project/pyhumps/) is from 2022/10/21 Related: * https://github.com/meltano/sdk/issues/2490#issuecomment-2180832069 --- poetry.lock | 26 +++++++++++++------------- pyproject.toml | 2 +- singer_sdk/helpers/_flattening.py | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/poetry.lock b/poetry.lock index 52b813531..e5de940ef 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "alabaster" @@ -865,17 +865,6 @@ zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] testing = ["jaraco.test (>=5.4)", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-ruff (>=0.2.1)", "zipp (>=3.17)"] -[[package]] -name = "inflection" -version = "0.5.1" -description = "A port of Ruby on Rails inflector to Python" -optional = false -python-versions = ">=3.5" -files = [ - {file = "inflection-0.5.1-py2.py3-none-any.whl", hash = "sha256:f38b2b640938a4f35ade69ac3d053042959b62a0f1076a5bbaa1b9526605a8a2"}, - {file = "inflection-0.5.1.tar.gz", hash = "sha256:1a29730d366e996aaacffb2f1f1cb9593dc38e2ddd30c91250c6dde09ea9b417"}, -] - [[package]] name = "iniconfig" version = "2.0.0" @@ -1524,6 +1513,17 @@ files = [ [package.extras] windows-terminal = ["colorama (>=0.4.6)"] +[[package]] +name = "pyhumps" +version = "3.8.0" +description = "🐫 Convert strings (and dictionary keys) between snake case, camel case and pascal case in Python. Inspired by Humps for Node" +optional = false +python-versions = "*" +files = [ + {file = "pyhumps-3.8.0-py3-none-any.whl", hash = "sha256:060e1954d9069f428232a1adda165db0b9d8dfdce1d265d36df7fbff540acfd6"}, + {file = "pyhumps-3.8.0.tar.gz", hash = "sha256:498026258f7ee1a8e447c2e28526c0bea9407f9a59c03260aee4bd6c04d681a3"}, +] + [[package]] name = "pyjwt" version = "2.8.0" @@ -2674,4 +2674,4 @@ testing = ["pytest", "pytest-durations"] [metadata] lock-version = "2.0" python-versions = ">=3.8" -content-hash = "c67c6c6f6394ae7cddeb6d00b05225e0e232d460a34fc2806b4f12c89486cb78" +content-hash = "e5459f357cf98fcea37e0825a281f5b83f3d48b1c8e6c345862dc90a82900f95" diff --git a/pyproject.toml b/pyproject.toml index 5c131bd79..b4a67cf91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,12 +46,12 @@ cryptography = ">=3.4.6" fs = ">=2.4.16" importlib-metadata = {version = "<8.0.0", python = "<3.12"} importlib-resources = {version = ">=5.12.0,!=6.2.0,!=6.3.0,!=6.3.1", python = "<3.9"} -inflection = ">=0.5.1" joblib = ">=1.3.0" jsonpath-ng = ">=1.5.3" jsonschema = ">=4.16.0" packaging = ">=23.1" pendulum = ">=2.1.0,<4" +pyhumps = ">=3.8.0" PyJWT = "~=2.4" python-dateutil = ">=2.8.2" python-dotenv = ">=0.20" diff --git a/singer_sdk/helpers/_flattening.py b/singer_sdk/helpers/_flattening.py index 145b76bb2..0488d4409 100644 --- a/singer_sdk/helpers/_flattening.py +++ b/singer_sdk/helpers/_flattening.py @@ -8,7 +8,7 @@ import typing as t from copy import deepcopy -import inflection +import humps import simplejson as json DEFAULT_FLATTENING_SEPARATOR = "__" @@ -67,7 +67,7 @@ def flatten_key(key_name: str, parent_keys: list[str], separator: str = "__") -> reduced_key = re.sub( r"[a-z]", "", - inflection.camelize(inflected_key[reducer_index]), + humps.camelize(inflected_key[reducer_index]), ) inflected_key[reducer_index] = ( reduced_key if len(reduced_key) > 1 else inflected_key[reducer_index][:3]