pre-commit failing on mypy hook with at least a 'Module has no attribute "getuid" error' · Issue #11343 · pytest-dev/pytest (original) (raw)
description of problem
On VS Code, I am attempting to commit a staged change of src\_pytest\config\__init__.py
; however, the pre-commit hook fails on mypy with command ouput:
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1
src\_pytest\compat.py:324: error: Module has no attribute "getuid"; maybe "getpid" or "getppid"? [attr-defined]
Found 1 error in 1 file (checked 1 source file)
Every other hook either passes or is skipped. I installed pre-commit and its hook on the pytest repo using
$ pip install --user pre-commit $ pre-commit install
pip list
output
(.venv) PS C:\pytest\pytest> pip list
Package Version Editable project location
------------------ --------------------------------- -------------------------
argcomplete 3.1.1
attrs 23.1.0
cachetools 5.3.1
certifi 2023.7.22
cfgv 3.4.0
chardet 5.2.0
charset-normalizer 3.2.0
colorama 0.4.6
distlib 0.3.7
elementpath 4.1.5
exceptiongroup 1.1.3
filelock 3.12.2
hypothesis 6.82.6
identify 2.5.26
idna 3.4
iniconfig 2.0.0
mock 5.1.0
nodeenv 1.8.0
nose 1.3.7
packaging 23.1
pip 23.2.1
platformdirs 3.10.0
pluggy 1.2.0
pre-commit 3.3.3
Pygments 2.16.1
pyproject-api 1.5.4
pytest 8.0.0.dev167+g37bb18617.d20230822 C:\pytest\pytest
PyYAML 6.0.1
requests 2.31.0
setuptools 58.1.0
sortedcontainers 2.4.0
tomli 2.0.1
tox 4.9.0
urllib3 2.0.4
virtualenv 20.24.3
xmlschema 2.4.0
pytest and operating system versions
$ pytest --version $ pytest 8.0.0.dev167+g37bb18617.d20230822
platform.system(), platform.release(), platform.version()
('Windows', '10', '10.0.19045')
minimal example
If I discard my changes and do pre-commit run --all-files
, everything passes or is skipped except for
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1
src\_pytest\compat.py:324: error: Module has no attribute "getuid"; maybe "getpid" or "getppid"? [attr-defined]
testing\test_parseopt.py:294: error: Module has no attribute "getencoding" [attr-defined]
Found 2 errors in 2 files (checked 224 source files)