Skip to content

Commit dd09efd

Browse files
authored
Fix typo in flake8 config; fix LN001/002 violations (#226)
1 parent 1b2de9e commit dd09efd

File tree

10 files changed

+28
-22
lines changed

10 files changed

+28
-22
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Change Log
22

3-
## [unpublished]
3+
## [0.6.3] - 2025-03-30
44

55
- Added
66
- Added `DOC504` and a config option
@@ -9,6 +9,11 @@
99
declaration is required in the docstring. Otherwise `DOC504` is raised.
1010
(This changes the behavior introduced in v0.6.1.)
1111
- Added a new config option `--ignore-private-args` (default to `False`)
12+
- Changed
13+
- Canceled the ignoring of `LN002` violation in flake8 config in tox
14+
- Fix a typo in maximum line length setting in flake8 config in tox
15+
- Full diff
16+
- https://github.com/jsh9/pydoclint/compare/0.6.2...0.6.3
1217

1318
## [0.6.2] - 2025-02-17
1419

pydoclint/utils/arg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ def _typeHintsEq(cls, hint1: str, hint2: str) -> bool:
120120
# >>> "ghi",
121121
# >>> ]
122122
try:
123-
hint1_: str = unparseName(ast.parse(stripQuotes(hint1))) # type:ignore[arg-type,assignment]
123+
hint1_: str = unparseName(ast.parse(stripQuotes(hint1))) # type:ignore[arg-type,assignment] # noqa: LN002
124124
except SyntaxError:
125125
hint1_ = hint1
126126

127127
try:
128-
hint2_: str = unparseName(ast.parse(stripQuotes(hint2))) # type:ignore[arg-type,assignment]
128+
hint2_: str = unparseName(ast.parse(stripQuotes(hint2))) # type:ignore[arg-type,assignment] # noqa: LN002
129129
except SyntaxError:
130130
hint2_ = hint2
131131

@@ -263,7 +263,7 @@ def _unparseTargetAndAppendToInfoList(
263263
msg2: str = (
264264
f' astAssign.targets[{i}] is of type {type(target)}.'
265265
if j is None
266-
else f' astAssign.targets[{i}].elts[{j}] is of type {type(target)}.'
266+
else f' astAssign.targets[{i}].elts[{j}] is of type {type(target)}.' # noqa: LN001
267267
)
268268
msg: str = msg1 + msg2
269269
raise EdgeCaseError(msg) from ex

pydoclint/utils/invisibleChars.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def replaceInvisibleChars(text: str) -> str:
22
"""Replace invisible characters so that AST can correctly parse the code"""
33
invisibleToSpace = {
4-
'\uFEFF': ' ', # Byte order mark (zero-width but might act as a separator)
4+
'\uFEFF': ' ', # Byte order mark: 0-width but might act as a separator
55
}
66

77
invisibleToEmpty = {

pydoclint/utils/return_anno.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ def decompose(self) -> list[str]:
5757
# because we don't know the tuple's length
5858
return [self.annotation]
5959

60-
parsedBody0: ast.Expr = ast.parse(insideTuple).body[0] # type:ignore[assignment]
61-
if isinstance(parsedBody0.value, ast.Name): # like this: Tuple[int]
60+
parsedBody0: ast.Expr = ast.parse(insideTuple).body[0] # type:ignore[assignment] # noqa: LN002
61+
if isinstance(parsedBody0.value, ast.Name): # like this: Tuple[int] # noqa: LN002
6262
return [insideTuple]
6363

64-
if isinstance(parsedBody0.value, ast.Tuple): # like Tuple[int, str]
64+
if isinstance(parsedBody0.value, ast.Tuple): # like Tuple[int, str] # noqa: LN002
6565
elts: list[ast.expr] = parsedBody0.value.elts
6666
return [unparseName(_) for _ in elts] # type:ignore[misc]
6767

@@ -72,7 +72,7 @@ def decompose(self) -> list[str]:
7272
def _isTuple(self) -> bool:
7373
try:
7474
assert self.annotation is not None # to help mypy understand type
75-
annoHead = ast.parse(self.annotation).body[0].value.value.id # type:ignore[attr-defined]
75+
annoHead = ast.parse(self.annotation).body[0].value.value.id # type:ignore[attr-defined] # noqa: LN002
7676
return annoHead in {'tuple', 'Tuple'}
7777
except Exception:
7878
return False

pydoclint/utils/return_yield_raise.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,14 @@ def _getRaisedExceptions( # noqa: C901
163163
if isinstance(child.exc, ast.Attribute):
164164
# case: looks like m.n.exception
165165
exceptionName = unparseName(child.exc)
166-
assert isinstance(exceptionName, str) # make mypy happy
166+
assert isinstance(exceptionName, str) # satisfy mypy
167167
yield exceptionName
168168
elif isinstance(child.exc, ast.Call) and isinstance(
169169
child.exc.func, ast.Attribute
170170
):
171171
# case: looks like m.n.exception()
172172
exceptionName = unparseName(child.exc.func)
173-
assert isinstance(exceptionName, str) # make mypy happy
173+
assert isinstance(exceptionName, str) # satisfy mypy
174174
yield exceptionName
175175
elif (
176176
currentParentExceptHandler
@@ -180,7 +180,8 @@ def _getRaisedExceptions( # noqa: C901
180180
# case: "except <> as e; raise e" -> we must yield the
181181
# stuff in <>
182182
#
183-
# Note: if subnode.id != currentParentExceptHandler.name,
183+
# Note:
184+
# if subnode.id != currentParentExceptHandler.name,
184185
# the user is raising something not bound by
185186
# this exception handler (meaning we should fall
186187
# through to yielding the subnode.id)

pydoclint/utils/visitor_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def extractYieldTypeFromGeneratorOrIteratorAnnotation(
517517
)
518518
else:
519519
yieldType = unparseName(
520-
ast.parse(returnAnnoText).body[0].value.slice.elts[0] # type:ignore[attr-defined,arg-type]
520+
ast.parse(returnAnnoText).body[0].value.slice.elts[0] # type:ignore[attr-defined,arg-type] # noqa: LN002
521521
)
522522
elif hasIteratorOrIterableAsReturnAnnotation:
523523
yieldType = unparseName(
@@ -542,7 +542,7 @@ def extractReturnTypeFromGenerator(returnAnnoText: str | None) -> str | None:
542542
try:
543543
if sys.version_info >= (3, 9):
544544
returnType = unparseName(
545-
ast.parse(returnAnnoText).body[0].value.slice.elts[-1] # type:ignore[attr-defined,arg-type]
545+
ast.parse(returnAnnoText).body[0].value.slice.elts[-1] # type:ignore[attr-defined,arg-type] # noqa: LN002
546546
)
547547
else:
548548
returnType = unparseName(

pydoclint/visitor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def _checkClassDocstringAndConstructorDocstrings( # noqa: C901
312312

313313
classDocstring: str = getDocstring(parent_)
314314

315-
if len(initDocstring) == 0: # __init__() doesn't have its own docstring
315+
if len(initDocstring) == 0: # __init__() doesn't have own docstring
316316
# Check class docstring instead, because that's what we care
317317
# about when checking the class constructor.
318318
return classDocstring
@@ -831,8 +831,8 @@ def my_function(num: int) -> Generator[int, None, str]:
831831
returnAnnoText=returnAnno.annotation,
832832
)
833833
# If "Generator[...]" is put in the return type annotation,
834-
# we don't need a "Returns" section in the docstring. Instead,
835-
# we need a "Yields" section.
834+
# we don't need a "Returns" section in the docstring.
835+
# Instead, we need a "Yields" section.
836836
if self.requireReturnSectionWhenReturningNothing:
837837
violations.append(v201)
838838
elif retTypeInGenerator not in {'None', 'NoReturn'}:
@@ -870,15 +870,15 @@ def my_function(num: int) -> Generator[int, None, str]:
870870
yieldType: str | None = extract(
871871
returnAnnoText=returnAnno.annotation,
872872
hasGeneratorAsReturnAnnotation=hasGenAsRetAnno,
873-
hasIteratorOrIterableAsReturnAnnotation=hasIterAsRetAnno,
873+
hasIteratorOrIterableAsReturnAnnotation=hasIterAsRetAnno, # noqa: LN001
874874
)
875875
checkYieldTypesForViolations(
876876
returnAnnotation=ReturnAnnotation(yieldType),
877877
violationList=violations,
878878
yieldSection=yieldSec,
879879
violation=v404,
880880
hasGeneratorAsReturnAnnotation=hasGenAsRetAnno,
881-
hasIteratorOrIterableAsReturnAnnotation=hasIterAsRetAnno,
881+
hasIteratorOrIterableAsReturnAnnotation=hasIterAsRetAnno, # noqa: LN001
882882
requireYieldSectionWhenYieldingNothing=(
883883
self.requireYieldSectionWhenYieldingNothing
884884
),

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = pydoclint
3-
version = 0.6.2
3+
version = 0.6.3
44
description = A Python docstring linter that checks arguments, returns, yields, and raises sections
55
long_description = file: README.md
66
long_description_content_type = text/markdown

tests/utils/test_returns_yields_raise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ def func9(d):
428428
raise
429429
430430
def func10():
431-
# no variable resolution is done. this function looks like it throws GError.
431+
# no variable resolution is done. this func looks like it throws GError.
432432
GError = ZeroDivisionError
433433
try:
434434
1 / 0

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ commands =
9898

9999

100100
[flake8]
101-
max-line-length = 88
101+
max-line-length = 79
102102
extend-ignore =
103103
# E501: line length
104104
E501,

0 commit comments

Comments
 (0)