Skip to content

Commit a47628e

Browse files
authored
Merge pull request #190 from commitizen-tools/unify-docstring-style
remove trailing space in keep_a_changelog and other minor improvement
2 parents 5201aaf + 274179f commit a47628e

20 files changed

+66
-67
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ jobs:
1212
python-version: [3.6, 3.7, 3.8]
1313

1414
steps:
15-
- uses: actions/checkout@v1
15+
- uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
1618
- name: Set up Python ${{ matrix.python-version }}
1719
uses: actions/setup-python@v1
1820
with:
@@ -27,6 +29,14 @@ jobs:
2729
git config --global user.email "action@github.com"
2830
git config --global user.name "GitHub Action"
2931
./scripts/test
32+
- name: Check commit
33+
run: |
34+
poetry run python -m commitizen check --rev-range ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} || \
35+
if [ $$? == 3 ] ; then
36+
exit 0;
37+
else
38+
exit 1;
39+
fi
3040
- name: Upload coverage to Codecov
3141
if: runner.os == 'Linux'
3242
uses: codecov/codecov-action@v1.0.3

commitizen/bump.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def find_increment(
5555

5656

5757
def prerelease_generator(current_version: str, prerelease: Optional[str] = None) -> str:
58-
"""
58+
"""Generate prerelease
59+
5960
X.YaN # Alpha release
6061
X.YbN # Beta release
6162
X.YrcN # Release Candidate
@@ -137,7 +138,7 @@ def update_version_in_files(
137138
So for example, your tag could look like `v1.0.0` while your version in
138139
the package like `1.0.0`.
139140
"""
140-
# TODO: sepearte check step and write step
141+
# TODO: separate check step and write step
141142
for location in files:
142143
filepath, *regexes = location.split(":", maxsplit=1)
143144
regex = regexes[0] if regexes else None
@@ -179,13 +180,11 @@ def create_tag(version: Union[Version, str], tag_format: Optional[str] = None):
179180
That's why this function exists.
180181
181182
Example:
182-
183183
| tag | version (PEP 0440) |
184184
| --- | ------- |
185185
| v0.9.0 | 0.9.0 |
186186
| ver1.0.0 | 1.0.0 |
187187
| ver1.0.0.a0 | 1.0.0a0 |
188-
189188
"""
190189
if isinstance(version, str):
191190
version = Version(version)

commitizen/changelog.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
# DESIGN
1+
"""Design
32
43
## Metadata CHANGELOG.md
54
@@ -62,7 +61,6 @@ def transform_change_type(change_type: str) -> str:
6261

6362

6463
def get_commit_tag(commit: GitCommit, tags: List[GitTag]) -> Optional[GitTag]:
65-
""""""
6664
return next((tag for tag in tags if tag.rev == commit.rev), None)
6765

6866

@@ -211,13 +209,13 @@ def incremental_build(new_content: str, lines: List, metadata: Dict) -> List:
211209
The metadata holds information enough to remove the old unreleased and
212210
where to place the new content
213211
214-
Arguments:
215-
lines -- the lines from the changelog
216-
new_content -- this should be placed somewhere in the lines
217-
metadata -- information about the changelog
212+
Args:
213+
lines: The lines from the changelog
214+
new_content: This should be placed somewhere in the lines
215+
metadata: Information about the changelog
218216
219217
Returns:
220-
List -- updated lines
218+
Updated lines
221219
"""
222220
unreleased_start = metadata.get("unreleased_start")
223221
unreleased_end = metadata.get("unreleased_end")

commitizen/changelog_parser.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
# DESIGN
1+
"""CHNAGLOG PARSER DESIGN
32
43
## Parse CHANGELOG.md
54
@@ -36,8 +35,7 @@
3635

3736

3837
def find_version_blocks(filepath: str) -> Generator:
39-
"""
40-
version block: contains all the information about a version.
38+
"""Find version block (version block: contains all the information about a version.)
4139
4240
E.g:
4341
```

commitizen/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
{
115115
"name": "--bump-message",
116116
"help": (
117-
"template used to create the release commmit, "
117+
"template used to create the release commit, "
118118
"useful when working with CI"
119119
),
120120
},

commitizen/commands/bump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def __call__(self): # noqa: C901
154154
self.config.set_key("version", new_version.public)
155155
c = git.commit(message, args=self._get_commit_args())
156156
if c.err:
157-
out.error('git.commit errror: "{}"'.format(c.err.strip()))
157+
out.error('git.commit error: "{}"'.format(c.err.strip()))
158158
raise SystemExit(COMMIT_FAILED)
159159
c = git.tag(new_tag_version)
160160
if c.err:

commitizen/commands/check.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,12 @@ class Check:
1212
"""Check if the current commit msg matches the commitizen format."""
1313

1414
def __init__(self, config: BaseConfig, arguments: Dict[str, str], cwd=os.getcwd()):
15-
"""Init method.
16-
17-
Parameters
18-
----------
19-
config : BaseConfig
20-
the config object required for the command to perform its action
21-
arguments : dict
22-
the arguments object that contains all
23-
the flags provided by the user
15+
"""Initial check command.
2416
17+
Args:
18+
config: The config object required for the command to perform its action
19+
arguments: All the flags provided by the user
20+
cwd: Current work directory
2521
"""
2622
self.commit_msg_file: Optional[str] = arguments.get("commit_msg_file")
2723
self.rev_range: Optional[str] = arguments.get("rev_range")
@@ -44,11 +40,8 @@ def _valid_command_argument(self):
4440
def __call__(self):
4541
"""Validate if commit messages follows the conventional pattern.
4642
47-
Raises
48-
------
49-
SystemExit
50-
if the commit provided not follows the conventional pattern
51-
43+
Raises:
44+
SystemExit: if the commit provided not follows the conventional pattern
5245
"""
5346
commit_msgs = self._get_commit_messages()
5447
if not commit_msgs:

commitizen/config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def load_global_conf() -> Optional[IniConfig]:
1616
if not global_cfg.exists():
1717
return None
1818

19-
# global conf doesnt make sense with commitizen bump
19+
# global conf doesn't make sense with commitizen bump
2020
# so I'm deprecating it and won't test it
2121
message = (
2222
"Global conf will be deprecated in next major version. "

commitizen/cz/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def schema(self) -> Optional[str]:
6969
raise NotImplementedError("Not Implemented yet")
7070

7171
def schema_pattern(self) -> Optional[str]:
72-
"""Regex matching the schema used for message validation"""
72+
"""Regex matching the schema used for message validation."""
7373
raise NotImplementedError("Not Implemented yet")
7474

7575
def info(self) -> Optional[str]:

commitizen/factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def commiter_factory(config: BaseConfig) -> BaseCommitizen:
1111
_cz = registry[name](config)
1212
except KeyError:
1313
msg_error = (
14-
"The commiter has not been found in the system.\n\n"
14+
"The committer has not been found in the system.\n\n"
1515
f"Try running 'pip install {name}'\n"
1616
)
1717
out.error(msg_error)

commitizen/git.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ def get_commits(
6363
delimiter: str = "----------commit-delimiter----------",
6464
args: str = "",
6565
) -> List[GitCommit]:
66-
"""
67-
Get the commits betweeen start and end
68-
"""
66+
"""Get the commits between start and end."""
6967
git_log_cmd = f"git log --pretty={log_format}{delimiter} {args}"
7068

7169
if start:
@@ -133,7 +131,7 @@ def find_git_project_root() -> Optional[Path]:
133131

134132

135133
def is_staging_clean() -> bool:
136-
"""Check if staing is clean"""
134+
"""Check if staing is clean."""
137135
c = cmd.run("git diff --no-ext-diff --name-only")
138136
c_cached = cmd.run("git diff --no-ext-diff --cached --name-only")
139137
return not (bool(c.out) or bool(c_cached.out))

commitizen/templates/keep_a_changelog_template.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% for entry in tree %}
22

3-
## {{ entry.version }} {% if entry.date %}({{ entry.date }}){% endif %}
3+
## {{ entry.version }}{% if entry.date %} ({{ entry.date }}){% endif %}
44

55
{% for change_key, changes in entry.changes.items() %}
66

docs/tutorials/github_actions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,6 @@ jobs:
9797
```
9898

9999
Notice that we are calling a bash script in `./scripts/publish`, you should configure it with your tools (twine, poetry, etc.). Check [commitizen example](https://github.com/commitizen-tools/commitizen/blob/master/scripts/publish)
100+
You can also use [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) to publish your package.
100101

101102
Push the changes and that's it.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ mkdocs = "^1.0"
6767
mkdocs-material = "^4.1"
6868
isort = "^4.3.21"
6969
freezegun = "^0.3.15"
70+
pydocstyle = "^5.0.2"
7071

7172
[tool.poetry.scripts]
7273
cz = "commitizen.cli:main"

scripts/test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ ${PREFIX}black commitizen tests --check
1010
${PREFIX}isort --recursive --check-only commitizen tests
1111
${PREFIX}flake8 commitizen/ tests/
1212
${PREFIX}mypy commitizen/ tests/
13+
${PREFIX}pydocstyle --convention=google --add-ignore=D1,D415

tests/CHANGELOG_FOR_TEST.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
- update given files with new version
3030
- **config**: new set key, used to set version to cfg
3131
- support for pyproject.toml
32-
- first semantic version bump implementaiton
32+
- first semantic version bump implementation
3333

3434
### fix
3535

@@ -92,11 +92,11 @@
9292

9393
### refactor
9494

95-
- **conventionalCommit**: moved fitlers to questions instead of message
95+
- **conventionalCommit**: moved filters to questions instead of message
9696

9797
### fix
9898

99-
- **manifest**: inluded missing files
99+
- **manifest**: included missing files
100100

101101
## v0.9.5 (2018-08-24)
102102

@@ -114,7 +114,7 @@
114114

115115
### feat
116116

117-
- **commiter**: conventional commit is a bit more intelligent now
117+
- **committer**: conventional commit is a bit more intelligent now
118118

119119
## v0.9.2 (2017-11-11)
120120

tests/commands/test_bump_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_bump_on_git_with_hooks_no_verify_disabled(mocker, capsys):
7777
cli.main()
7878

7979
_, err = capsys.readouterr()
80-
assert 'git.commit errror: "0.1.0"' in err
80+
assert 'git.commit error: "0.1.0"' in err
8181

8282

8383
@pytest.mark.usefixtures("tmp_commitizen_project")

tests/commands/test_changelog_command.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_changlog_from_version_zero_point_two(mocker, capsys):
3838
cli.main()
3939

4040
out, _ = capsys.readouterr()
41-
assert out == "\n## Unreleased \n\n### Feat\n\n- after 0.2\n- after 0.2.0\n\n"
41+
assert out == "\n## Unreleased\n\n### Feat\n\n- after 0.2\n- after 0.2.0\n\n"
4242

4343

4444
@pytest.mark.usefixtures("tmp_commitizen_project")
@@ -54,7 +54,7 @@ def test_changlog_with_different_cz(mocker, capsys):
5454
out, _ = capsys.readouterr()
5555
assert (
5656
out
57-
== "\n## Unreleased \n\n\n- JRA-35 #time 1w 2d 4h 30m Total work logged\n- JRA-34 #comment corrected indent issue\n\n"
57+
== "\n## Unreleased\n\n\n- JRA-35 #time 1w 2d 4h 30m Total work logged\n- JRA-34 #comment corrected indent issue\n\n"
5858
)
5959

6060

@@ -74,7 +74,7 @@ def test_changlog_from_start(mocker, capsys):
7474

7575
assert (
7676
out
77-
== "\n## Unreleased \n\n### Refactor\n\n- is in changelog\n\n### Feat\n\n- new file\n"
77+
== "\n## Unreleased\n\n### Refactor\n\n- is in changelog\n\n### Feat\n\n- new file\n"
7878
)
7979

8080

@@ -108,7 +108,7 @@ def test_changlog_replacing_unreleased_using_incremental(mocker, capsys):
108108
today = date.today().isoformat()
109109
assert (
110110
out
111-
== f"\n\n## Unreleased \n\n### Feat\n\n- add more stuff\n\n### Fix\n\n- mama gotta work\n\n## 0.2.0 ({today})\n\n### Fix\n\n- output glitch\n\n### Feat\n\n- add new output\n"
111+
== f"\n\n## Unreleased\n\n### Feat\n\n- add more stuff\n\n### Fix\n\n- mama gotta work\n\n## 0.2.0 ({today})\n\n### Fix\n\n- output glitch\n\n### Feat\n\n- add new output\n"
112112
)
113113

114114

@@ -146,7 +146,7 @@ def test_changlog_is_persisted_using_incremental(mocker, capsys):
146146
today = date.today().isoformat()
147147
assert (
148148
out
149-
== f"\n\n## Unreleased \n\n### Feat\n\n- add more stuff\n\n### Fix\n\n- mama gotta work\n\n## 0.2.0 ({today})\n\n### Fix\n\n- output glitch\n\n### Feat\n\n- add new output\n\nnote: this should be persisted using increment\n"
149+
== f"\n\n## Unreleased\n\n### Feat\n\n- add more stuff\n\n### Fix\n\n- mama gotta work\n\n## 0.2.0 ({today})\n\n### Fix\n\n- output glitch\n\n### Feat\n\n- add new output\n\nnote: this should be persisted using increment\n"
150150
)
151151

152152

@@ -180,7 +180,7 @@ def test_changlog_incremental_angular_sample(mocker, capsys):
180180

181181
assert (
182182
out
183-
== "\n## Unreleased \n\n### Feat\n\n- add more stuff\n- add new output\n\n### Fix\n\n- mama gotta work\n- output glitch\n\n# [10.0.0-next.3](https://github.com/angular/angular/compare/10.0.0-next.2...10.0.0-next.3) (2020-04-22)\n\n### Bug Fixes\n* **common:** format day-periods that cross midnight ([#36611](https://github.com/angular/angular/issues/36611)) ([c6e5fc4](https://github.com/angular/angular/commit/c6e5fc4)), closes [#36566](https://github.com/angular/angular/issues/36566)\n"
183+
== "\n## Unreleased\n\n### Feat\n\n- add more stuff\n- add new output\n\n### Fix\n\n- mama gotta work\n- output glitch\n\n# [10.0.0-next.3](https://github.com/angular/angular/compare/10.0.0-next.2...10.0.0-next.3) (2020-04-22)\n\n### Bug Fixes\n* **common:** format day-periods that cross midnight ([#36611](https://github.com/angular/angular/issues/36611)) ([c6e5fc4](https://github.com/angular/angular/commit/c6e5fc4)), closes [#36566](https://github.com/angular/angular/issues/36566)\n"
184184
)
185185

186186

@@ -233,7 +233,7 @@ def test_changlog_incremental_keep_a_changelog_sample(mocker, capsys):
233233

234234
assert (
235235
out
236-
== """# Changelog\nAll notable changes to this project will be documented in this file.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n\n\n## Unreleased \n\n### Feat\n\n- add more stuff\n- add new output\n\n### Fix\n\n- mama gotta work\n- output glitch\n\n## [1.0.0] - 2017-06-20\n### Added\n- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).\n- Version navigation.\n\n### Changed\n- Start using "changelog" over "change log" since it\'s the common usage.\n\n### Removed\n- Section about "changelog" vs "CHANGELOG".\n\n## [0.3.0] - 2015-12-03\n### Added\n- RU translation from [@aishek](https://github.com/aishek).\n"""
236+
== """# Changelog\nAll notable changes to this project will be documented in this file.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n\n\n## Unreleased\n\n### Feat\n\n- add more stuff\n- add new output\n\n### Fix\n\n- mama gotta work\n- output glitch\n\n## [1.0.0] - 2017-06-20\n### Added\n- New visual identity by [@tylerfortune8](https://github.com/tylerfortune8).\n- Version navigation.\n\n### Changed\n- Start using "changelog" over "change log" since it\'s the common usage.\n\n### Removed\n- Section about "changelog" vs "CHANGELOG".\n\n## [0.3.0] - 2015-12-03\n### Added\n- RU translation from [@aishek](https://github.com/aishek).\n"""
237237
)
238238

239239

@@ -251,6 +251,6 @@ def test_changlog_hook(mocker, config):
251251
)
252252
mocker.patch.object(changelog.cz, "changelog_hook", changelog_hook_mock)
253253
changelog()
254-
full_changelog = "\n## Unreleased \n\n### Refactor\n\n- is in changelog\n\n### Feat\n\n- new file\n"
254+
full_changelog = "\n## Unreleased\n\n### Refactor\n\n- is in changelog\n\n### Feat\n\n- new file\n"
255255

256256
changelog_hook_mock.assert_called_with(full_changelog, full_changelog)

0 commit comments

Comments
 (0)