diff --git a/dataclasses_avroschema/fields/base.py b/dataclasses_avroschema/fields/base.py index 4297ad81..f3b093b9 100644 --- a/dataclasses_avroschema/fields/base.py +++ b/dataclasses_avroschema/fields/base.py @@ -5,13 +5,11 @@ import typing from collections import OrderedDict -from inflector import Inflector +import inflection from typing_extensions import get_args from dataclasses_avroschema import utils -p = Inflector() - logger = logging.getLogger(__name__) @@ -52,7 +50,7 @@ def _get_self_reference_type(a_type: typing.Any) -> str: @staticmethod def get_singular_name(name: str) -> str: - return p.singularize(name) + return inflection.singularize(name) def get_metadata(self) -> typing.List[typing.Tuple[str, str]]: return [(name, value) for name, value in self.metadata.items()] @@ -126,11 +124,7 @@ def fake(self) -> typing.Any: def exist_type(self) -> int: # filter by the same field types - same_types = [ - field.type - for field in self.parent._user_defined_types - if field.type == self.type - ] + same_types = [field.type for field in self.parent._user_defined_types if field.type == self.type] # If length > 0, means that it is the first appearance # of this type, otherwise exist already. diff --git a/poetry.lock b/poetry.lock index 8566501c..e74bb3b1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -994,14 +994,14 @@ perf = ["ipython"] test = ["flufl.flake8", "importlib-resources (>=1.3)", "jaraco.test (>=5.4)", "packaging", "pyfakefs", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-perf (>=0.9.2)", "pytest-ruff (>=0.2.1)"] [[package]] -name = "inflector" -version = "3.1.1" -description = "Inflector for Python" +name = "inflection" +version = "0.5.1" +description = "A port of Ruby on Rails inflector to Python" optional = false -python-versions = "*" +python-versions = ">=3.5" files = [ - {file = "Inflector-3.1.1-py3-none-any.whl", hash = "sha256:b158010b9c400382a9792dcaa05a02c198b27d17fb52a23262e8226c91b13c97"}, - {file = "Inflector-3.1.1.tar.gz", hash = "sha256:1835ccc74ea8b5bea93cee9f7802b5cbbaaa937e268a197a937394aa47dee6d5"}, + {file = "inflection-0.5.1-py2.py3-none-any.whl", hash = "sha256:f38b2b640938a4f35ade69ac3d053042959b62a0f1076a5bbaa1b9526605a8a2"}, + {file = "inflection-0.5.1.tar.gz", hash = "sha256:1a29730d366e996aaacffb2f1f1cb9593dc38e2ddd30c91250c6dde09ea9b417"}, ] [[package]] @@ -2473,4 +2473,4 @@ pydantic = ["pydantic"] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "b47e65b40e8c46f0a3612a0f9e03676086da87ed7eed2d09839c3d5c9aeda145" +content-hash = "17f300013efe465e8914b0b52548907e1159160d9ccfff40719e5615bd761f7c" diff --git a/pyproject.toml b/pyproject.toml index c354eb5a..e5d11496 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,13 +24,13 @@ python = "^3.8" fastavro = "^1.7.3" dacite = "^1.8.0" faker = {version = ">=26.0.0,<27.0.0", optional = true} -inflector = "^3.1.1" faust-streaming = {version = ">=0.10.11,<0.12.0", optional = true} casefy = "^0.1.7" typing-extensions = "^4.2.0" pydantic = {version = "^2.4.2", optional = true, extras = ["email"]} python-dateutil = "^2.9.0.post0" dc-avro = {version =">=0.6.4,<0.9.0", optional = true} +inflection = "^0.5.1" [tool.poetry.group.dev.dependencies] mypy = "^1.8.0" diff --git a/tests/schemas/avro/user_array_address_alias.avsc b/tests/schemas/avro/user_array_address_alias.avsc index a499d14b..412fe7f8 100644 --- a/tests/schemas/avro/user_array_address_alias.avsc +++ b/tests/schemas/avro/user_array_address_alias.avsc @@ -29,7 +29,7 @@ ], "doc": "An Address" }, - "name": "addres" + "name": "address" } } ], diff --git a/tests/schemas/avro/user_map_address_alias.avsc b/tests/schemas/avro/user_map_address_alias.avsc index 9b9eec8c..e808bb80 100644 --- a/tests/schemas/avro/user_map_address_alias.avsc +++ b/tests/schemas/avro/user_map_address_alias.avsc @@ -29,7 +29,7 @@ ], "doc": "An Address" }, - "name": "addres" + "name": "address" } } ],