def _find_rows_parametric( # noqa: WPS231 self, source_type: Type[SourceType], destination_type: Type[DestinationType], ) -> Iterable[Row[SourceType, DestinationType]]: """Find suitable conversion arrows by DestinationType superclasses.""" for row in self.items(): (source, destination), cast = row if source != source_type: continue if getattr(destination, '__origin__', None) != SubclassOf: continue destination_superclass, = generic_type_args(destination) if not issubclass(destination_type, destination_superclass): continue # pragma: no cover yield row
def value_type(self) -> Type[ValueType]: """Type of the values.""" return generic_type_args(self)[1]
def key_type(self) -> Type[KeyType]: """Type of the keys.""" return generic_type_args(self)[0]
def test_failure(type_or_value): """Test a value which does not have generic parameters.""" with pytest.raises(TypeArgsError): generic_type_args(type_or_value)
def test_get_args_docstring(generic_type, type_parameters): """Tests for typing.Generic.""" assert generic_type_args(generic_type) == type_parameters
def value_type(self) -> Type[ValueType]: """Extract the type of queue message from type args.""" return generic_type_args(self)[0]
def test_generic_with_inheritance(generic_type, type_parameters): """Test inheritance from generic type.""" subclass_type = types.new_class('SubClass', (generic_type, ), {}) assert generic_type_args(subclass_type) == type_parameters
def test_plain_generic(generic_type, type_parameters): """Test generic type.""" assert generic_type_args(generic_type) == type_parameters