Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mypy pre-commit tests keep failing #1041

Closed
Alex-JG3 opened this issue Oct 16, 2021 · 2 comments
Closed

Mypy pre-commit tests keep failing #1041

Alex-JG3 opened this issue Oct 16, 2021 · 2 comments

Comments

@Alex-JG3
Copy link
Contributor

Alex-JG3 commented Oct 16, 2021

🐛 Bug

I have set up a developer environment by following the contributing guide. I made a small change to albumentations\augmentations\geometric\functional.py but the pre-commit mypy tests keep failing.

To Reproduce

Steps to reproduce the behavior:

  1. Fork the repo.
  2. Set up the environment by following the contributing guide.
  3. Add print("Hello, world!") to line 18 in albumentations\augmentations\geometric\functional.py
  4. Execute git add albumentations\augmentations\geometric\functional.py
  5. Execute git commit -m "Test change"

The following error message should be produced.

git commit -m "Test commit"
Trim Trailing Whitespace.................................................Passed
Fix End of Files.........................................................Passed
Fix requirements.txt.................................(no files to check)Skipped       
Check JSON...........................................(no files to check)Skipped       
Check Yaml...........................................(no files to check)Skipped       
isort....................................................................Passed
black....................................................................Passed
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

albumentations\core\serialization.py:7: error: Library stubs not installed for "yaml" 
(or incompatible with Python 3.8)
albumentations\core\serialization.py:7: note: Hint: "python3 -m pip install types-PyYAML"
albumentations\core\serialization.py:7: note: (or run "mypy --install-types" to install all missing stub packages)
albumentations\core\serialization.py:7: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)

flake8...................................................................Passed

Executing python3 -m pip install types-PyYAML or mypy --install-types do not help, the same error message is produced.

Expected behavior

All pre-commit tests should pass.

Environment

  • Python version (e.g., 3.8):
  • OS: Windows:

conda environment:

atomicwrites==1.4.0
attrs==21.2.0
backports.entry-points-selectable==1.1.0
black==21.9b0
certifi==2021.10.8
cfgv==3.3.1
click==8.0.3
colorama==0.4.4
cycler==0.10.0
distlib==0.3.3
filelock==3.3.1
flake8==4.0.1
identify==2.3.0
imageio==2.9.0
iniconfig==1.1.1
joblib==1.1.0
kiwisolver==1.3.2
matplotlib==3.4.3
mccabe==0.6.1
mypy==0.910
mypy-extensions==0.4.3
networkx==2.6.3
nodeenv==1.6.0
numpy==1.21.2
opencv-python-headless==4.5.3.56
packaging==21.0
pathspec==0.9.0
Pillow==8.4.0
platformdirs==2.4.0
pluggy==1.0.0
pre-commit==2.15.0
py==1.10.0
pycodestyle==2.8.0
pyflakes==2.4.0
pyparsing==2.4.7
pytest==6.2.5
python-dateutil==2.8.2
PyWavelets==1.1.1
PyYAML==6.0
qudida==0.0.4
regex==2021.10.8
scikit-image==0.18.3
scikit-learn==1.0
scipy==1.7.1
six==1.16.0
threadpoolctl==3.0.0
tifffile==2021.10.12
toml==0.10.2
tomli==1.2.1
types-PyYAML==5.4.12
typing-extensions==3.10.0.2
virtualenv==20.8.1
wincertstore==0.2

Additional context

The following issue might be relevant python/mypy#10632.

I have been able to solve the issue by adding additional_dependencies: [ types-PyYAML==5.4.12 ] to the following line.

@Dipet
Copy link
Collaborator

Dipet commented Oct 17, 2021

Are you sure that you are using the same interpreter as pre-commit? Because I see that you have installed types-PyYAML, but pre-commit can not find it.

@Alex-JG3
Copy link
Contributor Author

I think you are right. Is there are way to see which interpreter pre-commit is using? Or is there a way to change the interpreter that pre-commit is using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants