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

Expand help doesn't work with Python 3.4 #158

Closed
fpietka opened this issue May 29, 2016 · 12 comments
Closed

Expand help doesn't work with Python 3.4 #158

fpietka opened this issue May 29, 2016 · 12 comments
Labels
Milestone

Comments

@fpietka
Copy link
Contributor

@fpietka fpietka commented May 29, 2016

I'm on OSX, although it works fine when I force Python 2.7, when using 3.4 I get this stack:

Traceback (most recent call last):
  File "/Users/fpietka/work/python/tmuxp/.venv/bin/tmuxp", line 9, in <module>
    load_entry_point('tmuxp==1.0.1', 'console_scripts', 'tmuxp')()
  File "/Users/fpietka/work/python/tmuxp/tmuxp/cli.py", line 981, in main
    parser.print_help()
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/argparse.py", line 2352, in print_help
    self._print_message(self.format_help(), file)
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/argparse.py", line 2336, in format_help
    return formatter.format_help()
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/argparse.py", line 278, in format_help
    help = self._root_section.format_help()
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/argparse.py", line 208, in format_help
    func(*args)
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/argparse.py", line 208, in format_help
    func(*args)
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/argparse.py", line 515, in _format_action
    help_text = self._expand_help(action)
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/argparse.py", line 602, in _expand_help
    return self._get_help_string(action) % params
TypeError: unsupported operand type(s) for %: 'tuple' and 'dict'

to reproduce I just have to call tmuxp without any argument within the virtualenv.

@tony
Copy link
Member

@tony tony commented May 29, 2016

I cannot reproduce.

~/work/python/tmuxp master
❯ virtualenv -ppython3.4 .venv3
Running virtualenv with interpreter /Users/me/.pyenv/shims/python3.4
Using base prefix '/Users/me/.pyenv/versions/3.4.4'
New python executable in /Users/me/work/python/tmuxp/.venv3/bin/python3.4
Also creating executable in /Users/me/work/python/tmuxp/.venv3/bin/python
Installing setuptools, pip, wheel.... .venv3/bdone.

~/work/python/tmuxp master
❯ . .venv3/bin/activate

~/work/python/tmuxp .venv3 master
❯ pip install -e .
Obtaining file:///Users/me/work/python/tmuxp
Collecting kaptan>=0.5.7 (from tmuxp==1.0.1)
  Using cached kaptan-0.5.8.tar.gz
Collecting libtmux==0.4.1 (from tmuxp==1.0.1)
  Using cached libtmux-0.4.1.tar.gz
Collecting argcomplete (from tmuxp==1.0.1)
  Using cached argcomplete-1.2.0-py2.py3-none-any.whl
Collecting colorama (from tmuxp==1.0.1)
  Using cached colorama-0.3.7-py2.py3-none-any.whl
Collecting PyYAML (from kaptan>=0.5.7->tmuxp==1.0.1)
  Using cached PyYAML-3.11.zip
tmBuilding wheels for collected packages: kaptan, libtmux, PyYAML
ux  Running setup.py bdist_wheel for kaptan ... -done
  Stored in directory: /Users/me/Library/Caches/pip/wheels/dc/11/ab/28f9ff0d1c76932ee9b037db0a1a7b20256c1e26638ae5e0aa
  Running setup.py bdist_wheel for libtmux ... done
  Stored in directory: /Users/me/Library/Caches/pip/wheels/7b/eb/76/ed394af7049fe4062011b4295ae490c96307256da9085800e1
  Running setup.py bdist_wheel for PyYAML ... done
  Stored in directory: /Users/me/Library/Caches/pip/wheels/4a/bf/14/d79994d19a59d4f73efdafb8682961f582d45ed6b459420346
Successfully built kaptan libtmux PyYAML
Installing collected packages: PyYAML, kaptan, libtmux, argcomplete, colorama, tmuxp
  Running setup.py develop for tmuxp
Successfully installed PyYAML-3.11 argcomplete-1.2.0 colorama-0.3.7 kaptan-0.5.8 libtmux-0.4.1 tmuxp

~/work/python/tmuxp .venv3 master
❯ tmuxp
usage: tmuxp [-h] [-L socket-name] [-S socket-path] [-y]
             [--log-level LOG_LEVEL] [-v]
             {kill-session,attach-session,freeze,load,convert,import} ...
tmuxp: error: too few arguments

~/work/python/tmuxp .venv3 master
❯ tmuxp --help
usage: tmuxp [-h] [-L socket-name] [-S socket-path] [-y]
             [--log-level LOG_LEVEL] [-v]
             {kill-session,attach-session,freeze,load,convert,import} ...

Launch tmux workspace. Help documentation: <http://tmuxp.rtfd.org>.

optional arguments:
  -h, --help            show this help message and exit
  -L socket-name        socket name of tmux server. Same as tmux.
  -S socket-path        socket path of tmux server. Same as tmux.
  -y                    Always answer yes.
  --log-level LOG_LEVEL
                        Level of debug verbosity. DEBUG, INFO, WARNING, ERROR,
                        CRITICAL.
  -v, --version         Prints the tmuxp version

commands:
  valid commands

  {kill-session,attach-session,freeze,load,convert,import}
    kill-session        Kill tmux session by name.
    attach-session      If run from outside tmux, create a new client in the
                        current terminal and attach it. If used from inside,
                        switch the current client.
    freeze              Create a snapshot of a tmux session and save it to
                        JSON or YAML.
    load                Load configurations from one or more files. Attach to
                        the session described by the last file. If it already
                        exists, offer to attach instead.
    convert             Convert tmuxp config between YAML and JSON format.
    import              Import configurations from teamocil and tmuxinator.

~/work/python/tmuxp .venv3 master
❯ python --version
Python 3.4.4

Can you try upgrading your python from 3.4.2 to 3.4.4?

Loading

@fpietka
Copy link
Contributor Author

@fpietka fpietka commented May 29, 2016

I just did the upgrade, and I have the same issue with 3.4.4 and 3.5.1:

Traceback (most recent call last):
  File "/Users/fpietka/work/python/tmuxp/.venv/bin/tmuxp", line 9, in <module>
    load_entry_point('tmuxp', 'console_scripts', 'tmuxp')()
  File "/Users/fpietka/work/python/tmuxp/tmuxp/cli.py", line 980, in main
    parser.print_help()
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/argparse.py", line 2358, in print_help
    self._print_message(self.format_help(), file)
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/argparse.py", line 2342, in format_help
    return formatter.format_help()
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/argparse.py", line 278, in format_help
    help = self._root_section.format_help()
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/argparse.py", line 208, in format_help
    func(*args)
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/argparse.py", line 208, in format_help
    func(*args)
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/argparse.py", line 515, in _format_action
    help_text = self._expand_help(action)
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/argparse.py", line 602, in _expand_help
    return self._get_help_string(action) % params
TypeError: unsupported operand type(s) for %: 'tuple' and 'dict'

Loading

@tony
Copy link
Member

@tony tony commented May 29, 2016

try pip install argparse

does that fix it?

Loading

@fpietka
Copy link
Contributor Author

@fpietka fpietka commented May 29, 2016

No, but in this case it doesn't seem to use the venv version for some reason... I'll look into that point

Loading

@tony
Copy link
Member

@tony tony commented May 29, 2016

I am not sure if this is a tmuxp issue or an environment issue at this point.

Can you try to pip install -U setuptools tmuxp outside virtualenv, and try to install tmuxp in a fresh virtualenv?

Are you sure you're sourced in the virtualenv ? via . or source?

Loading

@fpietka
Copy link
Contributor Author

@fpietka fpietka commented May 29, 2016

nothing is working...
seems to be related to homebrew install of python ...
I need to sort it somehow, but it isn't related to tmuxp.

Loading

@fpietka fpietka closed this May 29, 2016
@fpietka
Copy link
Contributor Author

@fpietka fpietka commented May 29, 2016

@tony just to be sure, I tried on a debian with vagrant. I could reproduce with tmuxp -h.

Loading

@tony
Copy link
Member

@tony tony commented May 29, 2016

@fpietka can you give me step by step instructions in how you encounter this error so I can try to reproduce on my end?

Loading

@fpietka
Copy link
Contributor Author

@fpietka fpietka commented May 29, 2016

I just installed using pip on a vagrant box, and typed tmuxp -h.

Also got the same result on linux mint:

$ tmuxp -h
Traceback (most recent call last):
  File "/usr/local/bin/tmuxp", line 9, in <module>
    load_entry_point('tmuxp==1.0.1', 'console_scripts', 'tmuxp')()
  File "/usr/local/lib/python2.7/dist-packages/tmuxp/cli.py", line 954, in main
    args = parser.parse_args()
  File "/usr/lib/python2.7/argparse.py", line 1690, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib/python2.7/argparse.py", line 1722, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib/python2.7/argparse.py", line 1928, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/lib/python2.7/argparse.py", line 1868, in consume_optional
    take_action(action, args, option_string)
  File "/usr/lib/python2.7/argparse.py", line 1796, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/lib/python2.7/argparse.py", line 996, in __call__
    parser.print_help()
  File "/usr/lib/python2.7/argparse.py", line 2329, in print_help
    self._print_message(self.format_help(), file)
  File "/usr/lib/python2.7/argparse.py", line 2303, in format_help
    return formatter.format_help()
  File "/usr/lib/python2.7/argparse.py", line 281, in format_help
    help = self._root_section.format_help()
  File "/usr/lib/python2.7/argparse.py", line 211, in format_help
    func(*args)
  File "/usr/lib/python2.7/argparse.py", line 211, in format_help
    func(*args)
  File "/usr/lib/python2.7/argparse.py", line 517, in _format_action
    help_text = self._expand_help(action)
  File "/usr/lib/python2.7/argparse.py", line 603, in _expand_help
    return self._get_help_string(action) % params
TypeError: unsupported operand type(s) for %: 'tuple' and 'dict'

Loading

@tony
Copy link
Member

@tony tony commented May 29, 2016

Okay I see it now.

Loading

@tony tony reopened this May 29, 2016
@tony tony added this to the Milestone 1.1 milestone May 30, 2016
@tony tony added this to the Milestone 1.1 milestone May 30, 2016
@tony
Copy link
Member

@tony tony commented May 31, 2016

#164 huge overhaul of cli spaghetti code underway.

Loading

@tony
Copy link
Member

@tony tony commented Jun 1, 2016

Switched to click, this should be solved

Loading

@tony tony closed this Jun 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants