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

Fix ValueError: max() arg is an empty sequence on #1529

Merged
merged 3 commits into from
Mar 23, 2020

Conversation

jquast
Copy link

@jquast jquast commented Feb 19, 2020

Closes #1343. When running tox -l with a tox.ini file not containing any default environments, instead of an empty output, an exception is raised:

$ tox -l
Traceback (most recent call last):
  File "/Users/jq/.pyenv/versions/py38/bin/tox", line 8, in <module>
    sys.exit(cmdline())
  File "/Users/jq/.pyenv/versions/3.8.1/envs/py38/lib/python3.8/site-packages/tox/session/__init__.py", line 44, in cmdline
    main(args)
  File "/Users/jq/.pyenv/versions/3.8.1/envs/py38/lib/python3.8/site-packages/tox/session/__init__.py", line 68, in main
    exit_code = session.runcommand()
  File "/Users/jq/.pyenv/versions/3.8.1/envs/py38/lib/python3.8/site-packages/tox/session/__init__.py", line 189, in runcommand
    self.showenvs(all_envs=False, description=show_description)
  File "/Users/jq/.pyenv/versions/3.8.1/envs/py38/lib/python3.8/site-packages/tox/session/__init__.py", line 293, in showenvs
    show_envs(self.config, all_envs=all_envs, description=description)
  File "/Users/jq/.pyenv/versions/3.8.1/envs/py38/lib/python3.8/site-packages/tox/session/commands/show_env.py", line 14, in show_envs
    max_length = max((len(env) for env in (default + extra)))
ValueError: max() arg is an empty sequence

This change resolves the issue by setting the value of max_length to 0 when default and extra are empty.

When running `tox -l` with a tox.ini file not containing any default environments, instead of an empty output, an exception is raised:

```
$ tox -l
tox -l
Traceback (most recent call last):
  File "/Users/jq/.pyenv/versions/py38/bin/tox", line 8, in <module>
    sys.exit(cmdline())
  File "/Users/jq/.pyenv/versions/3.8.1/envs/py38/lib/python3.8/site-packages/tox/session/__init__.py", line 44, in cmdline
    main(args)
  File "/Users/jq/.pyenv/versions/3.8.1/envs/py38/lib/python3.8/site-packages/tox/session/__init__.py", line 68, in main
    exit_code = session.runcommand()
  File "/Users/jq/.pyenv/versions/3.8.1/envs/py38/lib/python3.8/site-packages/tox/session/__init__.py", line 189, in runcommand
    self.showenvs(all_envs=False, description=show_description)
  File "/Users/jq/.pyenv/versions/3.8.1/envs/py38/lib/python3.8/site-packages/tox/session/__init__.py", line 293, in showenvs
    show_envs(self.config, all_envs=all_envs, description=description)
  File "/Users/jq/.pyenv/versions/3.8.1/envs/py38/lib/python3.8/site-packages/tox/session/commands/show_env.py", line 14, in show_envs
    max_length = max((len(env) for env in (default + extra)))
ValueError: max() arg is an empty sequence
```
Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is on hold until we fix the master CI. This also needs a test.

Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs test 👍

@gaborbernat gaborbernat merged commit 549f7ee into tox-dev:master Mar 23, 2020
@gaborbernat
Copy link
Member

released via https://pypi.org/project/tox/3.14.6/

@jquast jquast deleted the jquast-patch-1 branch April 3, 2020 05:57
ssbarnea pushed a commit to ssbarnea/tox that referenced this pull request Apr 19, 2021
* fix ValueError: max() arg is an empty sequence

When running `tox -l` with a tox.ini file not containing any default environments, instead of an empty output, an exception is raised:

```
$ tox -l
tox -l
Traceback (most recent call last):
  File "/Users/jq/.pyenv/versions/py38/bin/tox", line 8, in <module>
    sys.exit(cmdline())
  File "/Users/jq/.pyenv/versions/3.8.1/envs/py38/lib/python3.8/site-packages/tox/session/__init__.py", line 44, in cmdline
    main(args)
  File "/Users/jq/.pyenv/versions/3.8.1/envs/py38/lib/python3.8/site-packages/tox/session/__init__.py", line 68, in main
    exit_code = session.runcommand()
  File "/Users/jq/.pyenv/versions/3.8.1/envs/py38/lib/python3.8/site-packages/tox/session/__init__.py", line 189, in runcommand
    self.showenvs(all_envs=False, description=show_description)
  File "/Users/jq/.pyenv/versions/3.8.1/envs/py38/lib/python3.8/site-packages/tox/session/__init__.py", line 293, in showenvs
    show_envs(self.config, all_envs=all_envs, description=description)
  File "/Users/jq/.pyenv/versions/3.8.1/envs/py38/lib/python3.8/site-packages/tox/session/commands/show_env.py", line 14, in show_envs
    max_length = max((len(env) for env in (default + extra)))
ValueError: max() arg is an empty sequence
```

* trying to follow contributing guidelines

* add test, fails without merge, succeeds after

Signed-off-by: Bernat Gabor <[email protected]>
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

Successfully merging this pull request may close these issues.

tox -l: ValueError: max() arg is an empty sequence
2 participants