From 605fe29d12d62362f9a523f8c46774f9c7b0add2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 14 Jun 2021 17:42:33 +0000 Subject: [PATCH 1/4] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 21.5b2 → 21.6b0](https://github.com/psf/black/compare/21.5b2...21.6b0) - [github.com/asottile/pyupgrade: v2.19.1 → v2.19.4](https://github.com/asottile/pyupgrade/compare/v2.19.1...v2.19.4) - [github.com/pre-commit/pygrep-hooks: v1.8.0 → v1.9.0](https://github.com/pre-commit/pygrep-hooks/compare/v1.8.0...v1.9.0) - [github.com/pre-commit/mirrors-mypy: v0.812 → v0.902](https://github.com/pre-commit/mirrors-mypy/compare/v0.812...v0.902) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e641dd87c..b01d9c5d6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/psf/black - rev: 21.5b2 + rev: 21.6b0 hooks: - id: black args: [--safe, --quiet] @@ -34,7 +34,7 @@ repos: - id: reorder-python-imports args: ['--application-directories=.:src', --py36-plus] - repo: https://github.com/asottile/pyupgrade - rev: v2.19.1 + rev: v2.19.4 hooks: - id: pyupgrade args: [--py36-plus] @@ -44,11 +44,11 @@ repos: - id: setup-cfg-fmt args: [--max-py-version=3.10] - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.8.0 + rev: v1.9.0 hooks: - id: python-use-type-annotations - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.812 + rev: v0.902 hooks: - id: mypy files: ^(src/|testing/) From c4da6fff427191989d0199dc9039cbad1e822fa8 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 19 Jun 2021 21:31:17 -0700 Subject: [PATCH 2/4] Add missing types-* stub packages --- .pre-commit-config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b01d9c5d6..0490ae968 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -58,6 +58,8 @@ repos: - py>=1.8.2 - attrs>=19.2.0 - packaging + - types-toml + - types-pkg_resources - repo: local hooks: - id: rst From a1967e95940f04808b704cf3d678349f6278be6e Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 19 Jun 2021 21:41:00 -0700 Subject: [PATCH 3/4] fix overload of __getitem__ for Traceback --- src/_pytest/_code/code.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 2fdd8a086..bd2132a9a 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -48,6 +48,7 @@ from _pytest.pathlib import bestrelpath if TYPE_CHECKING: from typing_extensions import Literal + from typing_extensions import SupportsIndex from weakref import ReferenceType _TracebackStyle = Literal["long", "short", "line", "no", "native", "value", "auto"] @@ -371,14 +372,16 @@ class Traceback(List[TracebackEntry]): return self @overload - def __getitem__(self, key: int) -> TracebackEntry: + def __getitem__(self, key: "SupportsIndex") -> TracebackEntry: ... @overload def __getitem__(self, key: slice) -> "Traceback": ... - def __getitem__(self, key: Union[int, slice]) -> Union[TracebackEntry, "Traceback"]: + def __getitem__( + self, key: Union["SupportsIndex", slice] + ) -> Union[TracebackEntry, "Traceback"]: if isinstance(key, slice): return self.__class__(super().__getitem__(key)) else: From ab3cd644dcd9404aef045110cbcca59ac1a0e928 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 20 Jun 2021 08:09:18 -0700 Subject: [PATCH 4/4] add temporary ignore for FileHandler stream close --- src/_pytest/logging.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 4ab7b5e97..8b4865b5d 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -626,7 +626,8 @@ class LoggingPlugin: finally: self.log_file_handler.release() if old_stream: - old_stream.close() + # https://github.com/python/typeshed/pull/5663 + old_stream.close() # type:ignore[attr-defined] def _log_cli_enabled(self): """Return whether live logging is enabled."""