Skip to content

Extending the PATH of the original virtualenv into pre-commit's virtualenv #181

Closed

Description

@dinoshauer

Hey guys, currently I have an open issue on the python-import-sorter pre-commit hook.

I seem to have boiled the problem down to the fact that when the hook is running in pre-commit's virtualenv it doesn't have access to the PATH of the original virtualenv so it won't know which packages are third-/first-party - My troubleshooting is documented in the original issue above :)

Let me know if you need more info!

Activity

  1. asottile commented on Dec 19, 2014

    @asottile
    Member

    I've noticed similarly as well. It seems isort depends a bit too much on the running environment to determine first/third-party packages/modules.

    I've started a repository here which seems to do a better job of identifying imports statically, I'm hoping to either plug it into isort or write a separate thing that does a similar thing:

    http://github.com/asottile/aspy.refactor_imports

    I actually plan to work on this in the next coming weeks.

    But yes the idea that the virtualenvs are isolated is by design, you can work around this by making a system type hook.

  2. dinoshauer commented on Dec 22, 2014

    @dinoshauer
    Author

    Ah, that's really cool. I'll look into making it a system hook if I get the time over christmas. Let me know if there's anything I can help with re: your version, I might be able to find some time :)

  3. asottile commented on Jan 2, 2015

    @asottile
    Member

    @dinoshauer I've started working on it here: https://github.com/asottile/reorder_python_imports

    From what I can tell it works pretty well? Mind poking around with it and see if it works for you?

  4. dinoshauer commented on Jan 2, 2015

    @dinoshauer
    Author

    @asottile I'll check it out and get back to you :)

  5. dinoshauer commented on Jan 2, 2015

    @dinoshauer
    Author

    Eureka, it works! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions