Skip to content

Commit

Permalink
Fix mypy 0.800 plus when prepending $PYTHONPATH to sys.path (#5698)
Browse files Browse the repository at this point in the history
* 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 <jirka.borovec@seznam.cz>
  • Loading branch information
sumanthratna and Borda committed Feb 5, 2021
1 parent e525ae1 commit 9c5619a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
python-version: 3.8
- name: Install mypy
run: |
pip install "mypy==0.790"
pip install mypy==0.790
pip list
- name: mypy check
run: |
Expand Down
1 change: 1 addition & 0 deletions tests/models/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# this is needed only for mypy==0.800 as it undestands only packages
1 change: 1 addition & 0 deletions tests/models/data/horovod/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# this is needed only for mypy==0.800 as it undestands only packages
8 changes: 4 additions & 4 deletions tests/models/data/horovod/train_default_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import os
import sys

# this is need as e.g. Conda do not uses `PYTHONPATH` env var as pip or/and virtualenv
from pytorch_lightning.trainer.states import TrainerState

sys.path = os.getenv('PYTHONPATH').split(':') + sys.path
# this is needed because Conda does not use `PYTHONPATH` env var while pip and virtualenv do
PYTHONPATH = os.getenv('PYTHONPATH', '')
if ':' in PYTHONPATH:
sys.path = PYTHONPATH.split(':') + sys.path

from pytorch_lightning import Trainer # noqa: E402
from pytorch_lightning.callbacks import ModelCheckpoint # noqa: E402
Expand Down

0 comments on commit 9c5619a

Please sign in to comment.