Skip to content

Overrides breaks when using a parameter of Callable type #78

@dpcollins-google

Description

@dpcollins-google

When overriding the following interface:

class MyInterface(ABC):
  @abstractmethod
  def run(self, callback: Callable[[str], None]):
    pass

overrides will fail with:

lib/python3.7/site-packages/overrides/overrides.py:88: in overrides
    return _overrides(method, check_signature, check_at_runtime)
lib/python3.7/site-packages/overrides/overrides.py:114: in _overrides
    _validate_method(method, super_class, check_signature)
lib/python3.7/site-packages/overrides/overrides.py:135: in _validate_method
    ensure_signature_is_compatible(super_method, method, is_static)
lib/python3.7/site-packages/overrides/signature.py:84: in ensure_signature_is_compatible
    super_sig, sub_sig, super_type_hints, sub_type_hints, is_static, method_name
lib/python3.7/site-packages/overrides/signature.py:138: in ensure_all_kwargs_defined_in_sub
    and not _issubtype(super_type_hints[name], sub_type_hints[name])
python3.7/site-packages/overrides/signature.py:41: in _issubtype
    return issubtype(left, right)
python3.7/site-packages/typing_utils/__init__.py:274: in issubtype
    return _is_normal_subtype(normalize(left), normalize(right), forward_refs)
python3.7/site-packages/typing_utils/__init__.py:177: in normalize
    args = tuple(normalize(a) for a in args)
python3.7/site-packages/typing_utils/__init__.py:177: in <genexpr>
    args = tuple(normalize(a) for a in args)
python3.7/site-packages/typing_utils/__init__.py:171: in normalize
    return NormalizedType(_ensure_builtin(tp))
python3.7/site-packages/typing_utils/__init__.py:49: in _ensure_builtin
    if tp in BUILTINS_MAPPING:
E   TypeError: unhashable type: 'list'

I believe this is an issue in the underlying typing-utils library that it doesn't properly handle the first parameter of Callable being a list (which is unhashable).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions