Skip to content

Commit de94eef

Browse files
committed
ci: Remove unused type ignore comments
1 parent e1a4eba commit de94eef

8 files changed

Lines changed: 23 additions & 24 deletions

File tree

config/mypy.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
[mypy]
22
ignore_missing_imports = true
33
exclude = tests/fixtures/
4-
warn_unused_ignores = true

src/pytkdocs/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def main(args: Optional[List[str]] = None) -> int:
196196
An exit code.
197197
"""
198198
parser = get_parser()
199-
parsed_args: argparse.Namespace = parser.parse_args(args) # type: ignore
199+
parsed_args: argparse.Namespace = parser.parse_args(args)
200200

201201
if parsed_args.line_by_line:
202202
for line in sys.stdin:

src/pytkdocs/loader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def get_module_documentation(self, node: ObjectNode, select_members=None) -> Mod
420420
root_object.parse_docstring(self.docstring_parser, attributes=attributes_data)
421421

422422
for member_name, member in inspect.getmembers(module):
423-
if self.select(member_name, select_members): # type: ignore
423+
if self.select(member_name, select_members):
424424
child_node = ObjectNode(member, member_name, parent=node)
425425
if child_node.is_class() and node.root.obj is inspect.getmodule(child_node.obj):
426426
root_object.add_child(self.get_class_documentation(child_node))
@@ -604,7 +604,7 @@ def add_fields(
604604
fields = get_fields(attr_name, members=members)
605605

606606
for field_name, field in fields.items():
607-
select_field = self.select(field_name, select_members) # type: ignore
607+
select_field = self.select(field_name, select_members)
608608
is_inherited = field_is_inherited(field_name, attr_name, base_class)
609609

610610
if select_field and (self.select_inherited_members or not is_inherited):

src/pytkdocs/objects.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def root(self) -> "Object":
145145
obj = self
146146
while obj.parent:
147147
obj = obj.parent
148-
return obj # type: ignore
148+
return obj
149149

150150
@property
151151
def relative_file_path(self) -> str:
@@ -247,13 +247,13 @@ def add_child(self, obj: "Object") -> None: # noqa: WPS231 (not complex)
247247

248248
self.children.append(obj)
249249
if isinstance(obj, Module):
250-
self.modules.append(obj) # type: ignore
250+
self.modules.append(obj)
251251
elif isinstance(obj, Class):
252-
self.classes.append(obj) # type: ignore
252+
self.classes.append(obj)
253253
elif isinstance(obj, Function):
254-
self.functions.append(obj) # type: ignore
254+
self.functions.append(obj)
255255
elif isinstance(obj, Method):
256-
self.methods.append(obj) # type: ignore
256+
self.methods.append(obj)
257257
elif isinstance(obj, Attribute):
258258
# Dataclass attributes with default values will already be present in `self.attributes` as they are
259259
# resolved differently by the python interpreter. As they have a concrete value, they are already present
@@ -263,7 +263,7 @@ def add_child(self, obj: "Object") -> None: # noqa: WPS231 (not complex)
263263
for attribute in self.attributes:
264264
if attribute.name == new_attribute_name:
265265
self.attributes.remove(attribute)
266-
self.attributes.append(obj) # type: ignore
266+
self.attributes.append(obj)
267267
obj.parent = self
268268

269269
self._path_map[obj.path] = obj

src/pytkdocs/parsers/docstrings/google.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def _parse_parameters_section(self, lines: List[str], start_index: int) -> Tuple
263263

264264
# Check in the signature to get extra details
265265
try:
266-
signature_param = self.context["signature"].parameters[name.lstrip("*")] # type: ignore
266+
signature_param = self.context["signature"].parameters[name.lstrip("*")]
267267
except (AttributeError, KeyError):
268268
if annotation is empty:
269269
self.error(f"No type annotation for parameter '{name}'")

src/pytkdocs/parsers/docstrings/numpy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def read_parameters_section(
7171
type_name = param.type_name
7272
default = param.default or empty
7373
try:
74-
signature_param = self.context["signature"].parameters[name.lstrip("*")] # type: ignore
74+
signature_param = self.context["signature"].parameters[name.lstrip("*")]
7575
except (AttributeError, KeyError):
7676
self.error(f"No type annotation for parameter '{name}'")
7777
else:

src/pytkdocs/parsers/docstrings/restructured_text.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from typing import Literal # type: ignore
1515
except ImportError:
1616
# https://github.com/python/mypy/issues/8520
17-
from typing_extensions import Literal # type: ignore # noqa: WPS440
17+
from typing_extensions import Literal # type: ignore # noqa: WPS440
1818

1919

2020
# TODO: Examples: from the documentation, I'm not sure there is a standard format for examples
@@ -116,13 +116,13 @@ def __init__(self) -> None:
116116
self._parsed_values: ParsedValues = ParsedValues()
117117
# Ordering is significant so that directives like ":vartype" are checked before ":var"
118118
self.field_types = [
119-
FieldType(PARAM_TYPE_NAMES, self._read_parameter_type), # type: ignore
120-
FieldType(PARAM_NAMES, self._read_parameter), # type: ignore
121-
FieldType(ATTRIBUTE_TYPE_NAMES, self._read_attribute_type), # type: ignore
122-
FieldType(ATTRIBUTE_NAMES, self._read_attribute), # type: ignore
123-
FieldType(EXCEPTION_NAMES, self._read_exception), # type: ignore
124-
FieldType(RETURN_NAMES, self._read_return), # type: ignore
125-
FieldType(RETURN_TYPE_NAMES, self._read_return_type), # type: ignore
119+
FieldType(PARAM_TYPE_NAMES, self._read_parameter_type),
120+
FieldType(PARAM_NAMES, self._read_parameter),
121+
FieldType(ATTRIBUTE_TYPE_NAMES, self._read_attribute_type),
122+
FieldType(ATTRIBUTE_NAMES, self._read_attribute),
123+
FieldType(EXCEPTION_NAMES, self._read_exception),
124+
FieldType(RETURN_NAMES, self._read_return),
125+
FieldType(RETURN_TYPE_NAMES, self._read_return_type),
126126
]
127127

128128
def parse_sections(self, docstring: str) -> List[Section]: # noqa: D102
@@ -443,10 +443,10 @@ def _parse_directive(self, lines: List[str], start_index: int) -> ParsedDirectiv
443443
_, directive, value = line.split(":", 2)
444444
except ValueError:
445445
self.error(f"Failed to get ':directive: value' pair from '{line}'")
446-
return ParsedDirective(line, next_index, [], "", invalid=True) # type: ignore
446+
return ParsedDirective(line, next_index, [], "", invalid=True)
447447

448448
value = value.strip()
449-
return ParsedDirective(line, next_index, directive.split(" "), value) # type: ignore
449+
return ParsedDirective(line, next_index, directive.split(" "), value)
450450

451451

452452
def _consolidate_continuation_lines(lines: List[str], start_index: int) -> Tuple[str, int]:

src/pytkdocs/serializer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def serialize_docstring_section(section: Section) -> dict: # noqa: WPS231 (not
177177
"""
178178
serialized = {"type": section.type}
179179
if section.type == section.Type.MARKDOWN:
180-
serialized.update({"value": section.value}) # type: ignore
180+
serialized.update({"value": section.value})
181181
elif section.type == section.Type.RETURN:
182182
serialized.update({"value": serialize_annotated_object(section.value)}) # type: ignore
183183
elif section.type == section.Type.YIELD:
@@ -191,7 +191,7 @@ def serialize_docstring_section(section: Section) -> dict: # noqa: WPS231 (not
191191
elif section.type == section.Type.ATTRIBUTES:
192192
serialized.update({"value": [serialize_attribute(attr) for attr in section.value]}) # type: ignore
193193
elif section.type == section.Type.EXAMPLES:
194-
serialized.update({"value": section.value}) # type: ignore
194+
serialized.update({"value": section.value})
195195
return serialized
196196

197197

0 commit comments

Comments
 (0)