Skip to content

Commit 1c44f35

Browse files
sumanthratnaBorda
andcommitted
Fix mypy 0.800 plus when prepending $PYTHONPATH to sys.path (#5698)
* Fix mypy when prepending $PYTHONPATH to sys.path * attempt mypy fix * Revert "attempt mypy fix" This reverts commit fb7ed82. * fix mypy Co-authored-by: Jirka Borovec <[email protected]>
1 parent da02ac3 commit 1c44f35

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

.github/workflows/code-formatting.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
python-version: 3.8
7070
- name: Install mypy
7171
run: |
72-
pip install "mypy==0.790"
72+
pip install mypy==0.790
7373
pip list
7474
- name: mypy check
7575
run: |

tests/models/data/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# this is needed only for mypy==0.800 as it undestands only packages

tests/models/data/horovod/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# this is needed only for mypy==0.800 as it undestands only packages

tests/models/data/horovod/train_default_model.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
import os
2222
import sys
2323

24-
# this is need as e.g. Conda do not uses `PYTHONPATH` env var as pip or/and virtualenv
25-
from pytorch_lightning.trainer.states import TrainerState
26-
27-
sys.path = os.getenv('PYTHONPATH').split(':') + sys.path
24+
# this is needed because Conda does not use `PYTHONPATH` env var while pip and virtualenv do
25+
PYTHONPATH = os.getenv('PYTHONPATH', '')
26+
if ':' in PYTHONPATH:
27+
sys.path = PYTHONPATH.split(':') + sys.path
2828

2929
from pytorch_lightning import Trainer # noqa: E402
3030
from pytorch_lightning.callbacks import ModelCheckpoint # noqa: E402

0 commit comments

Comments
 (0)