Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

public class _Base #102

Closed
aamalev opened this issue Jul 2, 2017 · 3 comments
Closed

public class _Base #102

aamalev opened this issue Jul 2, 2017 · 3 comments

Comments

@aamalev
Copy link

aamalev commented Jul 2, 2017

To effective detect a group of classes

if isinstance(a, BaseMultidict):
    # dosomething1
elif isinstances (a, Mapping):
    # dosomething2

The simplest implementation is less effective

BaseMultidict = (CIMultiDict, MultiDict, MultiDictProxy)
@asvetlov
Copy link
Member

asvetlov commented Jul 2, 2017

No. It is implementation detail and subject of future changes.
Next versions may have no such base class at all.

BTW what use cases for checking this type? Theoretically what you need is iteration over a.items() regardless concrete Mapping implementation.

@aamalev
Copy link
Author

aamalev commented Jul 2, 2017

The main project classes have a common interface described by common methods. Based on the principles of parametric polymorphism, it makes sense to single out a formally generalized interface. For python parametric polymorphism goes along with annotations and types such as Mapping, but Mapping exclude getall

In this case https://github.com/aamalev/aiohttp_apiset/blob/master/aiohttp_apiset/swagger/route.py#L132 could get away from duck typing

@asvetlov
Copy link
Member

asvetlov commented Jul 2, 2017

In this case you need multidict ABCs for extending standard Mapping and MutableMapping.
I'm open for PR like this (documentation should be updated as well).
Personally I don't have very strong motivation for fixing it myself right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants