Skip to content

Commit 4bc3e75

Browse files
committed
Version 1.6.1 release
1 parent ae3671d commit 4bc3e75

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Version history
22

3+
4+
## Version 1.6.1
5+
6+
### Bugfixes
7+
8+
- Changes how `MYPYPATH` and `PYTHONPATH` are calcualted. We now expand `$PWD` variable and also include relative paths specified in `env:` section
9+
10+
311
## Version 1.6.0
412

513
### Features

pytest_mypy_plugins/item.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def replace_fpath_with_module_name(line: str, rootdir: Path) -> str:
7373

7474

7575
def maybe_to_abspath(rel_or_abs: str, rootdir: Optional[Path]) -> str:
76+
rel_or_abs = os.path.expandvars(rel_or_abs)
7677
if rootdir is None or os.path.isabs(rel_or_abs):
7778
return rel_or_abs
7879
return str(rootdir / rel_or_abs)
@@ -365,9 +366,8 @@ def _collect_python_path(
365366
python_path_parts.append(str(execution_path))
366367
python_path_key = self.environment_variables.get("PYTHONPATH")
367368
if python_path_key:
368-
python_path_parts.append(
369-
maybe_to_abspath(python_path_key, rootdir),
370-
)
369+
python_path_parts.append(maybe_to_abspath(python_path_key, rootdir))
370+
python_path_parts.append(python_path_key)
371371

372372
self.environment_variables["PYTHONPATH"] = ":".join(python_path_parts)
373373

@@ -381,8 +381,7 @@ def _collect_mypy_path(self, rootdir: Optional[Path]) -> None:
381381
mypy_path_parts.append(os.path.dirname(self.base_ini_fpath))
382382
mypy_path_key = self.environment_variables.get("MYPYPATH")
383383
if mypy_path_key:
384-
mypy_path_parts.append(
385-
maybe_to_abspath(mypy_path_key, rootdir),
386-
)
384+
mypy_path_parts.append(maybe_to_abspath(mypy_path_key, rootdir))
385+
mypy_path_parts.append(mypy_path_key)
387386

388387
self.environment_variables["MYPYPATH"] = ":".join(mypy_path_parts)

pytest_mypy_plugins/tests/test-paths-from-env.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,15 @@
1515
main:1: error: Module 'pair' has no attribute 'Missing'
1616
env:
1717
- MYPYPATH=./pytest_mypy_plugins/tests/fixtures
18+
19+
20+
- case: add_mypypath_env_var_to_package_search
21+
main: |
22+
import extra_module
23+
env:
24+
- MYPYPATH=./extras
25+
files:
26+
- path: extras/extra_module.py
27+
content: |
28+
def extra_fn():
29+
pass

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
setup(
1515
name="pytest-mypy-plugins",
16-
version="1.6.0",
16+
version="1.6.1",
1717
description="pytest plugin for writing tests for mypy plugins",
1818
long_description=readme,
1919
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)