Skip to content

Commit

Permalink
release/v1.7.3 (#238)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
weibullguy authored Jun 23, 2023
1 parent 7502a15 commit 53c598e
Show file tree
Hide file tree
Showing 11 changed files with 253 additions and 66 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/do-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# - Gets list of PR labels.
# - If 'release' label:
# - Get release version using Poetry.
# - Generate new CHANGELOG.
# - Tag repository with new version tag.
# - Build the release.
# - Draft a new GitHub release.
# - Upload the wheel to the new GitHub release.
Expand Down
52 changes: 43 additions & 9 deletions .github/workflows/on-push-tag.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# This workflow runs when a version tag is pushed.
#
# - Get new tag.
# - If release tag:
# - Get next semantic version.
# - Close old milestones.
# - Create new minor version milestone.
# - Create new major version milestone.
# - If version tag:
# - If release condidate tag:
# - Build the pre-release.
# - Cut GitHub pre-release.
# - Upload wheel to pre-release.
# - If release tag:
# - Generate new CHANGELOG.
# - Get next semantic version.
# - Close old milestones.
# - Create new minor version milestone.
# - Create new major version milestone.
name: Version Tag Workflow

on:
Expand All @@ -28,16 +34,44 @@ jobs:
id: newversion
run: |
tag=${GITHUB_REF/refs\/tags\//}
version=$(echo $tag | sed 's/-rc[0-9]*//')
if [[ $tag == *"-rc"* ]]; then
echo "do_prerelease=1" >> $GItHUB_ENV
fi
if [[ $tag != *"-rc"* ]]; then
echo "do_changelog=1" >> $GITHUB_ENV
echo "tag=$(echo $tag)" >> $GITHUB_OUTPUT
echo "version=$(echo $version)" >> $GITHUB_OUTPUT
fi
echo "tag=$(echo $tag)" >> $GITHUB_OUTPUT
echo "New tag is: $tag"
echo "New version is: $version"
echo "GitHub ref: ${{ github.ref }}"
- name: Build pre-release
id: build
if: ${{ env.do_prerelease == 1 }}
run: |
pip install -U pip poetry twine
poetry build && twine check dist/* && echo "build_ok=1" >> $GITHUB_ENV
- name: Cut pre-release
id: cutprerelease
if: ${{ env.build_ok == 1 }}
uses: release-drafter/release-drafter@v5
with:
name: $env.tag
tag: $env.tag
version: $env.tag
prerelease: true
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload wheel to GitHub pre-release
id: upload-wheel
if: ${{ env.build_ok == 1 }}
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ steps.cutprerelease.outputs.upload_url }}
asset_path: ./dist/*.whl

- name: Generate release changelog
uses: heinrichreimer/github-changelog-generator-action@master
if: ${{ env.do_changelog == 1 }}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
project = "docformatter"
copyright = "2022-2023, Steven Myint"
author = "Steven Myint"
release = "1.7.3-alpha"
release = "1.7.3"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "docformatter"
version = "1.7.3-alpha"
version = "1.7.3"
description = "Formats docstrings to follow PEP 257"
authors = ["Steven Myint"]
maintainers = [
Expand Down Expand Up @@ -99,6 +99,12 @@ non-cap = [
"docformatter",
]

[tool.mypy]
allow_subclassing_any = true
follow_imports = "skip"
implicit_reexport = true
ignore_missing_imports = true

[tool.pydocstyle]
convention = "pep257"

Expand Down
2 changes: 0 additions & 2 deletions src/docformatter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"""Formats docstrings to follow PEP 257."""


from __future__ import absolute_import, division, print_function, unicode_literals

# Standard Library Imports
import contextlib
import signal
Expand Down
2 changes: 1 addition & 1 deletion src/docformatter/__pkginfo__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
# SOFTWARE.
"""Package information for docformatter."""

__version__ = "1.7.3-alpha"
__version__ = "1.7.3"
28 changes: 16 additions & 12 deletions src/docformatter/encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

# Standard Library Imports
import collections
import io
import locale
import sys
from typing import Dict, List
Expand All @@ -46,11 +45,9 @@ class Encoder:
def __init__(self):
"""Initialize an Encoder instance."""
self.encoding = "latin-1"
self.system_encoding = (
locale.getpreferredencoding() or sys.getdefaultencoding()
)
self.system_encoding = locale.getpreferredencoding() or sys.getdefaultencoding()

def do_detect_encoding(self, filename: str) -> None:
def do_detect_encoding(self, filename) -> None:
"""Return the detected file encoding.
Parameters
Expand All @@ -67,7 +64,7 @@ def do_detect_encoding(self, filename: str) -> None:
except (SyntaxError, LookupError, UnicodeDecodeError):
self.encoding = "latin-1"

def do_find_newline(self, source: List[str]) -> Dict[int, int]:
def do_find_newline(self, source: List[str]) -> str:
"""Return type of newline used in source.
Parameters
Expand All @@ -77,12 +74,12 @@ def do_find_newline(self, source: List[str]) -> Dict[int, int]:
Returns
-------
counter : dict
A dict with the count of new line types found.
newline : str
The most prevalent new line type found.
"""
assert not isinstance(source, unicode)

counter = collections.defaultdict(int)
counter: Dict[str, int] = collections.defaultdict(int)
for line in source:
if line.endswith(self.CRLF):
counter[self.CRLF] += 1
Expand All @@ -91,9 +88,16 @@ def do_find_newline(self, source: List[str]) -> Dict[int, int]:
elif line.endswith(self.LF):
counter[self.LF] += 1

return (sorted(counter, key=counter.get, reverse=True) or [self.LF])[0]
return (
sorted(
counter,
key=counter.get, # type: ignore
reverse=True,
)
or [self.LF]
)[0]

def do_open_with_encoding(self, filename: str, mode: str = "r"):
def do_open_with_encoding(self, filename, mode: str = "r"):
"""Return opened file with a specific encoding.
Parameters
Expand All @@ -108,6 +112,6 @@ def do_open_with_encoding(self, filename: str, mode: str = "r"):
contents : TextIO
The contents of the file.
"""
return io.open(
return open(
filename, mode=mode, encoding=self.encoding, newline=""
) # Preserve line endings
7 changes: 5 additions & 2 deletions src/docformatter/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def do_format_files(self):
try:
result = self._do_format_file(filename)
outcomes[result] += 1
except IOError as exception:
except OSError as exception:
outcomes[FormatResult.error] += 1
print(unicode(exception), file=self.stderror)

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

# Leave docstrings with only field lists alone.
if _syntax.is_some_sort_of_field_list(summary, self.args.style):
if _syntax.is_some_sort_of_field_list(
summary,
self.args.style,
):
return docstring

# Leave docstrings with underlined descriptions alone.
Expand Down
Loading

0 comments on commit 53c598e

Please sign in to comment.