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

CWP change to argparse breaks shortcuts to execute module with -m option #177

Closed
2 tasks done
JTignor-Raltron opened this issue Jan 25, 2024 · 2 comments · Fixed by #182
Closed
2 tasks done

CWP change to argparse breaks shortcuts to execute module with -m option #177

JTignor-Raltron opened this issue Jan 25, 2024 · 2 comments · Fixed by #182
Labels
type::bug describes erroneous operation, use severity::* to classify the type

Comments

@JTignor-Raltron
Copy link
Contributor

JTignor-Raltron commented Jan 25, 2024

Checklist

  • I added a descriptive title
  • I searched open reports and couldn't find a duplicate

What happened?

I have not been the best about keeping my dev computer up to date, so this presented itself when I went to set up a new computer with our production software. We create shortcuts that execute cwp.py using pythonw providing the command to execute pythonw within the relevent environment with the -m option to run our module. These shortcuts did not work on the new machine. Trying to diagnose the issue I attempted to run the shortcut command manually on the terminal (using python instead of pythonw to get feedback:python [Anaconda install location]\cwp.py [environment prefix] [environment prefix]pythonw -m my.module) and got this error:

usage: cwp.py [-h] [--no-console] prefix [args ...] cwp.py: error: unrecognized arguments: -m my.module

I reported this yesterday in issue #167 but after a nights sleep I had an epiphany and not only do I realize this is a different issue, but I realized the cause. argparse is interpreting the -m as a new argument instead of part of the args argument. Did a little research to try to find a solution, but haven't found one so far.

Conda Info

No response

Conda Config

No response

Conda list

No response

Additional Context

No response

@JTignor-Raltron JTignor-Raltron added the type::bug describes erroneous operation, use severity::* to classify the type label Jan 25, 2024
@JTignor-Raltron
Copy link
Contributor Author

I've come back to report I've found a solution, although it required the use of a feature that isn't in the argparse documentation anymore, although it's not planned to be removed. If you instead set nargs=argparse.REMAINDER it works as intended.

@jaimergp
Copy link
Contributor

Awesome, do you want to submit a PR with the change or would you rather us handle it?

JTignor-Raltron added a commit to JTignor-Raltron/menuinst that referenced this issue Jan 26, 2024
Parameters that start with "-" are interpreted as a new argument. argparse.REMAINDER forces it to interpret all everything left in the command as a list of strings instead of new arguments. Fixes issue conda#177
jaimergp added a commit that referenced this issue Jan 26, 2024
* Fix commands with arguments that start with "-"

Parameters that start with "-" are interpreted as a new argument. argparse.REMAINDER forces it to interpret all everything left in the command as a list of strings instead of new arguments. Fixes issue #177

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update tests/_legacy/test_cwp.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: jaimergp <jaimergp@users.noreply.github.com>
@jaimergp jaimergp linked a pull request Jan 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type::bug describes erroneous operation, use severity::* to classify the type
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants