Skip to content

Commit f1e992e

Browse files
committed
Remove unnecessary type: ignore comments
The rapid pace of changes in typing across our dependencies has slowed, so now is the time to enable the 'warn_unused_ignores' option. Doing so highlights a few now-unnecessary comments. Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent 3998279 commit f1e992e

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ python_version = "3.10"
6363
show_column_numbers = true
6464
show_error_context = true
6565
strict = true
66-
# this is here temporarily due to the rapid changes in typing across
67-
# dependencies
68-
warn_unused_ignores = false
66+
warn_unused_ignores = true
6967
# FIXME(stephenfin): We should remove this
7068
implicit_reexport = true
7169
exclude = 'doc'

testtools/compat.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,19 @@ def unicode_output_stream(stream: IO[str]) -> IO[str]:
139139
# already a TextIO [which in the io library has no encoding
140140
# attribute).
141141
return stream
142+
142143
try:
143144
writer = codecs.getwriter(stream.encoding or "") # type: ignore[attr-defined]
144145
except (AttributeError, LookupError):
145146
return codecs.getwriter("ascii")(stream, "replace") # type: ignore[arg-type, return-value]
147+
146148
if writer.__module__.rsplit(".", 1)[1].startswith("utf"):
147149
# The current stream has a unicode encoding so no error handler is needed
148150
return stream
151+
149152
# Python 3 doesn't seem to make this easy, handle a common case
150153
try:
151-
return stream.__class__( # type: ignore[call-arg, return-value]
154+
return stream.__class__( # type: ignore[call-arg]
152155
stream.buffer, # type: ignore[attr-defined]
153156
stream.encoding, # type: ignore[attr-defined]
154157
"replace",
@@ -157,4 +160,5 @@ def unicode_output_stream(stream: IO[str]) -> IO[str]:
157160
)
158161
except AttributeError:
159162
pass
163+
160164
return writer(stream, "replace") # type: ignore[arg-type, return-value]

testtools/matchers/_dict.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def _dict_to_mismatch(
7878
result_mismatch: "Callable[[dict[K, Mismatch]], Mismatch]" = DictMismatches,
7979
) -> Mismatch | None:
8080
if to_mismatch:
81-
data = map_values(to_mismatch, data) # type: ignore[arg-type,assignment]
82-
mismatches = filter_values(bool, data) # type: ignore[arg-type]
81+
data = map_values(to_mismatch, data) # type: ignore[arg-type]
82+
mismatches = filter_values(bool, data)
8383
if mismatches:
8484
return result_mismatch(mismatches) # type: ignore[arg-type]
8585
return None

testtools/matchers/_exception.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def match(self, matchee: "Callable[[], object]") -> Mismatch | None:
134134
# Handle staticmethod objects by extracting the underlying function
135135
actual_callable: Callable[[], object]
136136
if isinstance(matchee, staticmethod):
137-
actual_callable = matchee.__func__ # type: ignore[assignment]
137+
actual_callable = matchee.__func__
138138
else:
139139
actual_callable = matchee
140140
result = actual_callable()
@@ -146,7 +146,7 @@ def match(self, matchee: "Callable[[], object]") -> Mismatch | None:
146146
# Type narrow to actual ExcInfo
147147
assert exc_info[0] is not None
148148
assert exc_info[1] is not None
149-
typed_exc_info: ExcInfo = (exc_info[0], exc_info[1], exc_info[2]) # type: ignore[assignment]
149+
typed_exc_info: ExcInfo = (exc_info[0], exc_info[1], exc_info[2])
150150

151151
if self.exception_matcher:
152152
mismatch = self.exception_matcher.match(typed_exc_info)

testtools/testresult/real.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2186,7 +2186,7 @@ def stopTest(self, test: unittest.TestCase) -> None:
21862186
self._tags = self._tags.parent
21872187
self.decorated.stopTest(test)
21882188

2189-
def stopTestRun(self) -> object: # type: ignore[override]
2189+
def stopTestRun(self) -> object:
21902190
try:
21912191
return self.decorated.stopTestRun()
21922192
except AttributeError:

testtools/testsuite.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ def run(
126126
semaphore = threading.Semaphore(1)
127127
for i, test in enumerate(tests):
128128
process_result = self._wrap_result(
129-
testtools.ThreadsafeForwardingResult(result, semaphore),
130-
i, # type: ignore[no-untyped-call]
129+
testtools.ThreadsafeForwardingResult(result, semaphore), i
131130
)
132131
reader_thread = threading.Thread(
133132
target=self._run_test, args=(test, process_result, queue)

0 commit comments

Comments
 (0)