Conditions | 4 |
Total Lines | 54 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
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:
If many parameters/temporary variables are present:
1 | from coalib.bears.requirements.PackageRequirement import PackageRequirement |
||
28 | >>> REQUIREMENTS = PythonRequirement.multiple( |
||
29 | ... ['coala_decorators', '19.2'],) |
||
30 | |||
31 | In case you provide too many arguments into the tuple, an error will be |
||
32 | raised: |
||
33 | |||
34 | >>> REQUIREMENTS = PythonRequirement.multiple( |
||
35 | ... 'coala_decorators', ('setuptools', '19.2', 'colorama')) |
||
36 | Traceback (most recent call last): |
||
37 | ... |
||
38 | TypeError: Too many elements provided. |
||
39 | """ |
||
40 | |||
41 | def __init__(self, package, version=""): |
||
42 | """ |
||
43 | Constructs a new ``PythonRequirement``, using the ``PackageRequirement`` |
||
44 | constructor. |
||
45 | |||
46 | >>> pr = PythonRequirement('setuptools', '19.2') |
||
47 | >>> pr.manager |
||
48 | 'pip' |
||
49 | >>> pr.package |
||
50 | 'setuptools' |
||
51 | >>> pr.version |
||
52 | '19.2' |
||
53 | |||
54 | :param package: A string with the name of the package to be installed. |
||
55 | :param version: A version string. Leave empty to specify latest version. |
||
56 | """ |
||
57 | PackageRequirement.__init__(self, 'pip', package, version) |
||
58 |