Total Complexity | 3 |
Total Lines | 20 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | class PackageRequirement: |
||
2 | |||
3 | def __init__(self, manager: str, package: str, version: str): |
||
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 | |||
33 |
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
could be written as