nptyping.types._nptype   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 48 %

Importance

Changes 0
Metric Value
eloc 12
dl 12
loc 25
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A SimpleNPTypeMeta.__repr__() 5 5 2
A NPType.__new__() 0 2 1

How to fix   Duplicated Code   

Duplicated Code

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):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
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