Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0b45393

Browse files
committedOct 3, 2024··
Improve fixes for ruff/flake8-simplify rule SIM103
1 parent ae41609 commit 0b45393

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed
 

‎docs/pip_sphinxext.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ def _is_version_section_title_underline(
3737
self, prev: Optional[str], curr: str
3838
) -> bool:
3939
"""Find a ==== line that marks the version section title."""
40-
if prev is None:
41-
return False
42-
if re.match(r"^=+$", curr) is None:
43-
return False
44-
return not len(curr) < len(prev)
40+
return (
41+
prev is not None
42+
and re.match(r"^=+$", curr) is not None
43+
and len(curr) >= len(prev)
44+
)
4545

4646
def _iter_lines_with_refs(self, lines: Iterable[str]) -> Iterator[str]:
4747
"""Transform the input lines to add a ref before each section title.

‎src/pip/_internal/req/constructors.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,11 @@ def _looks_like_path(name: str) -> bool:
261261
* a path separator is found (either os.path.sep or os.path.altsep);
262262
* a dot is found (which represents the current directory).
263263
"""
264-
if os.path.sep in name:
265-
return True
266-
if os.path.altsep is not None and os.path.altsep in name:
267-
return True
268-
return name.startswith(".")
264+
return (
265+
os.path.sep in name
266+
or (os.path.altsep is not None and os.path.altsep in name)
267+
or name.startswith(".")
268+
)
269269

270270

271271
def _get_url_from_path(path: str, name: str) -> Optional[str]:

‎src/pip/_internal/utils/misc.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,10 @@ def is_installable_dir(path: str) -> bool:
303303
setup.cfg because using it without setup.py is only available for PEP 517
304304
projects, which are already covered by the pyproject.toml check.
305305
"""
306-
if not os.path.isdir(path):
307-
return False
308-
if os.path.isfile(os.path.join(path, "pyproject.toml")):
309-
return True
310-
return os.path.isfile(os.path.join(path, "setup.py"))
306+
return os.path.isdir(path) and (
307+
os.path.isfile(os.path.join(path, "pyproject.toml"))
308+
or os.path.isfile(os.path.join(path, "setup.py"))
309+
)
311310

312311

313312
def read_chunks(

‎src/pip/_internal/vcs/git.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,11 @@ def _should_fetch(cls, dest: str, rev: str) -> bool:
192192
# Git fetch would fail with abbreviated commits.
193193
return False
194194

195-
# Don't fetch if we have the commit locally.
196-
return not cls.has_commit(dest, rev)
195+
if cls.has_commit(dest, rev):
196+
# Don't fetch if we have the commit locally.
197+
return False
198+
199+
return True
197200

198201
@classmethod
199202
def resolve_revision(

0 commit comments

Comments
 (0)
Please sign in to comment.