diff --git a/docs/pip_sphinxext.py b/docs/pip_sphinxext.py index 8448cbeab58..4b175d55739 100644 --- a/docs/pip_sphinxext.py +++ b/docs/pip_sphinxext.py @@ -37,11 +37,11 @@ def _is_version_section_title_underline( self, prev: Optional[str], curr: str ) -> bool: """Find a ==== line that marks the version section title.""" - if prev is None: - return False - if re.match(r"^=+$", curr) is None: - return False - return not len(curr) < len(prev) + return ( + prev is not None + and re.match(r"^=+$", curr) is not None + and len(curr) >= len(prev) + ) def _iter_lines_with_refs(self, lines: Iterable[str]) -> Iterator[str]: """Transform the input lines to add a ref before each section title. diff --git a/src/pip/_internal/req/constructors.py b/src/pip/_internal/req/constructors.py index 5293c4ba99c..6f1cc911adf 100644 --- a/src/pip/_internal/req/constructors.py +++ b/src/pip/_internal/req/constructors.py @@ -261,11 +261,11 @@ def _looks_like_path(name: str) -> bool: * a path separator is found (either os.path.sep or os.path.altsep); * a dot is found (which represents the current directory). """ - if os.path.sep in name: - return True - if os.path.altsep is not None and os.path.altsep in name: - return True - return name.startswith(".") + return ( + os.path.sep in name + or (os.path.altsep is not None and os.path.altsep in name) + or name.startswith(".") + ) def _get_url_from_path(path: str, name: str) -> Optional[str]: diff --git a/src/pip/_internal/utils/misc.py b/src/pip/_internal/utils/misc.py index 07d43ce74f1..3069432a773 100644 --- a/src/pip/_internal/utils/misc.py +++ b/src/pip/_internal/utils/misc.py @@ -303,11 +303,10 @@ def is_installable_dir(path: str) -> bool: setup.cfg because using it without setup.py is only available for PEP 517 projects, which are already covered by the pyproject.toml check. """ - if not os.path.isdir(path): - return False - if os.path.isfile(os.path.join(path, "pyproject.toml")): - return True - return os.path.isfile(os.path.join(path, "setup.py")) + return os.path.isdir(path) and ( + os.path.isfile(os.path.join(path, "pyproject.toml")) + or os.path.isfile(os.path.join(path, "setup.py")) + ) def read_chunks( diff --git a/src/pip/_internal/vcs/git.py b/src/pip/_internal/vcs/git.py index 4e08be5fd90..0425debb3ae 100644 --- a/src/pip/_internal/vcs/git.py +++ b/src/pip/_internal/vcs/git.py @@ -192,8 +192,11 @@ def _should_fetch(cls, dest: str, rev: str) -> bool: # Git fetch would fail with abbreviated commits. return False - # Don't fetch if we have the commit locally. - return not cls.has_commit(dest, rev) + if cls.has_commit(dest, rev): + # Don't fetch if we have the commit locally. + return False + + return True @classmethod def resolve_revision(