Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fb1fdbf

Browse files
authored
more mypy checking (#14995)
2 parents dc978f1 + db0fde0 commit fb1fdbf

3 files changed

Lines changed: 22 additions & 22 deletions

File tree

IPython/core/ultratb.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,10 @@ def _format_exception_only(
336336
)
337337
)
338338
if textline == "":
339-
textline = py3compat.cast_unicode(value.text, "utf-8")
339+
# sep 2025:
340+
# textline = py3compat.cast_unicode(value.text, "utf-8")
341+
assert isinstance(value.text, str)
342+
textline = value.text
340343

341344
if textline is not None:
342345
i = 0
@@ -425,7 +428,7 @@ def show_exception_only(
425428
def _some_str(self, value: Any) -> str:
426429
# Lifted from traceback.py
427430
try:
428-
return py3compat.cast_unicode(str(value))
431+
return str(value)
429432
except:
430433
return "<unprintable %s object>" % type(value).__name__
431434

@@ -704,16 +707,19 @@ def format_exception(self, etype, evalue):
704707
if not isinstance(notes, Sequence) or isinstance(notes, (str, bytes)):
705708
notes = [_safe_string(notes, "__notes__", func=repr)]
706709

710+
for note in notes:
711+
assert isinstance(note, str)
712+
713+
str_notes: Sequence[str] = notes
714+
707715
# ... and format it
708716
return [
709717
theme_table[self._theme_name].format(
710718
[(Token.ExcName, etype_str), (Token, ": "), (Token, evalue_str)]
711719
),
712720
*(
713-
theme_table[self._theme_name].format(
714-
[(Token, _safe_string(py3compat.cast_unicode(n), "note"))]
715-
)
716-
for n in notes
721+
theme_table[self._theme_name].format([(Token, note)])
722+
for note in str_notes
717723
),
718724
]
719725

IPython/utils/text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ def match_target(s: str) -> str:
187187
else:
188188
pred = pattern
189189
if not prune:
190-
return type(self)([el for el in self if pred(match_target(el))])
190+
return type(self)([el for el in self if pred(match_target(el))]) # type: ignore [no-untyped-call]
191191
else:
192-
return type(self)([el for el in self if not pred(match_target(el))])
192+
return type(self)([el for el in self if not pred(match_target(el))]) # type: ignore [no-untyped-call]
193193

194194
def fields(self, *fields: List[str]) -> List[List[str]]:
195195
"""Collect whitespace-separated fields from string list

pyproject.toml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ exclude = [
110110
'IPython/sphinxext/ipython_directive.py',
111111
'IPython/terminal/ipapp.py',
112112
'IPython/utils/path.py',
113+
'IPython/core/debugger_backport.py',
113114
]
114-
# check_untyped_defs = true
115+
check_untyped_defs = true
115116
# disallow_untyped_calls = true
116117
# disallow_untyped_decorators = true
117118
# ignore_errors = false
@@ -126,6 +127,7 @@ enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
126127
[[tool.mypy.overrides]]
127128
module = [
128129
"IPython.core.crashhandler",
130+
"IPython.utils.text",
129131
]
130132
check_untyped_defs = true
131133
disallow_incomplete_defs = true
@@ -135,25 +137,17 @@ disallow_untyped_defs = true
135137
ignore_errors = false
136138
ignore_missing_imports = false
137139

138-
[[tool.mypy.overrides]]
139-
module = [
140-
"IPython.utils.text",
141-
]
142-
disallow_untyped_defs = true
143-
check_untyped_defs = false
144-
disallow_untyped_decorators = true
145-
146140
[[tool.mypy.overrides]]
147141
module = [
148142
"IPython.core.ultratb",
149143
]
144+
check_untyped_defs = true
145+
disallow_incomplete_defs = true
146+
disallow_untyped_calls = false
147+
disallow_untyped_decorators = true
150148
disallow_untyped_defs = false
151149
ignore_errors = false
152150
ignore_missing_imports = false
153-
disallow_untyped_calls = false
154-
disallow_incomplete_defs = true
155-
check_untyped_defs = true
156-
disallow_untyped_decorators = true
157151

158152
[[tool.mypy.overrides]]
159153
module = [
@@ -315,7 +309,7 @@ ignore_errors = true
315309
ignore_missing_imports = true
316310
disallow_untyped_calls = false
317311
disallow_incomplete_defs = false
318-
check_untyped_defs = false
312+
check_untyped_defs = true
319313
disallow_untyped_decorators = false
320314

321315
[tool.pytest.ini_options]

0 commit comments

Comments
 (0)