From e0edac8f12707f410904c5750d76ffe27955d4cb Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 24 Jul 2020 20:31:09 +0200 Subject: [PATCH 1/2] Enable aliases in pytest_mock and put on pytest exclude list --- tests/pytype_exclude_list.txt | 3 +++ third_party/3/pytest_mock/plugin.pyi | 21 ++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/pytype_exclude_list.txt b/tests/pytype_exclude_list.txt index 8641d4e6b466..6f49be66dfe1 100644 --- a/tests/pytype_exclude_list.txt +++ b/tests/pytype_exclude_list.txt @@ -15,3 +15,6 @@ third_party/2and3/attr/converters.pyi third_party/2and3/attr/filters.pyi third_party/2and3/attr/validators.pyi third_party/2and3/pynamodb/models.pyi + +# https://github.com/google/pytype/issues/612 +third_party/3/pytest_mock/plugin.pyi diff --git a/third_party/3/pytest_mock/plugin.pyi b/third_party/3/pytest_mock/plugin.pyi index 2ccfe6db6ffa..bf615dad471e 100644 --- a/third_party/3/pytest_mock/plugin.pyi +++ b/third_party/3/pytest_mock/plugin.pyi @@ -14,17 +14,16 @@ def _get_mock_module(config: _Config) -> _MockModule: ... class MockFixture: mock_module: _MockModule patch: MockFixture._Patcher # google/pytype#611 - # The following aliases don't work due to google/pytype#612 - Mock: Any # actually unittest.mock.Mock - MagicMock: Any # actually unittest.mock.MagicMock - NonCallableMock: Any # actually unittest.mock.NonCallableMock - PropertyMock: Any # actually unittest.mock.PropertyMock - call: Any # actually unittest.mock.call - ANY: Any # actually unittest.mock.ANY - DEFAULT: Any # actually unittest.mock.DEFAULT - create_autospec: Any # actually unittest.mock.create_autospec - sentinel: Any # actually unittest.mock.sentinel - mock_open: Any # actually unittest.mock.mock_open + Mock = unittest.mock.Mock + MagicMock = unittest.mock.MagicMock + NonCallableMock = unittest.mock.NonCallableMock + PropertyMock = unittest.mock.PropertyMock + call = unittest.mock.call + ANY = unittest.mock.ANY + DEFAULT = unittest.mock.DEFAULT + create_autospec = unittest.mock.create_autospec + sentinel = unittest.mock.sentinel + mock_open = unittest.mock.mock_open def __init__(self, config: _Config) -> None: ... def resetall(self) -> None: ... def stopall(self) -> None: ... From d5c562c08dc87162db25f5496eec7d455280bedb Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Sat, 25 Jul 2020 14:18:41 +0200 Subject: [PATCH 2/2] Require newer pytype Remove from pytype exclude list --- requirements-tests-py3.txt | 2 +- tests/pytype_exclude_list.txt | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/requirements-tests-py3.txt b/requirements-tests-py3.txt index b06ea2631f12..44832310f88d 100644 --- a/requirements-tests-py3.txt +++ b/requirements-tests-py3.txt @@ -5,4 +5,4 @@ flake8==3.8.3 flake8-bugbear==20.1.4 flake8-pyi==20.5.0 isort[pyproject]==5.1.1 -pytype>=2020.07.20 +pytype>=2020.07.24 diff --git a/tests/pytype_exclude_list.txt b/tests/pytype_exclude_list.txt index 6f49be66dfe1..8641d4e6b466 100644 --- a/tests/pytype_exclude_list.txt +++ b/tests/pytype_exclude_list.txt @@ -15,6 +15,3 @@ third_party/2and3/attr/converters.pyi third_party/2and3/attr/filters.pyi third_party/2and3/attr/validators.pyi third_party/2and3/pynamodb/models.pyi - -# https://github.com/google/pytype/issues/612 -third_party/3/pytest_mock/plugin.pyi