Skip to content

Commit 53c598e

Browse files
authored
release/v1.7.3 (#238)
* chore: update version strings * fix: treating in-line reST like field list * chore: update version strings * fix: adding newline between field lists * chore: update version strings * fix: wrapping alembic headers * chore: update version strings * refactor: apply pyupgrade to code base * chore: update GH workflows to cut pre-releases * chore: update version strings
1 parent 7502a15 commit 53c598e

File tree

11 files changed

+253
-66
lines changed

11 files changed

+253
-66
lines changed

Diff for: .github/workflows/do-release.yml

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# - Gets list of PR labels.
44
# - If 'release' label:
55
# - Get release version using Poetry.
6-
# - Generate new CHANGELOG.
7-
# - Tag repository with new version tag.
86
# - Build the release.
97
# - Draft a new GitHub release.
108
# - Upload the wheel to the new GitHub release.

Diff for: .github/workflows/on-push-tag.yml

+43-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
# This workflow runs when a version tag is pushed.
22
#
33
# - Get new tag.
4-
# - If release tag:
5-
# - Get next semantic version.
6-
# - Close old milestones.
7-
# - Create new minor version milestone.
8-
# - Create new major version milestone.
4+
# - If version tag:
5+
# - If release condidate tag:
6+
# - Build the pre-release.
7+
# - Cut GitHub pre-release.
8+
# - Upload wheel to pre-release.
9+
# - If release tag:
10+
# - Generate new CHANGELOG.
11+
# - Get next semantic version.
12+
# - Close old milestones.
13+
# - Create new minor version milestone.
14+
# - Create new major version milestone.
915
name: Version Tag Workflow
1016

1117
on:
@@ -28,16 +34,44 @@ jobs:
2834
id: newversion
2935
run: |
3036
tag=${GITHUB_REF/refs\/tags\//}
31-
version=$(echo $tag | sed 's/-rc[0-9]*//')
37+
if [[ $tag == *"-rc"* ]]; then
38+
echo "do_prerelease=1" >> $GItHUB_ENV
39+
fi
3240
if [[ $tag != *"-rc"* ]]; then
3341
echo "do_changelog=1" >> $GITHUB_ENV
34-
echo "tag=$(echo $tag)" >> $GITHUB_OUTPUT
35-
echo "version=$(echo $version)" >> $GITHUB_OUTPUT
3642
fi
43+
echo "tag=$(echo $tag)" >> $GITHUB_OUTPUT
3744
echo "New tag is: $tag"
38-
echo "New version is: $version"
3945
echo "GitHub ref: ${{ github.ref }}"
4046
47+
- name: Build pre-release
48+
id: build
49+
if: ${{ env.do_prerelease == 1 }}
50+
run: |
51+
pip install -U pip poetry twine
52+
poetry build && twine check dist/* && echo "build_ok=1" >> $GITHUB_ENV
53+
54+
- name: Cut pre-release
55+
id: cutprerelease
56+
if: ${{ env.build_ok == 1 }}
57+
uses: release-drafter/release-drafter@v5
58+
with:
59+
name: $env.tag
60+
tag: $env.tag
61+
version: $env.tag
62+
prerelease: true
63+
publish: true
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
67+
- name: Upload wheel to GitHub pre-release
68+
id: upload-wheel
69+
if: ${{ env.build_ok == 1 }}
70+
uses: shogo82148/actions-upload-release-asset@v1
71+
with:
72+
upload_url: ${{ steps.cutprerelease.outputs.upload_url }}
73+
asset_path: ./dist/*.whl
74+
4175
- name: Generate release changelog
4276
uses: heinrichreimer/github-changelog-generator-action@master
4377
if: ${{ env.do_changelog == 1 }}

Diff for: docs/source/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
project = "docformatter"
1212
copyright = "2022-2023, Steven Myint"
1313
author = "Steven Myint"
14-
release = "1.7.3-alpha"
14+
release = "1.7.3"
1515

1616
# -- General configuration ---------------------------------------------------
1717
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

Diff for: pyproject.toml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "docformatter"
3-
version = "1.7.3-alpha"
3+
version = "1.7.3"
44
description = "Formats docstrings to follow PEP 257"
55
authors = ["Steven Myint"]
66
maintainers = [
@@ -99,6 +99,12 @@ non-cap = [
9999
"docformatter",
100100
]
101101

102+
[tool.mypy]
103+
allow_subclassing_any = true
104+
follow_imports = "skip"
105+
implicit_reexport = true
106+
ignore_missing_imports = true
107+
102108
[tool.pydocstyle]
103109
convention = "pep257"
104110

Diff for: src/docformatter/__main__.py

-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
"""Formats docstrings to follow PEP 257."""
2525

2626

27-
from __future__ import absolute_import, division, print_function, unicode_literals
28-
2927
# Standard Library Imports
3028
import contextlib
3129
import signal

Diff for: src/docformatter/__pkginfo__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
# SOFTWARE.
2424
"""Package information for docformatter."""
2525

26-
__version__ = "1.7.3-alpha"
26+
__version__ = "1.7.3"

Diff for: src/docformatter/encode.py

+16-12
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
# Standard Library Imports
2727
import collections
28-
import io
2928
import locale
3029
import sys
3130
from typing import Dict, List
@@ -46,11 +45,9 @@ class Encoder:
4645
def __init__(self):
4746
"""Initialize an Encoder instance."""
4847
self.encoding = "latin-1"
49-
self.system_encoding = (
50-
locale.getpreferredencoding() or sys.getdefaultencoding()
51-
)
48+
self.system_encoding = locale.getpreferredencoding() or sys.getdefaultencoding()
5249

53-
def do_detect_encoding(self, filename: str) -> None:
50+
def do_detect_encoding(self, filename) -> None:
5451
"""Return the detected file encoding.
5552
5653
Parameters
@@ -67,7 +64,7 @@ def do_detect_encoding(self, filename: str) -> None:
6764
except (SyntaxError, LookupError, UnicodeDecodeError):
6865
self.encoding = "latin-1"
6966

70-
def do_find_newline(self, source: List[str]) -> Dict[int, int]:
67+
def do_find_newline(self, source: List[str]) -> str:
7168
"""Return type of newline used in source.
7269
7370
Parameters
@@ -77,12 +74,12 @@ def do_find_newline(self, source: List[str]) -> Dict[int, int]:
7774
7875
Returns
7976
-------
80-
counter : dict
81-
A dict with the count of new line types found.
77+
newline : str
78+
The most prevalent new line type found.
8279
"""
8380
assert not isinstance(source, unicode)
8481

85-
counter = collections.defaultdict(int)
82+
counter: Dict[str, int] = collections.defaultdict(int)
8683
for line in source:
8784
if line.endswith(self.CRLF):
8885
counter[self.CRLF] += 1
@@ -91,9 +88,16 @@ def do_find_newline(self, source: List[str]) -> Dict[int, int]:
9188
elif line.endswith(self.LF):
9289
counter[self.LF] += 1
9390

94-
return (sorted(counter, key=counter.get, reverse=True) or [self.LF])[0]
91+
return (
92+
sorted(
93+
counter,
94+
key=counter.get, # type: ignore
95+
reverse=True,
96+
)
97+
or [self.LF]
98+
)[0]
9599

96-
def do_open_with_encoding(self, filename: str, mode: str = "r"):
100+
def do_open_with_encoding(self, filename, mode: str = "r"):
97101
"""Return opened file with a specific encoding.
98102
99103
Parameters
@@ -108,6 +112,6 @@ def do_open_with_encoding(self, filename: str, mode: str = "r"):
108112
contents : TextIO
109113
The contents of the file.
110114
"""
111-
return io.open(
115+
return open(
112116
filename, mode=mode, encoding=self.encoding, newline=""
113117
) # Preserve line endings

Diff for: src/docformatter/format.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def do_format_files(self):
256256
try:
257257
result = self._do_format_file(filename)
258258
outcomes[result] += 1
259-
except IOError as exception:
259+
except OSError as exception:
260260
outcomes[FormatResult.error] += 1
261261
print(unicode(exception), file=self.stderror)
262262

@@ -460,7 +460,10 @@ def _do_format_docstring( # noqa PLR0911
460460
summary, description = _strings.split_summary_and_description(contents)
461461

462462
# Leave docstrings with only field lists alone.
463-
if _syntax.is_some_sort_of_field_list(summary, self.args.style):
463+
if _syntax.is_some_sort_of_field_list(
464+
summary,
465+
self.args.style,
466+
):
464467
return docstring
465468

466469
# Leave docstrings with underlined descriptions alone.

0 commit comments

Comments
 (0)