mirror of https://github.com/pypa/pip
Merge pull request #9410 from jdufresne/get-similar-commands
Make get_similar_command() return None for no value
This commit is contained in:
commit
47493d8227
|
@ -2,20 +2,13 @@
|
||||||
Package containing all pip commands
|
Package containing all pip commands
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# The following comment should be removed at some point in the future.
|
|
||||||
# mypy: disallow-untyped-defs=False
|
|
||||||
# There is currently a bug in python/typeshed mentioned at
|
|
||||||
# https://github.com/python/typeshed/issues/3906 which causes the
|
|
||||||
# return type of difflib.get_close_matches to be reported
|
|
||||||
# as List[Sequence[str]] whereas it should have been List[str]
|
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
from collections import OrderedDict, namedtuple
|
from collections import OrderedDict, namedtuple
|
||||||
|
|
||||||
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
|
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
|
||||||
|
|
||||||
if MYPY_CHECK_RUNNING:
|
if MYPY_CHECK_RUNNING:
|
||||||
from typing import Any
|
from typing import Any, Optional
|
||||||
|
|
||||||
from pip._internal.cli.base_command import Command
|
from pip._internal.cli.base_command import Command
|
||||||
|
|
||||||
|
@ -108,6 +101,7 @@ def create_command(name, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def get_similar_commands(name):
|
def get_similar_commands(name):
|
||||||
|
# type: (str) -> Optional[str]
|
||||||
"""Command name auto-correct."""
|
"""Command name auto-correct."""
|
||||||
from difflib import get_close_matches
|
from difflib import get_close_matches
|
||||||
|
|
||||||
|
@ -118,4 +112,4 @@ def get_similar_commands(name):
|
||||||
if close_commands:
|
if close_commands:
|
||||||
return close_commands[0]
|
return close_commands[0]
|
||||||
else:
|
else:
|
||||||
return False
|
return None
|
||||||
|
|
Loading…
Reference in New Issue