Skip to content

Commit

Permalink
Stop trying to check folder with names ending in .py (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsh9 authored Jul 17, 2024
1 parent 0247ef5 commit 94efc5f
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

## [0.5.6] - 2024-07-17

- Fixed

- Fixed a bug where _pydoclint_ treats folders whose names end with `.py` as
files

- Full diff
- https://github.com/jsh9/pydoclint/compare/0.5.5...0.5.6

## [0.5.5] - 2024-07-15

- Fixed
Expand All @@ -8,18 +18,26 @@
(https://github.com/jsh9/pydoclint/issues/151)

- Changed

- Changed the default of `--treat-property-methods-as-class-attributes` to
`False` to restore backward compatibility

- Full diff
- https://github.com/jsh9/pydoclint/compare/0.5.4...0.5.5

## [0.5.4] - 2024-07-14

- Added

- An option `--should-document-private-class-attributes` (if False, private
class attributes should not appear in the docstring)
- An option `--treat-property-methods-as-class-attributes` (if True,
`@property` methods are treated like class attributes and need to be
documented in the class docstring)

- Full diff
- https://github.com/jsh9/pydoclint/compare/0.5.3...0.5.4

## [0.5.3] - 2024-06-26

- Changed
Expand Down
3 changes: 3 additions & 0 deletions pydoclint/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,9 @@ def _checkFile(
requireReturnSectionWhenReturningNothing: bool = False,
requireYieldSectionWhenYieldingNothing: bool = False,
) -> List[Violation]:
if not filename.is_file(): # sometimes folder names can end with `.py`
return []

with open(filename, encoding='utf8') as fp:
src: str = ''.join(fp.readlines())

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pydoclint
version = 0.5.5
version = 0.5.6
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 Down
8 changes: 8 additions & 0 deletions tests/data/edge_cases/14_folders_ending_in_py.py/google.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def function1(arg1: str) -> None:
"""
Do something
Args:
arg1 (int): Arg 1
"""
pass
15 changes: 15 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,21 @@ def testNonAscii() -> None:
},
[],
),
(
'14_folders_ending_in_py.py', # This is actually a folder
{},
[], # Here we ensure that pydoclint doesn't treat this as a file
),
(
# Here we ensure that Python files under such folders (whose
# names end in `.py`) can still get recognized and checked.
'14_folders_ending_in_py.py/google.py',
{'style': 'google'},
[
'DOC105: Function `function1`: Argument names match, but type hints in these '
'args do not match: arg1'
],
),
],
)
def testEdgeCases(
Expand Down

0 comments on commit 94efc5f

Please sign in to comment.