Wemake-python-styleguide: Restrict the maximum number of base classes aka mixins

Created on 16 Oct 2018  路  2Comments  路  Source: wemake-services/wemake-python-styleguide

Rule request

Thesis

There are use cases that promote putting too many bases classes for your class:

class SnippetList(mixins.ListModelMixin,
                  mixins.CreateModelMixin,
                  mixins.DetailModelMixin,
                  mixins.DeleteModelMixin,
                  generics.GenericAPIView):

We need to restrict classes with too many base classes as too complex ones.
We also need to provide an option with reasonable default to make this rule configurable.

I guess 3 should be the default value. But I am open to any other suggestions.

Reasoning

It is almost never possible to navigate to the desired method of a parent class when you need it with multiple mixins.

It is hard to understand mro and super calls. Do not overuse this technique.

Hacktoberfest help wanted starter rule request

Most helpful comment

@sobolevn ye, I'll do it

All 2 comments

@novikovfred will this issue be interesting to you?

@sobolevn ye, I'll do it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Dreamsorcerer picture Dreamsorcerer  路  4Comments

orsinium picture orsinium  路  3Comments

Jrryy picture Jrryy  路  3Comments

serhii73 picture serhii73  路  3Comments

orsinium picture orsinium  路  5Comments