Repository: pypa/pip

Issue:
Fish completion not working for files (.whl)
### Description

When installing from a local file, e.g. a wheel, auto-completion does not work in fish shell:

```cpp
$ ls *.whl
package.whl
$ pip install ./pack  # no completion
```

### Expected behavior

I expected `./pack` to be auto-completed to `./package.whl`

### pip version

21.3.1

### Python version

3.9.7

### OS

Ubuntu 20.04

### How to Reproduce

1. Create a `package.whl` file in the current folder (either a real one or a dumb one).
2. Start fish shell (current folder)
3. Start typing `pip install pack`


### Output

_No response_

### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).


Discussion:
Have you run the completion setup documented here: https://pip.pypa.io/en/stable/user_guide/#command-completion
I just did but now I get:

```
complete: Unknown option “-m”                                                                                                           643ms  Tue 09 Nov 2021 03:59:51 PM CET

~/.config/fish/completions/pip.fish (line 11): 
complete -fa "(__fish_complete_pip)" -c /usr/bin/python3 -m pip
^
from sourcing file ~/.config/fish/completions/pip.fish
in command substitution

(Type 'help complete' for related documentation)
```

Doing the version with `eval` seems to work if I use `pip3` instead of `python3 -m pip` but then I get completion for parameters but the problem with files is still there.
It looks like this is expected behavior: https://github.com/pypa/pip/blob/3fd3a976c39421a098f9ff3699c5b56e9ea29e55/tests/functional/test_completion.py#L235-L256

I think this is wrong though, it should offer to complete wheel and sdist files...
Feel free to propose a pull request for this.

Resolving patch:
diff --git a/src/pip/_internal/cli/autocompletion.py b/src/pip/_internal/cli/autocompletion.py
--- a/src/pip/_internal/cli/autocompletion.py
+++ b/src/pip/_internal/cli/autocompletion.py
@@ -59,6 +59,14 @@ def autocomplete() -> None:
                     print(dist)
                 sys.exit(1)
 
+        should_list_installables = (
+            not current.startswith("-") and subcommand_name == "install"
+        )
+        if should_list_installables:
+            for path in auto_complete_paths(current, "path"):
+                print(path)
+            sys.exit(1)
+
         subcommand = create_command(subcommand_name)
 
         for opt in subcommand.parser.option_list_all:
@@ -138,7 +146,7 @@ def auto_complete_paths(current: str, completion_type: str) -> Iterable[str]:
     starting with ``current``.
 
     :param current: The word to be completed
-    :param completion_type: path completion type(`file`, `path` or `dir`)i
+    :param completion_type: path completion type(``file``, ``path`` or ``dir``)
     :return: A generator of regular files and/or directories
     """
     directory, filename = os.path.split(current)


Test patch:
diff --git a/tests/functional/test_completion.py b/tests/functional/test_completion.py
--- a/tests/functional/test_completion.py
+++ b/tests/functional/test_completion.py
@@ -237,10 +237,10 @@ def test_completion_not_files_after_option(
 ) -> None:
     """
     Test not getting completion files after options which not applicable
-    (e.g. ``pip install``)
+    (e.g. ``pip wheel``)
     """
     res, env = autocomplete(
-        words=("pip install r"),
+        words=("pip wheel r"),
         cword="2",
         cwd=data.completion_paths,
     )
@@ -256,6 +256,24 @@ def test_completion_not_files_after_option(
     ), "autocomplete function completed <dir> when it should not complete"
 
 
+def test_pip_install_complete_files(
+    autocomplete: DoAutocomplete, data: TestData
+) -> None:
+    """``pip install`` autocompletes wheel and sdist files."""
+    res, env = autocomplete(
+        words=("pip install r"),
+        cword="2",
+        cwd=data.completion_paths,
+    )
+    assert all(
+        out in res.stdout
+        for out in (
+            "requirements.txt",
+            "resources",
+        )
+    ), "autocomplete function could not complete <path>"
+
+
 @pytest.mark.parametrize("cl_opts", ["-U", "--user", "-h"])
 def test_completion_not_files_after_nonexpecting_option(
     autocomplete: DoAutocomplete, data: TestData, cl_opts: str