Merge pull request #9428 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
This commit is contained in:
commit
d39780f30b
|
@ -48,7 +48,7 @@ repos:
|
||||||
hooks:
|
hooks:
|
||||||
- id: python-use-type-annotations
|
- id: python-use-type-annotations
|
||||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
rev: v0.910-1
|
rev: v0.920
|
||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
files: ^(src/|testing/)
|
files: ^(src/|testing/)
|
||||||
|
|
|
@ -112,7 +112,7 @@ def _py36_windowsconsoleio_workaround(stream: TextIO) -> None:
|
||||||
buffering = -1
|
buffering = -1
|
||||||
|
|
||||||
return io.TextIOWrapper(
|
return io.TextIOWrapper(
|
||||||
open(os.dup(f.fileno()), mode, buffering), # type: ignore[arg-type]
|
open(os.dup(f.fileno()), mode, buffering),
|
||||||
f.encoding,
|
f.encoding,
|
||||||
f.errors,
|
f.errors,
|
||||||
f.newlines,
|
f.newlines,
|
||||||
|
|
|
@ -92,7 +92,7 @@ class _NodeReporter:
|
||||||
self.xml = xml
|
self.xml = xml
|
||||||
self.add_stats = self.xml.add_stats
|
self.add_stats = self.xml.add_stats
|
||||||
self.family = self.xml.family
|
self.family = self.xml.family
|
||||||
self.duration = 0
|
self.duration = 0.0
|
||||||
self.properties: List[Tuple[str, str]] = []
|
self.properties: List[Tuple[str, str]] = []
|
||||||
self.nodes: List[ET.Element] = []
|
self.nodes: List[ET.Element] = []
|
||||||
self.attrs: Dict[str, str] = {}
|
self.attrs: Dict[str, str] = {}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""Access and control log capturing."""
|
"""Access and control log capturing."""
|
||||||
|
import io
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -13,6 +14,7 @@ from typing import List
|
||||||
from typing import Mapping
|
from typing import Mapping
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
|
@ -34,6 +36,11 @@ from _pytest.main import Session
|
||||||
from _pytest.stash import StashKey
|
from _pytest.stash import StashKey
|
||||||
from _pytest.terminal import TerminalReporter
|
from _pytest.terminal import TerminalReporter
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
logging_StreamHandler = logging.StreamHandler[StringIO]
|
||||||
|
else:
|
||||||
|
logging_StreamHandler = logging.StreamHandler
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_LOG_FORMAT = "%(levelname)-8s %(name)s:%(filename)s:%(lineno)d %(message)s"
|
DEFAULT_LOG_FORMAT = "%(levelname)-8s %(name)s:%(filename)s:%(lineno)d %(message)s"
|
||||||
DEFAULT_LOG_DATE_FORMAT = "%H:%M:%S"
|
DEFAULT_LOG_DATE_FORMAT = "%H:%M:%S"
|
||||||
|
@ -322,11 +329,9 @@ class catching_logs:
|
||||||
root_logger.removeHandler(self.handler)
|
root_logger.removeHandler(self.handler)
|
||||||
|
|
||||||
|
|
||||||
class LogCaptureHandler(logging.StreamHandler):
|
class LogCaptureHandler(logging_StreamHandler):
|
||||||
"""A logging handler that stores log records and the log text."""
|
"""A logging handler that stores log records and the log text."""
|
||||||
|
|
||||||
stream: StringIO
|
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""Create a new log handler."""
|
"""Create a new log handler."""
|
||||||
super().__init__(StringIO())
|
super().__init__(StringIO())
|
||||||
|
@ -621,7 +626,8 @@ class LoggingPlugin:
|
||||||
if not fpath.parent.exists():
|
if not fpath.parent.exists():
|
||||||
fpath.parent.mkdir(exist_ok=True, parents=True)
|
fpath.parent.mkdir(exist_ok=True, parents=True)
|
||||||
|
|
||||||
stream = fpath.open(mode="w", encoding="UTF-8")
|
# https://github.com/python/mypy/issues/11193
|
||||||
|
stream: io.TextIOWrapper = fpath.open(mode="w", encoding="UTF-8") # type: ignore[assignment]
|
||||||
if sys.version_info >= (3, 7):
|
if sys.version_info >= (3, 7):
|
||||||
old_stream = self.log_file_handler.setStream(stream)
|
old_stream = self.log_file_handler.setStream(stream)
|
||||||
else:
|
else:
|
||||||
|
@ -633,8 +639,7 @@ class LoggingPlugin:
|
||||||
finally:
|
finally:
|
||||||
self.log_file_handler.release()
|
self.log_file_handler.release()
|
||||||
if old_stream:
|
if old_stream:
|
||||||
# https://github.com/python/typeshed/pull/5663
|
old_stream.close()
|
||||||
old_stream.close() # type:ignore[attr-defined]
|
|
||||||
|
|
||||||
def _log_cli_enabled(self):
|
def _log_cli_enabled(self):
|
||||||
"""Return whether live logging is enabled."""
|
"""Return whether live logging is enabled."""
|
||||||
|
@ -758,7 +763,7 @@ class _FileHandler(logging.FileHandler):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class _LiveLoggingStreamHandler(logging.StreamHandler):
|
class _LiveLoggingStreamHandler(logging_StreamHandler):
|
||||||
"""A logging StreamHandler used by the live logging feature: it will
|
"""A logging StreamHandler used by the live logging feature: it will
|
||||||
write a newline before the first log message in each test.
|
write a newline before the first log message in each test.
|
||||||
|
|
||||||
|
|
|
@ -332,8 +332,7 @@ def test_findsource(monkeypatch) -> None:
|
||||||
lines = ["if 1:\n", " def x():\n", " pass\n"]
|
lines = ["if 1:\n", " def x():\n", " pass\n"]
|
||||||
co = compile("".join(lines), filename, "exec")
|
co = compile("".join(lines), filename, "exec")
|
||||||
|
|
||||||
# Type ignored because linecache.cache is private.
|
monkeypatch.setitem(linecache.cache, filename, (1, None, lines, filename))
|
||||||
monkeypatch.setitem(linecache.cache, filename, (1, None, lines, filename)) # type: ignore[attr-defined]
|
|
||||||
|
|
||||||
src, lineno = findsource(co)
|
src, lineno = findsource(co)
|
||||||
assert src is not None
|
assert src is not None
|
||||||
|
|
|
@ -1057,7 +1057,7 @@ class TestAssertionRewriteHookDetails:
|
||||||
e = OSError()
|
e = OSError()
|
||||||
e.errno = 10
|
e.errno = 10
|
||||||
raise e
|
raise e
|
||||||
yield # type:ignore[unreachable]
|
yield
|
||||||
|
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
_pytest.assertion.rewrite, "atomic_write", atomic_write_failed
|
_pytest.assertion.rewrite, "atomic_write", atomic_write_failed
|
||||||
|
|
|
@ -14,7 +14,7 @@ def test_item_fspath(pytester: pytest.Pytester) -> None:
|
||||||
items2, hookrec = pytester.inline_genitems(item.nodeid)
|
items2, hookrec = pytester.inline_genitems(item.nodeid)
|
||||||
(item2,) = items2
|
(item2,) = items2
|
||||||
assert item2.name == item.name
|
assert item2.name == item.name
|
||||||
assert item2.fspath == item.fspath # type: ignore[attr-defined]
|
assert item2.fspath == item.fspath
|
||||||
assert item2.path == item.path
|
assert item2.path == item.path
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import email.message
|
||||||
import io
|
import io
|
||||||
from typing import List
|
from typing import List
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
@ -98,7 +99,9 @@ class TestPaste:
|
||||||
|
|
||||||
def mocked(url, data):
|
def mocked(url, data):
|
||||||
calls.append((url, data))
|
calls.append((url, data))
|
||||||
raise urllib.error.HTTPError(url, 400, "Bad request", {}, io.BytesIO())
|
raise urllib.error.HTTPError(
|
||||||
|
url, 400, "Bad request", email.message.Message(), io.BytesIO()
|
||||||
|
)
|
||||||
|
|
||||||
monkeypatch.setattr(urllib.request, "urlopen", mocked)
|
monkeypatch.setattr(urllib.request, "urlopen", mocked)
|
||||||
return calls
|
return calls
|
||||||
|
|
|
@ -114,13 +114,13 @@ class TestDeprecatedCall:
|
||||||
# Type ignored because `onceregistry` and `filters` are not
|
# Type ignored because `onceregistry` and `filters` are not
|
||||||
# documented API.
|
# documented API.
|
||||||
onceregistry = warnings.onceregistry.copy() # type: ignore
|
onceregistry = warnings.onceregistry.copy() # type: ignore
|
||||||
filters = warnings.filters[:] # type: ignore
|
filters = warnings.filters[:]
|
||||||
warn = warnings.warn
|
warn = warnings.warn
|
||||||
warn_explicit = warnings.warn_explicit
|
warn_explicit = warnings.warn_explicit
|
||||||
self.test_deprecated_call_raises()
|
self.test_deprecated_call_raises()
|
||||||
self.test_deprecated_call()
|
self.test_deprecated_call()
|
||||||
assert onceregistry == warnings.onceregistry # type: ignore
|
assert onceregistry == warnings.onceregistry # type: ignore
|
||||||
assert filters == warnings.filters # type: ignore
|
assert filters == warnings.filters
|
||||||
assert warn is warnings.warn
|
assert warn is warnings.warn
|
||||||
assert warn_explicit is warnings.warn_explicit
|
assert warn_explicit is warnings.warn_explicit
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue