Skip to content

Commit

Permalink
Merge pull request #6455 from blueyed/mypy-master
Browse files Browse the repository at this point in the history
master: update mypy 0.740 -> 0.761
  • Loading branch information
blueyed authored Jan 14, 2020
2 parents 3adaa3d + 090e260 commit 8eec42f
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:
- id: pyupgrade
args: [--py3-plus]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.740
rev: v0.761
hooks:
- id: mypy
files: ^(src/|testing/)
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/_code/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def from_current(
assert tup[1] is not None, "no current exception"
assert tup[2] is not None, "no current exception"
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
def for_later(cls) -> "ExceptionInfo[_E]":
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/assertion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
This function will make sure that this module or all modules inside
Expand Down
5 changes: 2 additions & 3 deletions src/_pytest/assertion/rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,14 +1045,13 @@ def try_makedirs(cache_dir) -> bool:

def get_cache_dir(file_path: Path) -> 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: # type: ignore
if sys.version_info >= (3, 8) and sys.pycache_prefix:
# given:
# prefix = '/tmp/pycs'
# path = '/home/user/proj/test_app.py'
# we want:
# '/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:
# classic pycache directory
return file_path.parent / "__pycache__"
7 changes: 2 additions & 5 deletions src/_pytest/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@


if sys.version_info >= (3, 8):
# Type ignored until next mypy release.
from importlib import metadata as importlib_metadata # type: ignore
from importlib import metadata as importlib_metadata
else:
import importlib_metadata # noqa: F401

Expand Down Expand Up @@ -385,9 +384,7 @@ def overload(f): # noqa: F811


if sys.version_info >= (3, 8):
# TODO: Remove type ignore on next mypy update.
# https://github.com/python/typeshed/commit/add0b5e930a1db16560fde45a3b710eefc625709
from functools import cached_property # type: ignore
from functools import cached_property
else:

class cached_property(Generic[_S, _T]):
Expand Down
4 changes: 3 additions & 1 deletion src/_pytest/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,9 @@ def _find_lineno(self, obj, source_lines):
obj = getattr(obj, "fget", obj)
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):
return
with _patch_unwrap_mock_aware():
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ def inline_genitems(self, *args):
items = [x.item for x in rec.getcalls("pytest_itemcollected")]
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.
Runs the :py:func:`pytest.main` function to run all of pytest inside
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def __repr__(self):
)

@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.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def pytest_runtest_makereport(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")
longrepr = None
if not call.excinfo:
Expand Down
8 changes: 2 additions & 6 deletions testing/code/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +318,12 @@ def test_compile_and_getsource(self) -> None:

@pytest.mark.parametrize("name", ["", None, "my"])
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)
if not name:
expected = "codegen %s:%d>" % (mypath, mylineno + 2 + 2) # type: ignore
else:
expected = "codegen %r %s:%d>" % (
name,
mypath, # type: ignore
mylineno + 2 + 2, # type: ignore
) # type: ignore
expected = "codegen %r %s:%d>" % (name, mypath, mylineno + 2 + 2) # type: ignore
fn = co.co_filename
assert fn.endswith(expected)

Expand Down

0 comments on commit 8eec42f

Please sign in to comment.