Skip to content

Commit 1236192

Browse files
committed
chore: Update ty comments
1 parent 75c1236 commit 1236192

21 files changed

Lines changed: 71 additions & 71 deletions

File tree

packages/griffecli/src/griffecli/_internal/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def dump(
414414
if per_package_output:
415415
for package_name, data in data_packages.items():
416416
serialized = data.as_json(indent=2, full=full, sort_keys=True)
417-
_print_data(serialized, output.format(package=package_name)) # ty:ignore[possibly-missing-attribute]
417+
_print_data(serialized, output.format(package=package_name)) # ty:ignore[unresolved-attribute]
418418
else:
419419
serialized = json.dumps(data_packages, cls=JSONEncoder, indent=2, full=full, sort_keys=True)
420420
_print_data(serialized, output)

packages/griffelib/src/griffe/_internal/agents/inspector.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,13 @@ def __init__(
156156
self.parent: Module | None = parent
157157
"""An optional parent for the final module object."""
158158

159-
self.current: Module | Class = None
159+
self.current: Module | Class = None # ty:ignore[invalid-assignment]
160160
"""The current object being inspected."""
161161

162162
self.docstring_parser: DocstringStyle | Parser | None = docstring_parser
163163
"""The docstring parser to use."""
164164

165-
self.docstring_options: DocstringOptions = docstring_options or {}
165+
self.docstring_options: DocstringOptions = docstring_options or {} # ty:ignore[invalid-assignment]
166166
"""The docstring parsing options."""
167167

168168
self.lines_collection: LinesCollection = lines_collection or LinesCollection()
@@ -581,7 +581,7 @@ def handle_attribute(self, node: ObjectNode, annotation: str | Expr | None = Non
581581
analysis="dynamic",
582582
)
583583
attribute.labels |= labels
584-
parent.set_member(node.name, attribute) # ty:ignore[possibly-missing-attribute]
584+
parent.set_member(node.name, attribute) # ty:ignore[unresolved-attribute]
585585

586586
if node.name == "__all__":
587587
parent.exports = list(node.obj) # ty:ignore[invalid-assignment]

packages/griffelib/src/griffe/_internal/agents/nodes/runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def module_path(self) -> str | None:
113113
except ValueError:
114114
return None
115115
try:
116-
return module.__spec__.name # ty:ignore[possibly-missing-attribute]
116+
return module.__spec__.name # ty:ignore[unresolved-attribute]
117117
except AttributeError:
118118
return getattr(module, "__name__", None)
119119
else:

packages/griffelib/src/griffe/_internal/agents/visitor.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ def __init__(
176176
self.parent: Module | None = parent
177177
"""An optional parent for the final module object."""
178178

179-
self.current: Module | Class = None
179+
self.current: Module | Class = None # ty:ignore[invalid-assignment]
180180
"""The current object being visited."""
181181

182182
self.docstring_parser: DocstringStyle | Parser | None = docstring_parser
183183
"""The docstring parser to use."""
184184

185-
self.docstring_options: DocstringOptions = docstring_options or {}
185+
self.docstring_options: DocstringOptions = docstring_options or {} # ty:ignore[invalid-assignment]
186186
"""The docstring parsing options."""
187187

188188
self.lines_collection: LinesCollection = lines_collection or LinesCollection()
@@ -231,7 +231,7 @@ def _get_type_parameters(
231231
member=scope,
232232
),
233233
)
234-
for type_param in node.type_params # ty:ignore[possibly-missing-attribute,unused-ignore-comment,unused-ignore-comment]
234+
for type_param in node.type_params # ty:ignore[unresolved-attribute,unused-ignore-comment,unused-ignore-comment]
235235
]
236236
else:
237237

@@ -692,8 +692,8 @@ def handle_attribute(
692692
if existing_member.docstring and not docstring:
693693
docstring = existing_member.docstring
694694
with suppress(AttributeError):
695-
if existing_member.annotation and not annotation: # ty:ignore[possibly-missing-attribute]
696-
annotation = existing_member.annotation # ty:ignore[possibly-missing-attribute]
695+
if existing_member.annotation and not annotation: # ty:ignore[unresolved-attribute]
696+
annotation = existing_member.annotation # ty:ignore[unresolved-attribute]
697697

698698
attribute = Attribute(
699699
name=name,
@@ -741,13 +741,13 @@ def visit_augassign(self, node: ast.AugAssign) -> None:
741741
"""
742742
with suppress(AttributeError):
743743
all_augment = (
744-
node.target.id == "__all__" # ty:ignore[possibly-missing-attribute]
744+
node.target.id == "__all__" # ty:ignore[unresolved-attribute]
745745
and self.current.is_module
746746
and isinstance(node.op, ast.Add)
747747
)
748748
if all_augment:
749749
# We assume `exports` is not `None` at this point.
750-
self.current.exports.extend( # ty:ignore[possibly-missing-attribute]
750+
self.current.exports.extend( # ty:ignore[unresolved-attribute]
751751
[
752752
name if isinstance(name, str) else ExprName(name.name, parent=name.parent)
753753
for name in safe_get__all__(node, self.current) # ty:ignore[invalid-argument-type]

packages/griffelib/src/griffe/_internal/diff.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,19 @@ def explain(self, style: ExplanationStyle = ExplanationStyle.ONE_LINE) -> str:
131131
@property
132132
def _filepath(self) -> Path:
133133
if self.obj.is_alias:
134-
return self.obj.parent.filepath # ty:ignore[invalid-return-type, possibly-missing-attribute]
134+
return self.obj.parent.filepath # ty:ignore[invalid-return-type, unresolved-attribute]
135135
return self.obj.filepath # ty:ignore[invalid-return-type]
136136

137137
@property
138138
def _relative_filepath(self) -> Path:
139139
if self.obj.is_alias:
140-
return self.obj.parent.relative_filepath # ty:ignore[possibly-missing-attribute]
140+
return self.obj.parent.relative_filepath # ty:ignore[unresolved-attribute]
141141
return self.obj.relative_filepath
142142

143143
@property
144144
def _relative_package_filepath(self) -> Path:
145145
if self.obj.is_alias:
146-
return self.obj.parent.relative_package_filepath # ty:ignore[possibly-missing-attribute]
146+
return self.obj.parent.relative_package_filepath # ty:ignore[unresolved-attribute]
147147
return self.obj.relative_package_filepath
148148

149149
@property
@@ -167,7 +167,7 @@ def _canonical_path(self) -> str:
167167
@property
168168
def _module_path(self) -> str:
169169
if self.obj.is_alias:
170-
return self.obj.parent.module.path # ty:ignore[possibly-missing-attribute]
170+
return self.obj.parent.module.path # ty:ignore[unresolved-attribute]
171171
return self.obj.module.path
172172

173173
@property
@@ -182,7 +182,7 @@ def _lineno(self) -> int:
182182
if self.kind is BreakageKind.OBJECT_REMOVED and self._relative_filepath != self._location:
183183
return 0
184184
if self.obj.is_alias:
185-
return self.obj.alias_lineno or 0 # ty:ignore[possibly-missing-attribute]
185+
return self.obj.alias_lineno or 0 # ty:ignore[unresolved-attribute]
186186
return self.obj.lineno or 0
187187

188188
def _format_location(self, *, colors: bool = True) -> str:
@@ -566,8 +566,8 @@ def _alias_incompatibilities(
566566
seen_paths: set[str],
567567
) -> Iterable[Breakage]:
568568
try:
569-
old_member = old_obj.target if old_obj.is_alias else old_obj # ty:ignore[possibly-missing-attribute]
570-
new_member = new_obj.target if new_obj.is_alias else new_obj # ty:ignore[possibly-missing-attribute]
569+
old_member = old_obj.target if old_obj.is_alias else old_obj # ty:ignore[unresolved-attribute]
570+
new_member = new_obj.target if new_obj.is_alias else new_obj # ty:ignore[unresolved-attribute]
571571
except AliasResolutionError:
572572
logger.debug("API check: %s | %s: skip alias with unknown target", old_obj.path, new_obj.path)
573573
return

packages/griffelib/src/griffe/_internal/docstrings/auto.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def infer_docstring_style(
162162
if method == "max_sections":
163163
style_sections = {}
164164
for style in style_order:
165-
style_sections[style] = parsers[style](docstring, **per_style_options.get(style, {})) # ty:ignore[possibly-missing-attribute]
165+
style_sections[style] = parsers[style](docstring, **per_style_options.get(style, {})) # ty:ignore[unresolved-attribute]
166166
style_lengths = {style: len(section) for style, section in style_sections.items()}
167167
max_sections = max(style_lengths.values())
168168
for style in style_order:
@@ -220,5 +220,5 @@ def parse_auto(
220220
per_style_options=per_style_options,
221221
)
222222
if sections is None:
223-
return parse(docstring, style, **per_style_options.get(style, {})) # ty:ignore[no-matching-overload, possibly-missing-attribute]
223+
return parse(docstring, style, **per_style_options.get(style, {})) # ty:ignore[no-matching-overload, unresolved-attribute]
224224
return sections

packages/griffelib/src/griffe/_internal/docstrings/google.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,20 +311,20 @@ def _read_type_parameters_section(
311311
name = name_with_bound
312312
# try to use the annotation from the signature
313313
try:
314-
bound = docstring.parent.type_parameters[name].annotation # ty:ignore[possibly-missing-attribute]
314+
bound = docstring.parent.type_parameters[name].annotation # ty:ignore[unresolved-attribute]
315315
except (AttributeError, KeyError):
316316
bound = None
317317

318318
try:
319-
default = docstring.parent.type_parameters[name].default # ty:ignore[possibly-missing-attribute]
319+
default = docstring.parent.type_parameters[name].default # ty:ignore[unresolved-attribute]
320320
except (AttributeError, KeyError):
321321
default = None
322322

323323
if warn_unknown_params:
324324
with suppress(AttributeError): # for type parameters sections in objects without type parameters
325-
type_params = docstring.parent.type_parameters # ty:ignore[possibly-missing-attribute]
325+
type_params = docstring.parent.type_parameters # ty:ignore[unresolved-attribute]
326326
if name not in type_params:
327-
message = f"Type parameter '{name}' does not appear in the {docstring.parent.kind.value} signature" # ty:ignore[possibly-missing-attribute]
327+
message = f"Type parameter '{name}' does not appear in the {docstring.parent.kind.value} signature" # ty:ignore[unresolved-attribute]
328328
for starred_name in (f"*{name}", f"**{name}"):
329329
if starred_name in type_params:
330330
message += f". Did you mean '{starred_name}'?"

packages/griffelib/src/griffe/_internal/docstrings/numpy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,23 +367,23 @@ def _read_type_parameters_section(
367367
# try to use the bound from the signature
368368
for name in names:
369369
with suppress(AttributeError, KeyError):
370-
bound = docstring.parent.type_parameters[name].annotation # ty:ignore[possibly-missing-attribute]
370+
bound = docstring.parent.type_parameters[name].annotation # ty:ignore[unresolved-attribute]
371371
break
372372
else:
373373
bound = parse_docstring_annotation(bound, docstring, log_level=LogLevel.debug)
374374

375375
if default is None:
376376
for name in names:
377377
with suppress(AttributeError, KeyError):
378-
default = docstring.parent.type_parameters[name].default # ty:ignore[possibly-missing-attribute]
378+
default = docstring.parent.type_parameters[name].default # ty:ignore[unresolved-attribute]
379379
break
380380

381381
if warn_unknown_params:
382382
with suppress(AttributeError): # for parameters sections in objects without parameters
383-
type_params = docstring.parent.type_parameters # ty:ignore[possibly-missing-attribute]
383+
type_params = docstring.parent.type_parameters # ty:ignore[unresolved-attribute]
384384
for name in names:
385385
if name not in type_params:
386-
message = f"Type parameter '{name}' does not appear in the {docstring.parent.kind} signature" # ty:ignore[possibly-missing-attribute]
386+
message = f"Type parameter '{name}' does not appear in the {docstring.parent.kind} signature" # ty:ignore[unresolved-attribute]
387387
for starred_name in (f"*{name}", f"**{name}"):
388388
if starred_name in type_params:
389389
message += f". Did you mean '{starred_name}'?"
@@ -458,9 +458,9 @@ def _read_returns_section(
458458
if annotation is None:
459459
# try to retrieve the annotation from the docstring parent
460460
with suppress(AttributeError, KeyError, ValueError):
461-
if docstring.parent.is_function: # ty:ignore[possibly-missing-attribute]
461+
if docstring.parent.is_function: # ty:ignore[unresolved-attribute]
462462
annotation = docstring.parent.returns # ty:ignore[unresolved-attribute]
463-
elif docstring.parent.is_attribute: # ty:ignore[possibly-missing-attribute]
463+
elif docstring.parent.is_attribute: # ty:ignore[unresolved-attribute]
464464
annotation = docstring.parent.annotation # ty:ignore[unresolved-attribute]
465465
else:
466466
raise ValueError

packages/griffelib/src/griffe/_internal/docstrings/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ def docstring_warning(
3737

3838
def warn(docstring: Docstring, offset: int, message: str, log_level: LogLevel = LogLevel.warning) -> None:
3939
try:
40-
prefix = docstring.parent.relative_filepath # ty:ignore[possibly-missing-attribute]
40+
prefix = docstring.parent.relative_filepath # ty:ignore[unresolved-attribute]
4141
except (AttributeError, ValueError):
4242
prefix = "<module>"
4343
except BuiltinModuleError:
44-
prefix = f"<module: {docstring.parent.module.name}>" # ty:ignore[possibly-missing-attribute]
44+
prefix = f"<module: {docstring.parent.module.name}>" # ty:ignore[unresolved-attribute]
4545
log = getattr(logger, log_level.value)
4646
log(f"{prefix}:{(docstring.lineno or 0) + offset}: {message}")
4747

packages/griffelib/src/griffe/_internal/encoders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def _attach_parent_to_exprs(obj: Class | Function | Attribute | TypeAlias, paren
197197
def _load_module(obj_dict: dict[str, Any]) -> Module:
198198
filepath = obj_dict.get("filepath")
199199
if filepath is not None:
200-
filepath = [*map(Path, filepath)] if isinstance(filepath, list) else Path(filepath)
200+
filepath = [*map(Path, filepath)] if isinstance(filepath, list) else Path(filepath) # ty:ignore[invalid-argument-type]
201201
module = Module(
202202
name=obj_dict["name"],
203203
filepath=filepath,

0 commit comments

Comments
 (0)