-
Notifications
You must be signed in to change notification settings - Fork 3
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
Pre-Commit compatibillity issue with PYTHONPATH #522
Comments
I can sort of mitigate it with: - repo: https://github.com/jshwi/docsig
rev: v0.65.0
hooks:
- id: docsig
entry: bash -c 'PYTHONPATH=$PWD docsig $@'
require_serial: true |
Hi @niall-byrne Thanks for opening this issue I am actually aware of this issue, when I came across this the first time it took me a while to work it out, sorry if took you a bit of time too The inference for check overridden is provided by I use it like the following, and therefore am unable to use it with # $ cat .pre-commit-config.yaml
repos:
- repo: local
hooks:
# local so package can be imported to lint
- id: lint
name: lint
entry: make .make/lint
language: system
pass_filenames: false # $ cat Makefile
#: lint code
.make/lint: $(VENV) $(PYTHON_FILES)
@$(POETRY) run pylint --output-format=colorized $(PYTHON_FILES)
@$(POETRY) run docsig $(PYTHON_FILES)
@mkdir -p $(@D)
@touch $@ The main issue, I think, is poor documentation and As, unlike with Cheers, |
Thanks for taking a look, After digging further I'm finding deeply nested relative imports still don't work as expected. I don't mind making them fully qualified, as docsig is very useful, but it might make your tool more widely applicable if this wasn't a nuisance. It might be worth looking at the solution detailed in here before deciding on anything. The local hooks thing is definitely a solution for setting the initial PYTHONPATH, it's just unfortunate that it would require either adding docsig as a dependency or manually managing another virtual-environment. I guess that's what makes pre-commit so nice to use. I'll try taking a look at the issue referenced above to see if there is a solution that can be used. |
I have prepared a PR, that's still in progress: #530 The MAJORITY of tests now pass, but there is a minority that are failing due to differences in the reporting output. Do you mind having a look? What would be the desired output format? It might be easier to modify them all so there is a consistent naming scheme. |
I think I sorted out the reporting issue. |
Hey @niall-byrne |
Hey @niall-byrne |
I altered the report logic slightly, and am able to run the doctests locally now. |
awesome work @niall-byrne , thank you! |
Signed-off-by: Stephen Whitlock <stephen@jshwisolutions.com>
Signed-off-by: Stephen Whitlock <stephen@jshwisolutions.com>
I'm seeing some behaviour that I wanted to make sure I was identifying correctly.
This is specifically in relation to the
--check-overidden
option.There appears to be a variance between the CLI usage and when using the pre-commit hook.
This example will pass CLI checks, but will fail a pre-commit run:
pyproject.toml
folder/bases/base_class.py
folder/implementation1.py
I can run:
docsig folder/implementation1.py
This is no problem.
pre-commit run docsig --all-files
This fails.
After playing around with this a bit, it seems relative imports are the problem.
If I instead change this to a fully qualified import path, it will work consistently.
So this led me to trying:
PYTHONPATH=$PWD pre-commit run docsig --all-files
Which works fine.
I am hesitant to suggest a change at this point, as I haven't looked at the codebase yet.
Do you have any hunches as to how this might be mitigated?
Environment:
The text was updated successfully, but these errors were encountered: