Skip to content

Inheritance issues with generic collections #202

@bintoro

Description

@bintoro

I have a problem with how __extra__ is currently inherited:

>>> class CustomMapping(typing.Mapping): ...
... 
>>> issubclass(dict, CustomMapping)
True
>>> class CustomDict(typing.Dict): ...
... 
>>> issubclass(dict, CustomDict)
True

This can't be right.

My initial impression is that __extra__ should only be propagated on parameterization, not when subclassing, and that the concrete types List, Dict, etc. should have their own extras (list, dict, and so on). Thoughts? A tentative patch is here.

Another thing: The module distributed on PyPI still has the issue where a generic doesn't include itself in the subtype's MRO during parameterization. This was fixed for Python 3.5.1 in aab2c59. It would be great if we could get a more recent revision on PyPI as well.

3.5.1:

>>> issubclass(Iterable[int], Iterable)
True

3.5.0:

>>> issubclass(Iterable[int], Iterable)
False

And finally, a question: The collections ABC replacements do not provide the abstract (or any other) methods of the originals. In particular, Iterable is technically not abstract at all. Is this intentional or just a temporary state of affairs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions