Open zjpiazza opened 3 years ago
please share the .pre-commit-config.yaml file where you have added pdoc hook and possibly the github project link if the project is public
I'm having the same issue, here is my pre-commit (only pdoc related) :
- repo: https://github.com/pdoc3/pdoc
rev: master
hooks:
- id: pdoc
name: pdoc
description: 'pdoc: Auto-generate API documentation for Python projects'
entry: pdoc --html -f -o docs module1 module2 module3
language: python
language_version: python3
require_serial: true
types: [python]
always_run: true
I have some packages installed that are out of stdlib that raise ModyleNotfoundError
. I didn't take time to replicate with minimal version but it should be easy :
A possible source of success is which python is used to trigger pdoc within pre-commit. If it's systems default (python
or python3
), depending on whether the module is installed or not, it might work.
Edit : I looked into my logs and it seems that pre-commit has its own virtualenv (kinda). It's probably more related to pre-commit than pdoc. Pdoc triggers this because it imports modules (other hooks usually don't, they only take them as text).
/Users/<username>/.cache/pre-commit/<repo_version>/py_env-python3/lib/python3.8/site-packages/pdoc/__init__.py", line 224, in import_module
I looked into my logs and it seems that pre-commit has its own virtualenv
Seems to me the only workaround, then, is to use repository-local hooks? Something like:
- repo: local
hooks:
- id: pdoc
name: pdoc
language: system
entry: python -m pip install pdoc3 && pdoc --html -f -o docs package
:confused:
It does work and I agree with you, it's probably the only solution. Do you want a PR to include this in the readme ?
Expected Behavior
After running pre-commit hook, to have generated pdoc output in the directory
Actual Behavior
ModuleNotFoundError is raised when running the pdoc pre-commit hook
Steps to Reproduce
Additional info