objetto
Advanced tools
| Metadata-Version: 2.1 | ||
| Name: objetto | ||
| Version: 1.25.1 | ||
| Version: 1.25.2 | ||
| Summary: Object-oriented framework for building smart applications and APIs | ||
@@ -5,0 +5,0 @@ Home-page: https://github.com/brunonicko/objetto |
@@ -34,3 +34,3 @@ # -*- coding: utf-8 -*- | ||
| from ..utils.reraise_context import ReraiseContext | ||
| from ..utils.type_checking import assert_is_instance, get_type_names | ||
| from ..utils.type_checking import assert_is_instance, get_type_names, import_types | ||
| from .bases import ( | ||
@@ -648,4 +648,18 @@ BaseAuxiliaryStructure, | ||
| # Both are constant attributes with a non-empty tuple/frozenset. | ||
| if ( | ||
| abstract_attribute.constant | ||
| and member.constant | ||
| and type(abstract_attribute.default) in (tuple, frozenset) | ||
| and type(member.default) is type(abstract_attribute.default) | ||
| and abstract_attribute.default | ||
| and member.default | ||
| ): | ||
| abstract_member_types = tuple( | ||
| type(v) for v in abstract_attribute.default | ||
| ) | ||
| member_types = tuple(type(v) for v in member.default) | ||
| # Both abstract and concrete are matching auxiliary structures. | ||
| if ( | ||
| elif ( | ||
| len(abstract_member_types) == 1 | ||
@@ -664,4 +678,2 @@ and isinstance(abstract_member_types[0], type) | ||
| ): | ||
| # Use their auxiliary relationship types. | ||
| abstract_member_types = abstract_member_types[ | ||
@@ -672,33 +684,35 @@ 0 | ||
| # Check types. | ||
| for typ in abstract_member_types: | ||
| # Import abstract member types. | ||
| abstract_member_types = import_types(abstract_member_types) | ||
| # If auxiliary structure, use base type. | ||
| if ( | ||
| not isinstance(typ, BASE_STRING_TYPES) | ||
| and issubclass(typ, BaseAuxiliaryStructure) | ||
| ): | ||
| typ = typ._base_auxiliary_type | ||
| # No types declared in implementation. | ||
| if abstract_member_types and not member_types: | ||
| error = ( | ||
| "abstract attribute '{}.{}' declares types, but " | ||
| "implementation in '{}.{}' does not" | ||
| ).format( | ||
| abstract_base.__name__, | ||
| member_name, | ||
| name, | ||
| member_name, | ||
| ) | ||
| raise TypeError(error) | ||
| # No types declared in implementation. | ||
| if not member_types: | ||
| # Types need to be compatible. | ||
| # Implementation needs to be a subset and subclass of abstract. | ||
| for t in member_types: | ||
| error = ( | ||
| "abstract attribute '{}.{}' declares types, but " | ||
| "implementation in '{}.{}' does not" | ||
| ).format( | ||
| abstract_base.__name__, | ||
| member_name, | ||
| name, | ||
| member_name, | ||
| ) | ||
| raise TypeError(error) | ||
| # Ignore lazy type. | ||
| if isinstance(t, BASE_STRING_TYPES): | ||
| continue | ||
| # Types are incompatible (skip lazy imported). | ||
| if not any( | ||
| isinstance(typ, BASE_STRING_TYPES) | ||
| or isinstance(t, BASE_STRING_TYPES) | ||
| or issubclass(t, typ) | ||
| for t in member_types | ||
| ): | ||
| # Check against abstract member types until we find a match. | ||
| for typ in abstract_member_types: | ||
| # Match! | ||
| if issubclass(t, typ): | ||
| break | ||
| # No match. | ||
| else: | ||
| error = ( | ||
@@ -705,0 +719,0 @@ "types in attribute '{}.{}' {} are not compatible " |
+1
-1
| Metadata-Version: 2.1 | ||
| Name: objetto | ||
| Version: 1.25.1 | ||
| Version: 1.25.2 | ||
| Summary: Object-oriented framework for building smart applications and APIs | ||
@@ -5,0 +5,0 @@ Home-page: https://github.com/brunonicko/objetto |
+1
-1
@@ -8,3 +8,3 @@ import setuptools | ||
| name="objetto", | ||
| version="1.25.1", | ||
| version="1.25.2", | ||
| author="Bruno Nicko", | ||
@@ -11,0 +11,0 @@ author_email="brunonicko@gmail.com", |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
1026868
0.07%25455
0.05%