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

Using negative flag forms (e.g. no-header, no-annotate) in config has no effect #1909

Closed
AndydeCleyre opened this issue Jul 12, 2023 · 3 comments · Fixed by #1913
Closed
Labels
bug Something is not working config Related to pip-tools' configuration

Comments

@AndydeCleyre
Copy link
Contributor

When testing out the new config behavior, if I add entries to [tool.pip-tools] like

no-annotate = true

or

no-header = true

then there are two surprises:

  • the option does not take effect; it must be given in the positive form (annotate = false and header = false)
  • there is no warning or error about unknown options being given, making this problem easy to miss

Environment Versions

  1. Linux
  2. Python version: 3.10.6
  3. pip version: 23.1.2
  4. pip-tools version: 6.14.0

Steps to replicate

$ git clone https://github.com/jazzband/pip-tools
$ cd pip-tools
$ printf '%s\n' '[tool.pip-tools]' 'no-annotate = true' >>pyproject.toml
$ printf '%s\n' httpx >requirements.in
$ python -m venv .venv
$ . ./.venv/bin/activate
$ pip install -U pip pip-tools
$ pip-compile requirements.in

Expected result

Either

  • there be no annotations in the output, since --no-annotate is a valid flag, and --no-annotate should also appear in the generated header, or
  • a warning or error should be presented due to an unrecognized option being supplied

Actual result

WARNING: the legacy dependency resolver is deprecated and will be removed in future versions of pip-tools. The default resolver will be changed to 'backtracking' in pip-tools 7.0.0. Specify --resolver=backtracking to silence this warning.
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
#    pip-compile requirements.in
#
anyio==3.7.1
    # via httpcore
certifi==2023.5.7
    # via
    #   httpcore
    #   httpx
exceptiongroup==1.1.2
    # via anyio
h11==0.14.0
    # via httpcore
httpcore==0.17.3
    # via httpx
httpx==0.24.1
    # via -r requirements.in
idna==3.4
    # via
    #   anyio
    #   httpx
sniffio==1.3.0
    # via
    #   anyio
    #   httpcore
    #   httpx
@chrysle
Copy link
Contributor

chrysle commented Jul 13, 2023

Can reproduce this. Working on a fix.

@chrysle
Copy link
Contributor

chrysle commented Jul 13, 2023

  • there be no annotations in the output, since --no-annotate is a valid flag, and --no-annotate should also appear in the generated header

I've tracked this down and it looks like click currently doesn't allow for setting default values for negating boolean flags. This means annotate = false is the equivalent for no_annotate = true.

I've tried implementing a feature switch, but that doesn't work either.

@atugushev
Copy link
Member

atugushev commented Jul 13, 2023

@AndydeCleyre could you try this draft #1910?

@atugushev atugushev added the bug Something is not working label Jul 13, 2023
@atugushev atugushev added the config Related to pip-tools' configuration label Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working config Related to pip-tools' configuration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants