Completed
Pull Request — master (#2166)
by Zatreanu
01:49
created

PackageRequirement.__str__()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 2
rs 10
1
class PackageRequirement:
2
3
    def __init__(self, manager: str, package: str, version):
4
        """
5
        :param manager: A string with the name of the manager (pip, npm, etc).
6
        :param package: A string with the name of the package to be installed.
7
        :param version: A number that contains the version.
8
        """
9
        self.manager = manager
10
        self.package = package
11
        self.version = version
12
13
    def __str__(self):
14
        return "{.package} version {.version} (for {.manager})".format(self)
15
16
    def check(self):
17
        """
18
        Check if the requirement is satisfied.
19
        """
20
        raise NotImplementedError
21
22
23
class PythonRequirement(PackageRequirement):
24
25
    def __init__(self, package, version):
26
        PackageRequirement.__init__(self, 'pip', package, version)
27
28
    def __str__(self):
29
        return "{.package} version {.version}".format(self)
30
31
    def multiple(self, *args):
0 ignored issues
show
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
32
        return args
33