My project structure looks like this:
project/
app/
main.py
venv/
.pylintrc
.pre-commit-config.yaml
When I am trying to edit project/app/main.py
and it fails with
Unable to import 'psycopg2' (import-error)
But when I am trying to pylint this file directly, it works.
.pre-commit-config.yaml
looks like this:
- repo: https://github.com/PyCQA/pylint
rev: pylint-2.4.2
hooks:
- id: pylint
not sure if this made it into pylint proper but there's a disclaimer on the bottom of pre-commit/mirrors-pylint
pre-commit runs pylint from an isolated virtualenv. Many of pylint's checks perform dynamic analysis which will fail there. You may find configuring pylint as a
local
hook more useful.
if you have very few dependencies, additional_dependencies
might be enough to make it work, but using local
hooks for things which need to (~essentially) import your code is probably your best bet
disclaimer: I'm the author of pre-commit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With