From 014ccec8caecefdb45bd1829104d69c74ec8b1a2 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Fri, 1 Jan 2021 09:48:05 -0800 Subject: [PATCH] Make get_similar_command() return None for no value Follows the more conventional pattern of using None, instead of False, when no value can be returned. This simplifies typing a bit by using Optional instead of Union[bool, ...]. --- .../2b5d1433-ec03-4b33-8cf1-ff76baa3690e.trivial.rst | 0 src/pip/_internal/commands/__init__.py | 12 +++--------- 2 files changed, 3 insertions(+), 9 deletions(-) create mode 100644 news/2b5d1433-ec03-4b33-8cf1-ff76baa3690e.trivial.rst diff --git a/news/2b5d1433-ec03-4b33-8cf1-ff76baa3690e.trivial.rst b/news/2b5d1433-ec03-4b33-8cf1-ff76baa3690e.trivial.rst new file mode 100644 index 000000000..e69de29bb diff --git a/src/pip/_internal/commands/__init__.py b/src/pip/_internal/commands/__init__.py index f0554b655..f2411201c 100644 --- a/src/pip/_internal/commands/__init__.py +++ b/src/pip/_internal/commands/__init__.py @@ -2,20 +2,13 @@ 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 from collections import OrderedDict, namedtuple from pip._internal.utils.typing import MYPY_CHECK_RUNNING if MYPY_CHECK_RUNNING: - from typing import Any + from typing import Any, Optional from pip._internal.cli.base_command import Command @@ -108,6 +101,7 @@ def create_command(name, **kwargs): def get_similar_commands(name): + # type: (str) -> Optional[str] """Command name auto-correct.""" from difflib import get_close_matches @@ -118,4 +112,4 @@ def get_similar_commands(name): if close_commands: return close_commands[0] else: - return False + return None