From c10b03977b22088f749a1c794dc39d644a42e9c0 Mon Sep 17 00:00:00 2001 From: Damian Zaremba Date: Wed, 20 Jul 2022 09:45:40 +0100 Subject: [PATCH] Remove base path from MYPYPATH After https://github.com/python/mypy/pull/11143, the search path for mypy has changed, resulting in the current path being present. Explicitly adding in the base path results in an error about the directory from the search_path (cwd) being present in `MYPYPATH`. Removing the base path from `MYPYPATH` and relying on just `pyinfo` to load the current path in appears to work as expected. --- pytest_mypy_plugins/item.py | 2 -- .../tests/test-paths-from-env.yml | 29 ------------------- setup.py | 2 +- 3 files changed, 1 insertion(+), 32 deletions(-) delete mode 100644 pytest_mypy_plugins/tests/test-paths-from-env.yml diff --git a/pytest_mypy_plugins/item.py b/pytest_mypy_plugins/item.py index 0c210a3..1ffd091 100644 --- a/pytest_mypy_plugins/item.py +++ b/pytest_mypy_plugins/item.py @@ -384,8 +384,6 @@ def _collect_mypy_path(self, rootdir: Optional[Path]) -> None: existing_mypy_path = os.environ.get("MYPYPATH") if existing_mypy_path: mypy_path_parts.append(existing_mypy_path) - if self.base_ini_fpath: - mypy_path_parts.append(os.path.dirname(self.base_ini_fpath)) mypy_path_key = self.environment_variables.get("MYPYPATH") if mypy_path_key: mypy_path_parts.append(maybe_to_abspath(mypy_path_key, rootdir)) diff --git a/pytest_mypy_plugins/tests/test-paths-from-env.yml b/pytest_mypy_plugins/tests/test-paths-from-env.yml deleted file mode 100644 index e355c80..0000000 --- a/pytest_mypy_plugins/tests/test-paths-from-env.yml +++ /dev/null @@ -1,29 +0,0 @@ -- case: mypy_path_from_env - main: | - from pair import Pair - - a: Pair - reveal_type(a) # N: Revealed type is "pair.Pair" - env: - - MYPYPATH=./pytest_mypy_plugins/tests/fixtures - - -- case: mypy_path_from_env_with_error - main: | - from pair import Missing - out: | - main:1: error: Module "pair" has no attribute "Missing" - env: - - MYPYPATH=./pytest_mypy_plugins/tests/fixtures - - -- case: add_mypypath_env_var_to_package_search - main: | - import extra_module - env: - - MYPYPATH=./extras - files: - - path: extras/extra_module.py - content: | - def extra_fn(): - pass diff --git a/setup.py b/setup.py index 55b2dbf..7dbadb8 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ dependencies = [ "pytest>=6.0.0", - "mypy>=0.900", + "mypy>=0.971", "decorator", "pyyaml", "chevron",