From 16ff9f591e38d1f2a79441f177130b1d89098c6e Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Mon, 2 Dec 2019 18:01:08 +0200 Subject: [PATCH] Update mypy 0.740 -> 0.750 Release notes: https://mypy-lang.blogspot.com/2019/11/mypy-0.html --- .pre-commit-config.yaml | 2 +- src/_pytest/_code/code.py | 2 +- src/_pytest/_code/source.py | 4 +++- src/_pytest/assertion/rewrite.py | 5 ++--- src/_pytest/compat.py | 7 ++----- src/_pytest/recwarn.py | 4 +++- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d4196152f..9548cd079 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,7 @@ repos: - id: pyupgrade args: [--py3-plus] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.740 + rev: v0.750 hooks: - id: mypy files: ^(src/|testing/) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index a8f117366..d1a8ec2f1 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -479,7 +479,7 @@ class ExceptionInfo(Generic[_E]): 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]": diff --git a/src/_pytest/_code/source.py b/src/_pytest/_code/source.py index d7cef683d..ac3ee231e 100644 --- a/src/_pytest/_code/source.py +++ b/src/_pytest/_code/source.py @@ -339,7 +339,9 @@ def getstatementrange_ast( block_finder.started = source.lines[start][0].isspace() it = ((x + "\n") for x in source.lines[start:end]) try: - for tok in tokenize.generate_tokens(lambda: next(it)): + # Type ignored until next mypy release. + # https://github.com/python/typeshed/commit/c0d46a20353b733befb85d8b9cc24e5b0bcd8f9a + for tok in tokenize.generate_tokens(lambda: next(it)): # type: ignore block_finder.tokeneater(*tok) except (inspect.EndOfBlock, IndentationError): end = block_finder.last + start diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index 51ea1801b..6bfb876e4 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -1074,14 +1074,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__" diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index fc810b3e5..8dd74b577 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -43,8 +43,7 @@ MODULE_NOT_FOUND_ERROR = ( 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 @@ -385,9 +384,7 @@ else: 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]): diff --git a/src/_pytest/recwarn.py b/src/_pytest/recwarn.py index 5cf32c894..e3d7b72ec 100644 --- a/src/_pytest/recwarn.py +++ b/src/_pytest/recwarn.py @@ -129,7 +129,9 @@ def warns( # noqa: F811 return func(*args[1:], **kwargs) -class WarningsRecorder(warnings.catch_warnings): +# Type ignored until next mypy release. Regression fixed by: +# https://github.com/python/typeshed/commit/41bf6a19822d6694973449d795f8bfe1d50d5a03 +class WarningsRecorder(warnings.catch_warnings): # type: ignore """A context manager to record raised warnings. Adapted from `warnings.catch_warnings`.