| Total Complexity | 3 |
| Total Lines | 25 |
| Duplicated Lines | 48 % |
| Changes | 0 | ||
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | from nptyping._hashed_subscriptable_type import HashedSubscriptableType |
||
| 2 | |||
| 3 | |||
| 4 | class NPType: |
||
| 5 | """ |
||
| 6 | The baseclass of all nptyping types. |
||
| 7 | """ |
||
| 8 | |||
| 9 | def __new__(cls, *args, **kwargs) -> None: |
||
| 10 | raise TypeError('Type {} cannot be instantiated'.format(cls.__name__)) |
||
| 11 | |||
| 12 | |||
| 13 | View Code Duplication | class SimpleNPTypeMeta(HashedSubscriptableType): |
|
|
|
|||
| 14 | """ |
||
| 15 | A metaclass for all simple NPTypes (e.g. float, int, etc.). |
||
| 16 | """ |
||
| 17 | |||
| 18 | def __repr__(cls): |
||
| 19 | repr_args = getattr(cls, '_repr_args', None) |
||
| 20 | if not repr_args: |
||
| 21 | return cls.__name__ |
||
| 22 | return '{}[{}]'.format(cls.__name__, repr_args) |
||
| 23 | |||
| 24 | __str__ = __repr__ |
||
| 25 |