Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangb committed Sep 30, 2021
1 parent 05efa72 commit 788e449
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 33 deletions.
2 changes: 1 addition & 1 deletion di/_local_scope_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)

if TYPE_CHECKING:
from di._state import ContainerState
from di._state import ContainerState # pragma: no cover

from di.types import FusedContextManager
from di.types.scopes import Scope
Expand Down
30 changes: 1 addition & 29 deletions di/_scope_map.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Any, Dict, Generic, Hashable, List, TypeVar, Union, overload
from typing import Dict, Generic, Hashable, List, TypeVar

from di.exceptions import DuplicateScopeError, UnknownScopeError
from di.types.scopes import Scope
Expand All @@ -10,9 +10,6 @@
VT = TypeVar("VT")


_unset: Any = object()


class ScopeMap(Generic[KT, VT]):
"""Mapping-like structure to hold binds and cached values.
Expand Down Expand Up @@ -52,34 +49,12 @@ def set(self, key: KT, value: VT, *, scope: Scope) -> None:
if key in mapping:
mapping.pop(key)

@overload
def pop(self, key: KT) -> VT:
...

@overload
def pop(self, key: KT, default: T) -> Union[VT, T]:
...

def pop(self, key: KT, default: T = _unset) -> Union[VT, T]:
for mapping in self.mappings.values():
if key in mapping:
return mapping.pop(key)
if default is not _unset:
return default
raise KeyError(key)

def contains(self, key: KT) -> bool:
for mapping in self.mappings.values():
if key in mapping:
return True
return False

def get_scope(self, key: KT) -> Scope:
for scope, mapping in self.mappings.items():
if key in mapping:
return scope
raise KeyError(key)

def add_scope(self, scope: Scope) -> None:
if scope in self.mappings:
raise DuplicateScopeError(f"The scope {scope} already exists!")
Expand All @@ -92,9 +67,6 @@ def pop_scope(self, scope: Scope) -> None:
)
self.mappings.pop(scope)

def has_scope(self, scope: Scope) -> bool:
return scope in self.mappings

def copy(self) -> ScopeMap[KT, VT]:
new = ScopeMap[KT, VT]()
new.mappings = self.mappings.copy()
Expand Down
2 changes: 0 additions & 2 deletions di/_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ def bind(
previous_provider = self.binds.get(dependency, None)

self.binds[dependency] = provider
if self.cached_values.contains(dependency):
self.cached_values.pop(dependency)

@contextmanager
def unbind() -> Generator[None, None, None]:
Expand Down
2 changes: 1 addition & 1 deletion di/executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def _all_sync(tasks: typing.List[Task]) -> bool:
if isinstance(task, functools.partial):
call = task.func # type: ignore
else:
call = task
call = task # pragma: no cover
if inspect.iscoroutinefunction(call):
return False
return True
Expand Down

0 comments on commit 788e449

Please sign in to comment.