extendable 1.2.2__tar.gz → 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {extendable-1.2.2 → extendable-1.3.0}/PKG-INFO +3 -2
- {extendable-1.2.2 → extendable-1.3.0}/src/extendable/main.py +16 -4
- {extendable-1.2.2 → extendable-1.3.0}/src/extendable/registry.py +3 -2
- extendable-1.3.0/src/extendable/version.py +1 -0
- extendable-1.2.2/src/extendable/version.py +0 -1
- {extendable-1.2.2 → extendable-1.3.0}/LICENSE +0 -0
- {extendable-1.2.2 → extendable-1.3.0}/README.md +0 -0
- {extendable-1.2.2 → extendable-1.3.0}/pyproject.toml +0 -0
- {extendable-1.2.2 → extendable-1.3.0}/src/extendable/__init__.py +0 -0
- {extendable-1.2.2 → extendable-1.3.0}/src/extendable/context.py +0 -0
- {extendable-1.2.2 → extendable-1.3.0}/src/extendable/exceptions.py +0 -0
- {extendable-1.2.2 → extendable-1.3.0}/src/extendable/py.typed +0 -0
- {extendable-1.2.2 → extendable-1.3.0}/src/extendable/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: extendable
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: A lib to define class extendable at runtime.
|
|
5
5
|
Author-email: Laurent Mignon <laurent.mignon@acsone.eu>
|
|
6
6
|
Requires-Python: >=3.6
|
|
@@ -8,6 +8,7 @@ Description-Content-Type: text/markdown
|
|
|
8
8
|
Classifier: License :: OSI Approved :: MIT License
|
|
9
9
|
Classifier: Intended Audience :: Developers
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
|
+
License-File: LICENSE
|
|
11
12
|
Requires-Dist: contextvars;python_version<'3.7'
|
|
12
13
|
Requires-Dist: types-contextvars;python_version<'3.7'
|
|
13
14
|
Requires-Dist: typing_extensions;python_version<'3.7'
|
|
@@ -87,9 +87,9 @@ class ExtendableClassDef:
|
|
|
87
87
|
return clone
|
|
88
88
|
|
|
89
89
|
|
|
90
|
-
_extendable_class_defs_by_module: OrderedDict[
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
_extendable_class_defs_by_module: OrderedDict[str, List[ExtendableClassDef]] = (
|
|
91
|
+
collections.OrderedDict()
|
|
92
|
+
)
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
def __register_class_def__(module: str, cls_def: ExtendableClassDef) -> None:
|
|
@@ -108,7 +108,7 @@ class ExtendableMeta(ABCMeta):
|
|
|
108
108
|
|
|
109
109
|
@no_type_check
|
|
110
110
|
def __new__(metacls, name, bases, namespace, extends=None, **kwargs):
|
|
111
|
-
"""
|
|
111
|
+
"""Create the expected class and collect the class definition that will be used
|
|
112
112
|
at the end of registry load process to build the final class."""
|
|
113
113
|
class_def = None
|
|
114
114
|
if isinstance(extends, bool) and extends:
|
|
@@ -251,6 +251,18 @@ class ExtendableMeta(ABCMeta):
|
|
|
251
251
|
###############################################################
|
|
252
252
|
# concrete methods provided to the final class by the metaclass
|
|
253
253
|
###############################################################
|
|
254
|
+
def __instancecheck__(self, instance: Any) -> bool: # noqa: B902
|
|
255
|
+
"""Implement issubclass(sub, cls)."""
|
|
256
|
+
if not hasattr(instance, "__xreg_name__"):
|
|
257
|
+
return False
|
|
258
|
+
|
|
259
|
+
if instance.__xreg_name__ == self.__xreg_name__:
|
|
260
|
+
# this is the same class
|
|
261
|
+
return True
|
|
262
|
+
# self is a class and instance is an instance of a class
|
|
263
|
+
if self.__xreg_name__ in instance.__xreg_all_base_names__:
|
|
264
|
+
return True
|
|
265
|
+
return super().__instancecheck__(instance)
|
|
254
266
|
|
|
255
267
|
def __subclasscheck__(cls, subclass: Any) -> bool: # noqa: B902
|
|
256
268
|
"""Implement issubclass(sub, cls)."""
|
|
@@ -8,8 +8,9 @@ from .utils import LastOrderedSet
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class ExtendableRegistryListener:
|
|
11
|
-
def on_registry_initialized(
|
|
12
|
-
|
|
11
|
+
def on_registry_initialized(
|
|
12
|
+
self, registry: "ExtendableClassesRegistry"
|
|
13
|
+
) -> None: ...
|
|
13
14
|
|
|
14
15
|
def before_init_registry(
|
|
15
16
|
self,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.3.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.2.2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|