Skip to content

Commit

Permalink
fix: support _no_init on python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-labs committed Nov 24, 2023
1 parent 1b9b749 commit 754407c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions rodi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
)

if sys.version_info >= (3, 9): # pragma: no cover
# Python 3.9
from typing import _no_init_or_replace_init
from typing import _no_init_or_replace_init as _no_init
elif sys.version_info >= (3, 8): # pragma: no cover
from typing import _no_init

try:
from typing import Protocol
Expand Down Expand Up @@ -584,12 +585,13 @@ def _ignore_class_attribute(self, key: str, value) -> bool:
return is_classvar or is_initialized

def _has_default_init(self):
if self.concrete_type.__init__ is object.__init__:
init = getattr(self.concrete_type, "__init__", None)

if init is object.__init__:
return True

if sys.version_info >= (3, 9): # pragma: no cover
# Python 3.9
if self.concrete_type.__init__ is _no_init_or_replace_init:
if sys.version_info >= (3, 8): # pragma: no cover
if init is _no_init:
return True
return False

Expand Down

0 comments on commit 754407c

Please sign in to comment.