master: update mypy 0.740 -> 0.761
(cherry picked from commit16ff9f591e
) (cherry picked from commit4848bbdf9a
)
This commit is contained in:
parent
90740007a8
commit
090e260517
|
@ -37,7 +37,7 @@ repos:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args: [--py3-plus]
|
args: [--py3-plus]
|
||||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
rev: v0.740
|
rev: v0.761
|
||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
files: ^(src/|testing/)
|
files: ^(src/|testing/)
|
||||||
|
|
|
@ -479,7 +479,7 @@ class ExceptionInfo(Generic[_E]):
|
||||||
assert tup[1] is not None, "no current exception"
|
assert tup[1] is not None, "no current exception"
|
||||||
assert tup[2] is not None, "no current exception"
|
assert tup[2] is not None, "no current exception"
|
||||||
exc_info = (tup[0], tup[1], tup[2])
|
exc_info = (tup[0], tup[1], tup[2])
|
||||||
return cls.from_exc_info(exc_info, exprinfo)
|
return ExceptionInfo.from_exc_info(exc_info, exprinfo)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def for_later(cls) -> "ExceptionInfo[_E]":
|
def for_later(cls) -> "ExceptionInfo[_E]":
|
||||||
|
|
|
@ -33,7 +33,7 @@ def pytest_addoption(parser):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def register_assert_rewrite(*names):
|
def register_assert_rewrite(*names) -> None:
|
||||||
"""Register one or more module names to be rewritten on import.
|
"""Register one or more module names to be rewritten on import.
|
||||||
|
|
||||||
This function will make sure that this module or all modules inside
|
This function will make sure that this module or all modules inside
|
||||||
|
|
|
@ -1045,14 +1045,13 @@ def try_makedirs(cache_dir) -> bool:
|
||||||
|
|
||||||
def get_cache_dir(file_path: Path) -> Path:
|
def get_cache_dir(file_path: Path) -> Path:
|
||||||
"""Returns the cache directory to write .pyc files for the given .py file path"""
|
"""Returns the cache directory to write .pyc files for the given .py file path"""
|
||||||
# Type ignored until added in next mypy release.
|
if sys.version_info >= (3, 8) and sys.pycache_prefix:
|
||||||
if sys.version_info >= (3, 8) and sys.pycache_prefix: # type: ignore
|
|
||||||
# given:
|
# given:
|
||||||
# prefix = '/tmp/pycs'
|
# prefix = '/tmp/pycs'
|
||||||
# path = '/home/user/proj/test_app.py'
|
# path = '/home/user/proj/test_app.py'
|
||||||
# we want:
|
# we want:
|
||||||
# '/tmp/pycs/home/user/proj'
|
# '/tmp/pycs/home/user/proj'
|
||||||
return Path(sys.pycache_prefix) / Path(*file_path.parts[1:-1]) # type: ignore
|
return Path(sys.pycache_prefix) / Path(*file_path.parts[1:-1])
|
||||||
else:
|
else:
|
||||||
# classic pycache directory
|
# classic pycache directory
|
||||||
return file_path.parent / "__pycache__"
|
return file_path.parent / "__pycache__"
|
||||||
|
|
|
@ -43,8 +43,7 @@ MODULE_NOT_FOUND_ERROR = (
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info >= (3, 8):
|
if sys.version_info >= (3, 8):
|
||||||
# Type ignored until next mypy release.
|
from importlib import metadata as importlib_metadata
|
||||||
from importlib import metadata as importlib_metadata # type: ignore
|
|
||||||
else:
|
else:
|
||||||
import importlib_metadata # noqa: F401
|
import importlib_metadata # noqa: F401
|
||||||
|
|
||||||
|
@ -385,9 +384,7 @@ else:
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info >= (3, 8):
|
if sys.version_info >= (3, 8):
|
||||||
# TODO: Remove type ignore on next mypy update.
|
from functools import cached_property
|
||||||
# https://github.com/python/typeshed/commit/add0b5e930a1db16560fde45a3b710eefc625709
|
|
||||||
from functools import cached_property # type: ignore
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
class cached_property(Generic[_S, _T]):
|
class cached_property(Generic[_S, _T]):
|
||||||
|
|
|
@ -445,7 +445,9 @@ class DoctestModule(pytest.Module):
|
||||||
obj = getattr(obj, "fget", obj)
|
obj = getattr(obj, "fget", obj)
|
||||||
return doctest.DocTestFinder._find_lineno(self, obj, source_lines)
|
return doctest.DocTestFinder._find_lineno(self, obj, source_lines)
|
||||||
|
|
||||||
def _find(self, tests, obj, name, module, source_lines, globs, seen):
|
def _find(
|
||||||
|
self, tests, obj, name, module, source_lines, globs, seen
|
||||||
|
) -> None:
|
||||||
if _is_mocked(obj):
|
if _is_mocked(obj):
|
||||||
return
|
return
|
||||||
with _patch_unwrap_mock_aware():
|
with _patch_unwrap_mock_aware():
|
||||||
|
|
|
@ -832,7 +832,7 @@ class Testdir:
|
||||||
items = [x.item for x in rec.getcalls("pytest_itemcollected")]
|
items = [x.item for x in rec.getcalls("pytest_itemcollected")]
|
||||||
return items, rec
|
return items, rec
|
||||||
|
|
||||||
def inline_run(self, *args, plugins=(), no_reraise_ctrlc=False):
|
def inline_run(self, *args, plugins=(), no_reraise_ctrlc: bool = False):
|
||||||
"""Run ``pytest.main()`` in-process, returning a HookRecorder.
|
"""Run ``pytest.main()`` in-process, returning a HookRecorder.
|
||||||
|
|
||||||
Runs the :py:func:`pytest.main` function to run all of pytest inside
|
Runs the :py:func:`pytest.main` function to run all of pytest inside
|
||||||
|
|
|
@ -259,7 +259,7 @@ class TestReport(BaseReport):
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_item_and_call(cls, item, call):
|
def from_item_and_call(cls, item, call) -> "TestReport":
|
||||||
"""
|
"""
|
||||||
Factory method to create and fill a TestReport with standard item and call info.
|
Factory method to create and fill a TestReport with standard item and call info.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -250,7 +250,7 @@ def pytest_runtest_makereport(item, call):
|
||||||
return TestReport.from_item_and_call(item, call)
|
return TestReport.from_item_and_call(item, call)
|
||||||
|
|
||||||
|
|
||||||
def pytest_make_collect_report(collector):
|
def pytest_make_collect_report(collector) -> CollectReport:
|
||||||
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
|
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
|
||||||
longrepr = None
|
longrepr = None
|
||||||
if not call.excinfo:
|
if not call.excinfo:
|
||||||
|
|
|
@ -318,16 +318,12 @@ class TestSourceParsingAndCompiling:
|
||||||
|
|
||||||
@pytest.mark.parametrize("name", ["", None, "my"])
|
@pytest.mark.parametrize("name", ["", None, "my"])
|
||||||
def test_compilefuncs_and_path_sanity(self, name: Optional[str]) -> None:
|
def test_compilefuncs_and_path_sanity(self, name: Optional[str]) -> None:
|
||||||
def check(comp, name):
|
def check(comp, name) -> None:
|
||||||
co = comp(self.source, name)
|
co = comp(self.source, name)
|
||||||
if not name:
|
if not name:
|
||||||
expected = "codegen %s:%d>" % (mypath, mylineno + 2 + 2) # type: ignore
|
expected = "codegen %s:%d>" % (mypath, mylineno + 2 + 2) # type: ignore
|
||||||
else:
|
else:
|
||||||
expected = "codegen %r %s:%d>" % (
|
expected = "codegen %r %s:%d>" % (name, mypath, mylineno + 2 + 2) # type: ignore
|
||||||
name,
|
|
||||||
mypath, # type: ignore
|
|
||||||
mylineno + 2 + 2, # type: ignore
|
|
||||||
) # type: ignore
|
|
||||||
fn = co.co_filename
|
fn = co.co_filename
|
||||||
assert fn.endswith(expected)
|
assert fn.endswith(expected)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue