Repository: pypa/pipenv

Issue:
pipenv cli without parameters show non-printable characters like [33m
```bash
$ lsb_release -a
  No LSB modules are available.
  Distributor ID:	Linuxmint
  Description:	Linux Mint 21.2
  Release:	21.2
  Codename:	victoria
$ gnome-terminal --version
  # GNOME Terminal 3.44.0 using VTE 0.68.0 +BIDI +GNUTLS +ICU +SYSTEMD
$ python --version
  Python 3.11.4
$ pipenv --version
  pipenv, version 2023.8.21
```

### Issue description

if I run the `pipenv` command without parameters, the output shows ASCII code of non-printable characters like `[33m`. The output doesn't have colors. 

### Expected result

I expect to see output without ASCII code of non-printable characters like the output of `pipenv -h`.

```console
$ pipenv -h
Usage: pipenv [OPTIONS] COMMAND [ARGS]...

Options:
  --where                         Output project home information.
  --venv                          Output virtualenv information.
  --py                            Output Python interpreter information.
  --envs                          Output Environment Variable options.
  --rm                            Remove the virtualenv.
  --bare                          Minimal output.
  --man                           Display manpage.
  --support                       Output diagnostic information for use in
                                  GitHub issues.
  --site-packages / --no-site-packages
                                  Enable site-packages for the virtualenv.
                                  [env var: PIPENV_SITE_PACKAGES]
  --python TEXT                   Specify which version of Python virtualenv
                                  should use.
  --clear                         Clears caches (pipenv, pip).  [env var:
                                  PIPENV_CLEAR]
  -q, --quiet                     Quiet mode.
  -v, --verbose                   Verbose mode.
  --pypi-mirror TEXT              Specify a PyPI mirror.
  --version                       Show the version and exit.
  -h, --help                      Show this message and exit.


Usage Examples:
   Create a new project using Python 3.7, specifically:
   $ pipenv --python 3.7

   Remove project virtualenv (inferred from current directory):
   $ pipenv --rm

   Install all dependencies for a project (including dev):
   $ pipenv install --dev

   Create a lockfile containing pre-releases:
   $ pipenv lock --pre

   Show a graph of your installed dependencies:
   $ pipenv graph

   Check your installed dependencies for security vulnerabilities:
   $ pipenv check

   Install a local setup.py into your virtual environment/Pipfile:
   $ pipenv install -e .

   Use a lower-level pip command:
   $ pipenv run pip freeze

Commands:
  check         Checks for PyUp Safety security vulnerabilities and against
                PEP 508 markers provided in Pipfile.
  clean         Uninstalls all packages not specified in Pipfile.lock.
  graph         Displays currently-installed dependency graph information.
  install       Installs provided packages and adds them to Pipfile, or (if no
                packages are given), installs all packages from Pipfile.
  lock          Generates Pipfile.lock.
  open          View a given module in your editor.
  requirements  Generate a requirements.txt from Pipfile.lock.
  run           Spawns a command installed into the virtualenv.
  scripts       Lists scripts in current environment config.
  shell         Spawns a shell within the virtualenv.
  sync          Installs all packages specified in Pipfile.lock.
  uninstall     Uninstalls a provided package and removes it from Pipfile.
  update        Runs lock, then sync.
  upgrade       Resolves provided packages and adds them to Pipfile, or (if no
                packages are given), merges results to Pipfile.lock
  verify        Verify the hash in Pipfile.lock is up-to-date.
```

### Actual result

```console
$ pipenv
Usage: [1mpipenv[0m [OPTIONS] COMMAND [ARGS]...

[1mOptions:[0m
  --where                         Output project home information.
  --venv                          Output virtualenv information.
  --py                            Output Python interpreter information.
  --envs                          Output Environment Variable options.
  --rm                            Remove the virtualenv.
  --bare                          Minimal output.
  --man                           Display manpage.
  --support                       Output diagnostic information for use in
                                  GitHub issues.
  --site-packages / --no-site-packages
                                  Enable site-packages for the virtualenv.
                                  
  --python TEXT                   Specify which version of Python virtualenv
                                  should use.
  --clear                         Clears caches (pipenv, pip).  
  -q, --quiet                     Quiet mode.
  -v, --verbose                   Verbose mode.
  --pypi-mirror TEXT              Specify a PyPI mirror.
  --version                       Show the version and exit.
  -h, --help                      Show this message and exit.


Usage Examples:
   Create a new project using Python 3.7, specifically:
   $ [33mpipenv --python 3.7[0m

   Remove project virtualenv (inferred from current directory):
   $ [33mpipenv --rm[0m

   Install all dependencies for a project (including dev):
   $ [33mpipenv install --dev[0m

   Create a lockfile containing pre-releases:
   $ [33mpipenv lock --pre[0m

   Show a graph of your installed dependencies:
   $ [33mpipenv graph[0m

   Check your installed dependencies for security vulnerabilities:
   $ [33mpipenv check[0m

   Install a local setup.py into your virtual environment/Pipfile:
   $ [33mpipenv install -e .[0m

   Use a lower-level pip command:
   $ [33mpipenv run pip freeze[0m

Commands:
[31m[1m  check[0m         Checks for PyUp Safety security vulnerabilities and against
                PEP 508 markers provided in Pipfile.
[31m[1m  clean[0m         Uninstalls all packages not specified in Pipfile.lock.
[31m[1m  graph[0m         Displays currently-installed dependency graph information.
[35m[1m  install[0m       Installs provided packages and adds them to Pipfile, or (if no
                packages are given), installs all packages from Pipfile.
[32m[1m  lock[0m          Generates Pipfile.lock.
[31m[1m  open[0m          View a given module in your editor.
  requirements  Generate a requirements.txt from Pipfile.lock.
[33m[1m  run[0m           Spawns a command installed into the virtualenv.
[33m[1m  scripts[0m       Lists scripts in current environment config.
[33m[1m  shell[0m         Spawns a shell within the virtualenv.
[32m[1m  sync[0m          Installs all packages specified in Pipfile.lock.
[35m[1m  uninstall[0m     Uninstalls a provided package and removes it from Pipfile.
[32m[1m  update[0m        Runs lock, then sync.
  upgrade       Resolves provided packages and adds them to Pipfile, or (if no
                packages are given), merges results to Pipfile.lock
  verify        Verify the hash in Pipfile.lock is up-to-date.
```

### Steps to replicate

```bash
$ pipenv
```

-------------------------------------------------------------------------------


<details><summary>$ pipenv --support</summary>

Pipenv version: `'2023.8.21'`

Pipenv location: `'/home/lhapaipai/.local/pipx/venvs/pipenv/lib/python3.10/site-packages/pipenv'`

Python location: `'/home/lhapaipai/.local/pipx/venvs/pipenv/bin/python'`

OS Name: `'posix'`

User pip version: `'23.2.1'`

user Python installations found:


PEP 508 Information:

```
{'implementation_name': 'cpython',
 'implementation_version': '3.10.12',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '5.15.0-79-generic',
 'platform_system': 'Linux',
 'platform_version': '#86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023',
 'python_full_version': '3.10.12',
 'python_version': '3.10',
 'sys_platform': 'linux'}
```

System environment variables:

  - `SHELL`
  - `SESSION_MANAGER`
  - `QT_ACCESSIBILITY`
  - `COLORTERM`
  - `PYENV_SHELL`
  - `XDG_CONFIG_DIRS`
  - `XDG_SESSION_PATH`
  - `GNOME_DESKTOP_SESSION_ID`
  - `LANGUAGE`
  - `SSH_AUTH_SOCK`
  - `DESKTOP_SESSION`
  - `GTK_MODULES`
  - `XDG_SEAT`
  - `PWD`
  - `LOGNAME`
  - `XDG_SESSION_DESKTOP`
  - `QT_QPA_PLATFORMTHEME`
  - `XDG_SESSION_TYPE`
  - `GPG_AGENT_INFO`
  - `XAUTHORITY`
  - `XDG_GREETER_DATA_DIR`
  - `GDM_LANG`
  - `HOME`
  - `LANG`
  - `LS_COLORS`
  - `XDG_CURRENT_DESKTOP`
  - `VTE_VERSION`
  - `XDG_SEAT_PATH`
  - `GNOME_TERMINAL_SCREEN`
  - `VOLTA_HOME`
  - `LESSCLOSE`
  - `XDG_SESSION_CLASS`
  - `TERM`
  - `LESSOPEN`
  - `USER`
  - `GNOME_TERMINAL_SERVICE`
  - `DISPLAY`
  - `SHLVL`
  - `XDG_VTNR`
  - `DESKTOP_AUTOSTART_ID`
  - `XDG_SESSION_ID`
  - `XDG_RUNTIME_DIR`
  - `PYENV_ROOT`
  - `GTK3_MODULES`
  - `XDG_DATA_DIRS`
  - `PATH`
  - `GDMSESSION`
  - `DBUS_SESSION_BUS_ADDRESS`
  - `_`
  - `PIP_DISABLE_PIP_VERSION_CHECK`
  - `PYTHONDONTWRITEBYTECODE`
  - `PYTHONFINDER_IGNORE_UNSUPPORTED`

Pipenv–specific environment variables:


Debug–specific environment variables:

  - `PATH`: `/home/lhapaipai/.pyenv/versions/3.11.4/bin:/home/lhapaipai/.pyenv/shims:/home/lhapaipai/.pyenv/bin:/home/lhapaipai/.volta/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/lhapaipai/.local/bin:/home/lhapaipai/bin:/home/lhapaipai/.local/bin:/home/lhapaipai/.local/bin`
  - `SHELL`: `/bin/bash`
  - `LANG`: `fr_FR.UTF-8`
  - `PWD`: `/home/lhapaipai`


---------------------------

</details>


Discussion:
This is weird, I confirm this behavior on linux (but windows I don't see it).  🤔 

@oz123 any ideas on this one?
are we mixing click.secho and rich console somewhere?
I'm using pipenv `2023.8.22` on macOS 12.6.8, same problem.

```
❯ pipenv --version
pipenv, version 2023.8.22
```

<details><summary>$ pipenv --support</summary>

Pipenv version: `'2023.8.22'`

Pipenv location: `'/usr/local/Cellar/pipenv/2023.8.22/libexec/lib/python3.11/site-packages/pipenv'`

Python location: `'/usr/local/Cellar/pipenv/2023.8.22/libexec/bin/python'`

OS Name: `'posix'`

User pip version: `'23.2.1'`

user Python installations found:


PEP 508 Information:

```
{'implementation_name': 'cpython',
 'implementation_version': '3.11.4',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '21.6.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 21.6.0: Thu Jul  6 22:18:26 PDT '
                     '2023; root:xnu-8020.240.18.702.13~1/RELEASE_X86_64',
 'python_full_version': '3.11.4',
 'python_version': '3.11',
 'sys_platform': 'darwin'}
```

System environment variables:

  - `PATH`
  - `LDFLAGS`
  - `TERM_PROGRAM`
  - `PYENV_ROOT`
  - `_P9K_TTY`
  - `TERM`
  - `SHELL`
  - `CPPFLAGS`
  - `PIPENV_VENV_IN_PROJECT`
  - `TMPDIR`
  - `TERM_PROGRAM_VERSION`
  - `TERM_SESSION_ID`
  - `LC_ALL`
  - `ZSH`
  - `USER`
  - `COMMAND_MODE`
  - `SSH_AUTH_SOCK`
  - `__CF_USER_TEXT_ENCODING`
  - `GO111MODULE`
  - `PAGER`
  - `LSCOLORS`
  - `_`
  - `LaunchInstanceID`
  - `__CFBundleIdentifier`
  - `PWD`
  - `P9K_SSH`
  - `LANG`
  - `P9K_TTY`
  - `ITERM_PROFILE`
  - `XPC_FLAGS`
  - `XPC_SERVICE_NAME`
  - `PYENV_SHELL`
  - `SHLVL`
  - `HOME`
  - `COLORFGBG`
  - `GOROOT`
  - `LC_TERMINAL_VERSION`
  - `ITERM_SESSION_ID`
  - `LESS`
  - `LOGNAME`
  - `LC_CTYPE`
  - `GOPATH`
  - `_P9K_SSH_TTY`
  - `LC_TERMINAL`
  - `SECURITYSESSIONID`
  - `COLORTERM`
  - `PIP_DISABLE_PIP_VERSION_CHECK`
  - `PYTHONDONTWRITEBYTECODE`
  - `PYTHONFINDER_IGNORE_UNSUPPORTED`

Pipenv–specific environment variables:

 - `PIPENV_VENV_IN_PROJECT`: `true`

Debug–specific environment variables:

  - `PATH`: `/Users/chi/.pyenv/versions/3.11.4/bin:/Users/chi/.pyenv/versions/3.8.17/bin:/Users/chi/.pyenv/versions/3.8.16/bin:/usr/local/Cellar/pipenv/2023.8.22/libexec/tools:/usr/local/opt/openssl@3/bin:/usr/local/opt/curl/bin:/Users/chi/.pyenv/shims:/Users/chi/.pyenv/bin:/Users/chi/.orbstack/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/chi/go/bin:/usr/local/opt/go/libexec/bin`
  - `SHELL`: `/bin/zsh`
  - `LANG`: `en_US.UTF-8`
  - `PWD`: `/Users/chi`


---------------------------

</details>

Resolving patch:
diff --git a/pipenv/cli/command.py b/pipenv/cli/command.py
--- a/pipenv/cli/command.py
+++ b/pipenv/cli/command.py
@@ -189,7 +189,7 @@ def cli(
     # Check this again before exiting for empty ``pipenv`` command.
     elif ctx.invoked_subcommand is None:
         # Display help to user, if no commands were passed.
-        console.print(format_help(ctx.get_help()))
+        print(format_help(ctx.get_help()))
 
 
 @cli.command(
diff --git a/pipenv/utils/funktools.py b/pipenv/utils/funktools.py
--- a/pipenv/utils/funktools.py
+++ b/pipenv/utils/funktools.py
@@ -71,8 +71,7 @@ def unnest(elem: Iterable) -> Any:
         for el in target:
             if isinstance(el, Iterable) and not isinstance(el, str):
                 el, el_copy = tee(el, 2)
-                for sub in unnest(el_copy):
-                    yield sub
+                yield from unnest(el_copy)
             else:
                 yield el
 


Test patch: