Skip to content

Commit

Permalink
Ignore mypy error about missing generic arg for catch_warnings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nicoddemus committed Oct 7, 2022
1 parent 4ee6e90 commit 4da0689
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
default_language_version:
python: "3.10"
repos:
- repo: https://github.com/psf/black
rev: 22.8.0
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/recwarn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit 4da0689

Please sign in to comment.