Skip to content
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 hook TypeError exception #1473

Closed
1oglop1 opened this issue Aug 24, 2021 · 6 comments
Closed

pre-commit hook TypeError exception #1473

1oglop1 opened this issue Aug 24, 2021 · 6 comments

Comments

@1oglop1
Copy link

1oglop1 commented Aug 24, 2021

Hi I have pre-commit installed globally via brew so it's using py3.9.
When I use the hook it I get an exception: TypeError: make_requirement_preparer() got an unexpected keyword argument 'wheel_download_dir'.
Also worth noting that my current project (venv) is py 3.8.X.

I also tried to install all parts in the same virtualenv so that pre-commit and pip-tools execute from the same location and exactly the same python version.

I believe this may be related to #1207 and possibly to #1326

Environment Versions

  1. OS Type
  2. Python version: 3.8.2
  3. pip version: pip 21.2.4
  4. pip-tools version: 5.3.1

Steps to replicate

  1. Project structure: in example repo https://github.com/jans-forks/pip-tools-error
.
├── app
│   └── requirements
│       ├── base.txt
│       ├── deploy.txt
│       └── dev.txt
├── compiled.txt
└── root.txt
  1. pre-commit run --all-files

Expected result

According to the pre-commit config

repos:
  - repo: https://github.com/jazzband/pip-tools
    rev: 5.3.1
    hooks:
      - id: pip-compile
        name: pip-compile root dir
        verbose: true
        args:
        - "root.txt"
        - "--output-file=compiled.txt"
        files: ^root\.txt$

I expect the same result as pip-compile root.txt -output-file=compiled.txt

On top of that it seem to be broken for multiple files in subdirectory

if hook configuration is:

repos:
 - repo: https://github.com/jazzband/pip-tools
   rev: 5.3.1
   hooks:
      - id: pip-compile
        name: pip-compile app dir
        verbose: true
        args:
        - "app/requirements/base.txt"
        - "app/requirements/dev.txt"
        - "--output-file=compiled.txt"
       files: ^app/requirements/.+\.(in|txt)$

The expected result is same as
pip-compile app/requirements/base.txt app/requirements/dev.txt -output-file=compiled.txt
...

Actual result

Traceback (most recent call last):
  File "/home/user/.cache/pre-commit/repor59m35ps/py_env-python3.9/bin/pip-compile", line 8, in <module>
    sys.exit(cli())
  File "/home/user/.cache/pre-commit/repor59m35ps/py_env-python3.9/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.cache/pre-commit/repor59m35ps/py_env-python3.9/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/home/user/.cache/pre-commit/repor59m35ps/py_env-python3.9/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/.cache/pre-commit/repor59m35ps/py_env-python3.9/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/home/user/.cache/pre-commit/repor59m35ps/py_env-python3.9/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/user/.cache/pre-commit/repor59m35ps/py_env-python3.9/lib/python3.9/site-packages/piptools/scripts/compile.py", line 458, in cli
    results = resolver.resolve(max_rounds=max_rounds)
  File "/home/user/.cache/pre-commit/repor59m35ps/py_env-python3.9/lib/python3.9/site-packages/piptools/resolver.py", line 173, in resolve
    has_changed, best_matches = self._resolve_one_round()
  File "/home/user/.cache/pre-commit/repor59m35ps/py_env-python3.9/lib/python3.9/site-packages/piptools/resolver.py", line 278, in _resolve_one_round
    their_constraints.extend(self._iter_dependencies(best_match))
  File "/home/user/.cache/pre-commit/repor59m35ps/py_env-python3.9/lib/python3.9/site-packages/piptools/resolver.py", line 388, in _iter_dependencies
    dependencies = self.repository.get_dependencies(ireq)
  File "/home/user/.cache/pre-commit/repor59m35ps/py_env-python3.9/lib/python3.9/site-packages/piptools/repositories/pypi.py", line 231, in get_dependencies
    self._dependencies_cache[ireq] = self.resolve_reqs(
  File "/home/user/.cache/pre-commit/repor59m35ps/py_env-python3.9/lib/python3.9/site-packages/piptools/repositories/pypi.py", line 155, in resolve_reqs
    preparer = self.command.make_requirement_preparer(
TypeError: make_requirement_preparer() got an unexpected keyword argument 'wheel_download_dir'
@webknjaz
Copy link
Member

Could you also post an asciinema recording?

@webknjaz
Copy link
Member

  • pip-tools version: 5.3.1

Is it reproducible with the latest version/master? If not, it's unlikely for anybody to backport the fix.

@webknjaz
Copy link
Member

Looking at https://github.com/jazzband/pip-tools/blob/0b0daff/piptools/repositories/pypi.py#L173-L182, there's no wheel_download_dir mentioned so it's probably already fixed.

@webknjaz
Copy link
Member

@1oglop1
Copy link
Author

1oglop1 commented Aug 25, 2021

@webknjaz Nice, thanks!
It made me realise that I blindly copied the example with pinned version 5.3.1 and forgot to pre-commit autoupdate

@webknjaz
Copy link
Member

Do you want to send a PR updating that example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants