Skip to content

Commit 9d1fa37

Browse files
committed
ci: Lint
1 parent 7f21d69 commit 9d1fa37

File tree

3 files changed

+29
-26
lines changed

3 files changed

+29
-26
lines changed

config/ruff.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ ignore = [
2626
"PLR0913", # Too many arguments to function call
2727
"PLR0915", # Too many statements
2828
"SLF001", # Private member accessed
29+
"TD001", # Invalid TODO tag "FIXME"
2930
"TD002", # Missing author in TODO
3031
"TD003", # Missing issue link for TODO
3132
"TRY003", # Avoid specifying long messages outside the exception class

src/griffe_typingdoc/_internal/extension.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ def _handle_attribute(self, attr: Attribute, /, *, node: ObjectNode | None = Non
2929

3030
module = dynamic if node else static
3131

32+
kwargs = {"node": node} if node else {}
3233
new_sections = (
33-
docstring := module._attribute_docs(attr, node=node),
34-
deprecated_section := module._deprecated_docs(attr, node=node),
35-
raises_section := module._raises_docs(attr, node=node),
36-
warns_section := module._warns_docs(attr, node=node),
34+
docstring := module._attribute_docs(attr, **kwargs),
35+
deprecated_section := module._deprecated_docs(attr, **kwargs),
36+
raises_section := module._raises_docs(attr, **kwargs),
37+
warns_section := module._warns_docs(attr, **kwargs),
3738
)
3839

3940
if not any(new_sections):
@@ -60,15 +61,16 @@ def _handle_function(self, func: Function, /, *, node: ObjectNode | None = None)
6061

6162
module = dynamic if node else static
6263

64+
kwargs = {"node": node} if node else {}
6365
new_sections = (
64-
deprecated_section := module._deprecated_docs(func, node=node),
65-
params_section := module._parameters_docs(func, node=node),
66-
other_params_section := module._other_parameters_docs(func, node=node),
67-
warns_section := module._warns_docs(func, node=node),
68-
raises_section := module._raises_docs(func, node=node),
69-
yields_section := module._yields_docs(func, node=node),
70-
receives_section := module._receives_docs(func, node=node),
71-
returns_section := module._returns_docs(func, node=node),
66+
deprecated_section := module._deprecated_docs(func, **kwargs),
67+
params_section := module._parameters_docs(func, **kwargs),
68+
other_params_section := module._other_parameters_docs(func, **kwargs),
69+
warns_section := module._warns_docs(func, **kwargs),
70+
raises_section := module._raises_docs(func, **kwargs),
71+
yields_section := module._yields_docs(func, **kwargs),
72+
receives_section := module._receives_docs(func, **kwargs),
73+
returns_section := module._returns_docs(func, **kwargs),
7274
)
7375

7476
if not any(new_sections):
@@ -110,9 +112,9 @@ def _handle_object(self, obj: Object | Alias) -> None:
110112
for member in obj.members.values():
111113
self._handle_object(member)
112114
elif obj.is_function:
113-
self._handle_function(obj) # type: ignore[arg-type]
115+
self._handle_function(obj) # ty:ignore[invalid-argument-type]
114116
elif obj.is_attribute:
115-
self._handle_attribute(obj) # type: ignore[arg-type]
117+
self._handle_attribute(obj) # ty:ignore[invalid-argument-type]
116118

117119
def on_package(
118120
self,

src/griffe_typingdoc/_internal/static.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def _attribute_docs(attr: Attribute, **kwargs: Any) -> str: # noqa: ARG001
106106
def _parameters_docs(func: Function, **kwargs: Any) -> DocstringSectionParameters | None: # noqa: ARG001
107107
params_data: dict[str, dict[str, Any]] = defaultdict(dict)
108108
for parameter in _no_self_params(func):
109-
stars = {ParameterKind.var_positional: "*", ParameterKind.var_keyword: "**"}.get(parameter.kind, "") # type: ignore[arg-type]
109+
stars = {ParameterKind.var_positional: "*", ParameterKind.var_keyword: "**"}.get(parameter.kind, "")
110110
param_name = f"{stars}{parameter.name}"
111111
metadata = _metadata(parameter.annotation)
112112
if "deprecated" in metadata or "doc" in metadata:
@@ -126,12 +126,12 @@ def _other_parameters_docs(func: Function, **kwargs: Any) -> DocstringSectionPar
126126
"typing.Annotated",
127127
"typing_extensions.Annotated",
128128
}:
129-
annotation = annotation.slice.elements[0] # type: ignore[union-attr]
129+
annotation = annotation.slice.elements[0]
130130
if isinstance(annotation, ExprSubscript) and annotation.canonical_path in {
131131
"typing.Unpack",
132132
"typing_extensions.Unpack",
133133
}:
134-
slice_path = annotation.slice.canonical_path # type: ignore[union-attr]
134+
slice_path = annotation.slice.canonical_path
135135
typed_dict = func.modules_collection[slice_path]
136136
params_data = {
137137
attr.name: {"annotation": attr.annotation, "description": description}
@@ -150,13 +150,13 @@ def _yields_docs(func: Function, **kwargs: Any) -> DocstringSectionYields | None
150150

151151
if isinstance(annotation, ExprSubscript):
152152
if annotation.canonical_path in {"typing.Generator", "typing_extensions.Generator"}:
153-
yield_annotation = annotation.slice.elements[0] # type: ignore[union-attr]
153+
yield_annotation = annotation.slice.elements[0] # ty:ignore[unresolved-attribute]
154154
elif annotation.canonical_path in {"typing.Iterator", "typing_extensions.Iterator"}:
155155
yield_annotation = annotation.slice
156156

157157
if yield_annotation:
158158
if isinstance(yield_annotation, ExprSubscript) and yield_annotation.is_tuple:
159-
yield_elements = yield_annotation.slice.elements # type: ignore[union-attr]
159+
yield_elements = yield_annotation.slice.elements # ty:ignore[unresolved-attribute]
160160
else:
161161
yield_elements = [yield_annotation]
162162
yield_data = [
@@ -178,11 +178,11 @@ def _receives_docs(func: Function, **kwargs: Any) -> DocstringSectionReceives |
178178
"typing.Generator",
179179
"typing_extensions.Generator",
180180
}:
181-
receive_annotation = annotation.slice.elements[1] # type: ignore[union-attr]
181+
receive_annotation = annotation.slice.elements[1] # ty:ignore[unresolved-attribute]
182182

183183
if receive_annotation:
184184
if isinstance(receive_annotation, ExprSubscript) and receive_annotation.is_tuple:
185-
receive_elements = receive_annotation.slice.elements # type: ignore[union-attr]
185+
receive_elements = receive_annotation.slice.elements
186186
else:
187187
receive_elements = [receive_annotation]
188188
receive_data = [
@@ -204,7 +204,7 @@ def _returns_docs(func: Function, **kwargs: Any) -> DocstringSectionReturns | No
204204
"typing.Generator",
205205
"typing_extensions.Generator",
206206
}:
207-
return_annotation = annotation.slice.elements[2] # type: ignore[union-attr]
207+
return_annotation = annotation.slice.elements[2] # ty:ignore[unresolved-attribute]
208208
elif isinstance(annotation, ExprSubscript) and annotation.canonical_path in {
209209
"typing.Annotated",
210210
"typing_extensions.Annotated",
@@ -213,7 +213,7 @@ def _returns_docs(func: Function, **kwargs: Any) -> DocstringSectionReturns | No
213213

214214
if return_annotation:
215215
if isinstance(return_annotation, ExprSubscript) and return_annotation.is_tuple:
216-
return_elements = return_annotation.slice.elements # type: ignore[union-attr]
216+
return_elements = return_annotation.slice.elements # ty:ignore[unresolved-attribute]
217217
else:
218218
return_elements = [return_annotation]
219219
return_data = [
@@ -231,7 +231,7 @@ def _warns_docs(attr_or_func: Attribute | Function, **kwargs: Any) -> DocstringS
231231
if attr_or_func.is_attribute:
232232
annotation = attr_or_func.annotation
233233
elif attr_or_func.is_function:
234-
annotation = attr_or_func.returns # type: ignore[union-attr]
234+
annotation = attr_or_func.returns # ty:ignore[unresolved-attribute]
235235
else:
236236
return None
237237
metadata = _metadata(annotation)
@@ -244,7 +244,7 @@ def _raises_docs(attr_or_func: Attribute | Function, **kwargs: Any) -> Docstring
244244
if attr_or_func.is_attribute:
245245
annotation = attr_or_func.annotation
246246
elif attr_or_func.is_function:
247-
annotation = attr_or_func.returns # type: ignore[union-attr]
247+
annotation = attr_or_func.returns # ty:ignore[unresolved-attribute]
248248
else:
249249
return None
250250
metadata = _metadata(annotation)
@@ -260,7 +260,7 @@ def _deprecated_docs(
260260
if attr_or_func.is_attribute:
261261
annotation = attr_or_func.annotation
262262
elif attr_or_func.is_function:
263-
annotation = attr_or_func.returns # type: ignore[union-attr]
263+
annotation = attr_or_func.returns # ty:ignore[unresolved-attribute]
264264
else:
265265
return None
266266
metadata = _metadata(annotation)

0 commit comments

Comments
 (0)