From 4da06896532809a216bfa7a53b0ff490c5193fe9 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 7 Oct 2022 11:30:24 -0300 Subject: [PATCH] Ignore mypy error about missing generic arg for catch_warnings mypy stubs recently changed warnings.catch_warnings to a Generic, in order to have proper overloads depending on the parameters passed to it, whihc triggers this mypy error now when we subclass it: src/_pytest/recwarn.py:170: error: Missing type parameters for generic type "catch_warnings" [type-arg] For our porpuses the parameter is not relevant (we always use record=True), so decided to just ignore the type error. --- .pre-commit-config.yaml | 2 ++ src/_pytest/recwarn.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 663bc64c2..19329cb21 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,5 @@ +default_language_version: + python: "3.10" repos: - repo: https://github.com/psf/black rev: 22.8.0 diff --git a/src/_pytest/recwarn.py b/src/_pytest/recwarn.py index 06eb82d71..0ab7ab2de 100644 --- a/src/_pytest/recwarn.py +++ b/src/_pytest/recwarn.py @@ -167,7 +167,7 @@ def warns( # noqa: F811 return func(*args[1:], **kwargs) -class WarningsRecorder(warnings.catch_warnings): +class WarningsRecorder(warnings.catch_warnings): # type:ignore[type-arg] """A context manager to record raised warnings. Each recorded warning is an instance of :class:`warnings.WarningMessage`.