Skip to content

Commit 93c8822

Browse files
committed
Fix check_untyped_defs errors in warnings
1 parent 583c2a2 commit 93c8822

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/_pytest/warnings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def catch_warnings_for_item(config, ihook, when, item):
6666
cmdline_filters = config.getoption("pythonwarnings") or []
6767
inifilters = config.getini("filterwarnings")
6868
with warnings.catch_warnings(record=True) as log:
69+
# mypy can't infer that record=True means log is not None; help it.
70+
assert log is not None
6971

7072
if not sys.warnoptions:
7173
# if user is not explicitly configuring warning filters, show deprecation warnings by default (#2908)
@@ -145,6 +147,8 @@ def _issue_warning_captured(warning, hook, stacklevel):
145147
with warnings.catch_warnings(record=True) as records:
146148
warnings.simplefilter("always", type(warning))
147149
warnings.warn(warning, stacklevel=stacklevel)
150+
# Mypy can't infer that record=True means records is not None; help it.
151+
assert records is not None
148152
hook.pytest_warning_captured.call_historic(
149153
kwargs=dict(warning_message=records[0], when="config", item=None)
150154
)

0 commit comments

Comments
 (0)