Pre-commit: Possible to configure a hook so pip installs "extras"?

Created on 26 Jun 2020  路  3Comments  路  Source: pre-commit/pre-commit

When isort is installed as part of a pre-commit hook, it needs to be installed with setuptools' "extras" for pyproject.

This is installed with pip install isort[pyproject] rather than the default install of pip install isort. When installing from a local repo, the command is pip install .[pyproject]

Is it possible to specify that in a .pre-commit-hooks.yaml?

Ref https://github.com/timothycrosley/isort/issues/1225

Thank you!

Most helpful comment

specifically:

-   id: isort
    additional_dependencies: ['.[pyproject]']

or whatever extra you want

All 3 comments

I believe you're looking for additional_dependencies

specifically:

-   id: isort
    additional_dependencies: ['.[pyproject]']

or whatever extra you want

Ah, this used to bite me all the time! This solution (.[extra]) is a lot nicer than anything I ever came up with. I wonder if it's worth noting this trick in the docs somewhere? I guess it's low priority because isort no longer has these set up as extras, but still, this is a really nice solution and I feel like it should be more visible.

Was this page helpful?
0 / 5 - 0 ratings