From 3ba4704bc1cb00310749fd2eda0c8221167c313c Mon Sep 17 00:00:00 2001 From: ZipFile Date: Sat, 14 Dec 2024 13:03:57 +0000 Subject: [PATCH] Remove six --- pyproject.toml | 1 - requirements.txt | 1 - src/dependency_injector/containers.pyx | 35 ++++++++++++-------------- tox.ini | 1 - 4 files changed, 16 insertions(+), 22 deletions(-) delete mode 100644 requirements.txt diff --git a/pyproject.toml b/pyproject.toml index d0b0f7f5..eba17764 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,6 @@ classifiers = [ "Topic :: Software Development :: Libraries :: Python Modules", ] dynamic = ["version"] -dependencies = ["six"] [project.optional-dependencies] yaml = ["pyyaml"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 806e29ae..00000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -six>=1.7.0,<=1.16.0 diff --git a/src/dependency_injector/containers.pyx b/src/dependency_injector/containers.pyx index 988c3e16..7e922773 100644 --- a/src/dependency_injector/containers.pyx +++ b/src/dependency_injector/containers.pyx @@ -18,8 +18,6 @@ try: except ImportError: yaml = None -import six - from . import providers, errors from .providers cimport __is_future_or_coroutine @@ -201,7 +199,7 @@ class DynamicContainer(Container): :rtype: None """ - for name, provider in six.iteritems(providers): + for name, provider in providers.items(): setattr(self, name, provider) def set_provider(self, name, provider): @@ -234,7 +232,7 @@ class DynamicContainer(Container): self.overridden += (overriding,) - for name, provider in six.iteritems(overriding.providers): + for name, provider in overriding.providers.items(): try: getattr(self, name).override(provider) except AttributeError: @@ -250,7 +248,7 @@ class DynamicContainer(Container): :rtype: None """ overridden_providers = [] - for name, overriding_provider in six.iteritems(overriding_providers): + for name, overriding_provider in overriding_providers.items(): container_provider = getattr(self, name) container_provider.override(overriding_provider) overridden_providers.append(container_provider) @@ -266,7 +264,7 @@ class DynamicContainer(Container): self.overridden = self.overridden[:-1] - for provider in six.itervalues(self.providers): + for provider in self.providers.values(): provider.reset_last_overriding() def reset_override(self): @@ -276,7 +274,7 @@ class DynamicContainer(Container): """ self.overridden = tuple() - for provider in six.itervalues(self.providers): + for provider in self.providers.values(): provider.reset_override() def is_auto_wiring_enabled(self): @@ -495,13 +493,13 @@ class DeclarativeContainerMetaClass(type): containers = { name: container - for name, container in six.iteritems(attributes) + for name, container in attributes.items() if is_container(container) } cls_providers = { name: provider - for name, provider in six.iteritems(attributes) + for name, provider in attributes.items() if isinstance(provider, providers.Provider) and not isinstance(provider, providers.Self) } @@ -509,7 +507,7 @@ class DeclarativeContainerMetaClass(type): name: provider for base in bases if is_container(base) and base is not DynamicContainer - for name, provider in six.iteritems(base.providers) + for name, provider in base.providers.items() } all_providers = {} @@ -536,10 +534,10 @@ class DeclarativeContainerMetaClass(type): self.set_container(cls) cls.__self__ = self - for provider in six.itervalues(cls.providers): + for provider in cls.providers.values(): _check_provider_type(cls, provider) - for provider in six.itervalues(cls.cls_providers): + for provider in cls.cls_providers.values(): if isinstance(provider, providers.CHILD_PROVIDERS): provider.assign_parent(cls) @@ -641,8 +639,7 @@ class DeclarativeContainerMetaClass(type): return self -@six.add_metaclass(DeclarativeContainerMetaClass) -class DeclarativeContainer(Container): +class DeclarativeContainer(Container, metaclass=DeclarativeContainerMetaClass): """Declarative inversion of control container. .. code-block:: python @@ -767,7 +764,7 @@ class DeclarativeContainer(Container): cls.overridden += (overriding,) - for name, provider in six.iteritems(overriding.cls_providers): + for name, provider in overriding.cls_providers.items(): try: getattr(cls, name).override(provider) except AttributeError: @@ -784,7 +781,7 @@ class DeclarativeContainer(Container): cls.overridden = cls.overridden[:-1] - for provider in six.itervalues(cls.providers): + for provider in cls.providers.values(): provider.reset_last_overriding() @classmethod @@ -795,7 +792,7 @@ class DeclarativeContainer(Container): """ cls.overridden = tuple() - for provider in six.itervalues(cls.providers): + for provider in cls.providers.values(): provider.reset_override() @@ -858,7 +855,7 @@ def copy(object base_container): """ def _get_memo_for_matching_names(new_providers, base_providers): memo = {} - for new_provider_name, new_provider in six.iteritems(new_providers): + for new_provider_name, new_provider in new_providers.items(): if new_provider_name not in base_providers: continue source_provider = base_providers[new_provider_name] @@ -877,7 +874,7 @@ def copy(object base_container): new_providers.update(providers.deepcopy(base_container.providers, memo)) new_providers.update(providers.deepcopy(new_container.cls_providers, memo)) - for name, provider in six.iteritems(new_providers): + for name, provider in new_providers.items(): setattr(new_container, name, provider) return new_container diff --git a/tox.ini b/tox.ini index ed02f0e9..54f99e57 100644 --- a/tox.ini +++ b/tox.ini @@ -35,7 +35,6 @@ deps = v2: pydantic-settings pytest pytest-asyncio - -rrequirements.txt typing_extensions httpx fastapi