Completed
Pull Request — master (#2185)
by Zatreanu
01:50
created

PythonRequirement.multiple()   A

Complexity

Conditions 4

Size

Total Lines 54

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 4
c 2
b 0
f 0
dl 0
loc 54
rs 9.0306

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
from coalib.bears.requirements.PackageRequirement import PackageRequirement
2
3
4
class PythonRequirement(PackageRequirement):
5
    """
6
    This class is a subclass of ``PackageRequirement``, and helps specifying
7
    requirements from ``pip``, without using the manager name.
8
    """
9
10
    def __init__(self, package, version=""):
11
        """
12
        Constructs a new ``PythonRequirement``, using the ``PackageRequirement``
13
        constructor.
14
15
        >>> pr = PythonRequirement('setuptools', '19.2')
16
        >>> pr.manager
17
        'pip'
18
        >>> pr.package
19
        'setuptools'
20
        >>> pr.version
21
        '19.2'
22
23
        :param package: A string with the name of the package to be installed.
24
        :param version: A version string. Leave empty to specify latest version.
25
        """
26
        PackageRequirement.__init__(self, 'pip', package, version)
27