Skip to content

Commit

Permalink
Fix union return type (Google style) (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsh9 authored Aug 18, 2023
1 parent 35124d8 commit 9c8903d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## [0.1.9] - 2023-08-18

- Fixed
- Fixed a bug where union-style return types (such as `int | str`) in
Google-style docstrings cannot be correctly parsed
([Issue #66](https://github.com/jsh9/pydoclint/issues/66))
- Full diff
- https://github.com/jsh9/pydoclint/compare/0.1.8...0.1.9

## [0.1.8] - 2023-08-16

- Fixed
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pydoclint
version = 0.1.8
version = 0.1.9
description = A Python docstring linter that checks arguments, returns, yields, and raises sections
long_description = file: README.md
long_description_content_type = text/markdown
Expand All @@ -18,7 +18,7 @@ install_requires =
flake8>=4
click>=8.0.0
numpydoc>=1.5.0
docstring_parser>=0.15
docstring_parser_fork>=0.0.1
tomli>=2.0.1; python_version<'3.11'
python_requires = >=3.8

Expand Down
19 changes: 19 additions & 0 deletions tests/data/edge_cases/edge_case_03_union_return_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# From this issue: https://github.com/jsh9/pydoclint/issues/66


def myFunc(arg1: int | str) -> str | bool | None:
"""
The docstring parser for Google-style docstring should be able to
parse the docstring without issues.
And then, pydoclint should be able to detect the discrepancy
between the return type hints in the signature and in the
docstring.
Args:
arg1 (int | str): Arg 1
Returns:
str | bool | float: The return value
"""
pass
9 changes: 9 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,15 @@ def testNonAscii() -> None:
'DOC105: Function `func3`: Argument names match, but type hints do not match ',
],
),
(
'edge_case_03_union_return_type.py',
{'style': 'google'},
[
'DOC203: Function `myFunc` return type(s) in docstring not consistent with '
"the return annotation. Return annotation types: ['str | bool | None']; "
"docstring return section types: ['str | bool | float']"
],
),
],
)
def testEdgeCases(
Expand Down

0 comments on commit 9c8903d

Please sign in to comment.