Refactor: use division operator to join paths (#11413)

Starting with `resolve_package_path` and its associated tests,
this refactoring seeks to make path concatenation more
readable and consistent within tests/functions.

As discussed in #11413:

- code is free to use either `/` and `joinpath`
- consistency within a function is more important than consistency across the codebase
- it is nice to use `/` when it is more readable
- it is nice to use `joinpath` when there is little context
- be mindful that `joinpath` may be clearer when joining multiple segments
This commit is contained in:
Warren Markham
2023-09-09 22:16:22 +10:00
committed by GitHub
parent 7259e8db98
commit 71f265f1f3
2 changed files with 5 additions and 5 deletions

View File

@@ -680,7 +680,7 @@ def resolve_package_path(path: Path) -> Optional[Path]:
result = None
for parent in itertools.chain((path,), path.parents):
if parent.is_dir():
if not parent.joinpath("__init__.py").is_file():
if not (parent / "__init__.py").is_file():
break
if not parent.name.isidentifier():
break