pyinfra-dev / pyinfra

pyinfra turns Python code into shell commands and runs them on your servers. Execute ad-hoc commands and write declarative operations. Target SSH servers, local machine and Docker containers. Fast and scales from one server to thousands.
https://pyinfra.com
MIT License
3.85k stars 374 forks source link

Exception with --ssh-user/--user CLI option and click<7.0 #764

Closed gchazot closed 2 years ago

gchazot commented 2 years ago

Describe the bug

# pipenv run -- pyinfra 192.168.1.1 --ssh-user root --ssh-key my_key files.put scripts/shred_disks.sh /tmp/shred_disks.sh
--> An unexpected internal exception occurred:

  File "/home/foobar/.virtualenvs/myvenv/lib/python3.9/site-packages/pyinfra_cli/main.py", line 236, in cli
    _main(*args, **kwargs)
TypeError: _main() got an unexpected keyword argument 'user'

--> The full traceback has been written to pyinfra-debug.log
--> If this is unexpected please consider submitting a bug report on GitHub, for more information run `pyinfra --support`.

To Reproduce

Expected behavior

No exception is raised :-D

Meta

gchazot commented 2 years ago

I've also come down further to the bottom of this issue.It is a side effect of:

So this is a bit borderline bugfix on click side that broke backwards compatibility (and is not documented in the CHANGELOG :-1: ) but this causes a bug in pyinfra.

I think there are a couple of options to improve the situation and they're both quite simple:

  1. update pyinfra install requirements to need click>=7.0.
  2. make pyinfra compatible with both click situations by specifying explicitely the name of the option.

I think option 2 is the nicest as it introduces explicit naming, and avoids forcing users to upgrade both pyinfra and click

gchazot commented 2 years ago

PR #765 Implements the change for option 2. above