Conditions | 9 |
Total Lines | 68 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
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 datetime import date |
||
15 | def stage(draft, release_name=None, release_description=None): |
||
16 | repository, bumpversion_part, release_type, proposed_version = status() |
||
17 | |||
18 | if not repository.changes_since_last_version: |
||
19 | error("There aren't any changes to release!") |
||
20 | return |
||
21 | |||
22 | info('Staging [{}] release for version {}'.format( |
||
23 | release_type, |
||
24 | proposed_version |
||
25 | )) |
||
26 | |||
27 | bumpversion_arguments = ( |
||
28 | BumpVersion.DRAFT_OPTIONS if draft |
||
29 | else BumpVersion.STAGE_OPTIONS |
||
30 | ) |
||
31 | bumpversion_arguments += [bumpversion_part] |
||
32 | |||
33 | info('Running: bumpversion {}'.format( |
||
34 | ' '.join(bumpversion_arguments) |
||
35 | )) |
||
36 | |||
37 | try: |
||
38 | bumpversion.main(bumpversion_arguments) |
||
39 | except bumpversion.WorkingDirectoryIsDirtyException as err: |
||
40 | error(err) |
||
41 | raise |
||
42 | |||
43 | info('Generating Release') |
||
44 | # prepare context for changelog documentation |
||
45 | project_labels = changes.project_settings.labels |
||
46 | for label, properties in project_labels.items(): |
||
47 | pull_requests_with_label = [ |
||
48 | pull_request |
||
49 | for pull_request in repository.changes_since_last_version |
||
50 | if label in pull_request.labels |
||
51 | ] |
||
52 | |||
53 | project_labels[label]['pull_requests'] = pull_requests_with_label |
||
54 | |||
55 | release = Release( |
||
56 | name=release_name, |
||
57 | release_date=date.today().isoformat(), |
||
58 | version=proposed_version, |
||
59 | description=release_description, |
||
60 | changes=project_labels, |
||
61 | ) |
||
62 | |||
63 | info('Loading template...') |
||
64 | # TODO: if project_settings.release_notes_template is None |
||
65 | release_notes_template = pkg_resources.resource_string( |
||
66 | changes.__name__, |
||
67 | 'templates/release_notes_template.md' |
||
68 | ).decode('utf8') |
||
69 | |||
70 | release_notes = Template(release_notes_template).render(release=release) |
||
71 | # TODO: jinja2.exceptions.UndefinedError |
||
72 | |||
73 | releases_directory = Path(changes.project_settings.releases_directory) |
||
74 | if not releases_directory.exists(): |
||
75 | releases_directory.mkdir(parents=True) |
||
76 | release_notes_path = releases_directory.joinpath( |
||
77 | '{}.md'.format(release.version) |
||
78 | ) |
||
79 | if not draft: |
||
80 | release_notes_path.write_text(release_notes) |
||
81 | else: |
||
82 | note(release_notes) |
||
83 |
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.py
files in your module folders. Make sure that you place one file in each sub-folder.