Skip to content

Allow using system wide python modules #362

Closed

Description

@thiblahute

I am trying to use pre-commit instead of git-pylint-commit-hook for the pitivi project, but we depend on gobject-introspection and running pylint with pre-commit on our code we get:

Traceback (most recent call last):
  File "/home/thiblahute/.pre-commit/reporeumijub/py_env-default/bin/pylint", line 11, in <module>
    sys.exit(run_pylint())
  File "/home/thiblahute/.pre-commit/reporeumijub/py_env-default/lib/python3.5/site-packages/pylint/__init__.py", line 23, in run_pylint
    Run(sys.argv[1:])
  File "/home/thiblahute/.pre-commit/reporeumijub/py_env-default/lib/python3.5/site-packages/pylint/lint.py", line 1273, in __init__
    'init-hook')))
  File "/home/thiblahute/.pre-commit/reporeumijub/py_env-default/lib/python3.5/site-packages/pylint/lint.py", line 1374, in cb_init_hook
    exec(value) # pylint: disable=exec-used
  File "<string>", line 1, in <module>
ImportError: No module named 'gi'

I know there is a additional_dependencies but for our case it means installing way to much things in the virtual environment and I think it does not make sense, and would be pretty complex, also we already have our own development environment. Maybe I am missing something but I can not find how that should be solved.

Activity

  1. asottile commented on Apr 7, 2016

    @asottile
    Member

    Ah yes, pylint does more than static analysis so it needs to both import your code and your dependencies.

    There's a supported way to do this through "local" (system) hooks (which still need documentation :/) pre-commit/pre-commit.com#50 -- You can also share a configured "system" hook (in a repo) if that makes more sense for you.

    Here's an example for how you can do this: https://github.com/Yelp/venv-update/blob/2a57651bb192770ec0e55171a1c2fdaa30c3fb8d/.pre-commit-config.yaml#L29-L35

  2. asottile commented on May 4, 2016

    @asottile
    Member

    local hooks are now documented here: http://pre-commit.com/#repository-local-hooks

  3. added a commit that references this issue on Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions