Skip to content

Commit

Permalink
Misc tidying (#7673)
Browse files Browse the repository at this point in the history
* correct logger for publisher
* build 0.10.0 to get metadata in PackageInfo
* prefer pathlib
* passwords must be strings
  • Loading branch information
dimbleby authored Mar 31, 2023
1 parent 7687539 commit b933443
Show file tree
Hide file tree
Showing 20 changed files with 246 additions and 243 deletions.
1 change: 1 addition & 0 deletions src/poetry/console/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def handle(self) -> int:
username = values[0]
# Only username, so we prompt for password
password = self.secret("Password:")
assert isinstance(password, str)
elif len(values) != 2:
raise ValueError(
"Expected one or two arguments "
Expand Down
2 changes: 1 addition & 1 deletion src/poetry/console/commands/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PublishCommand(Command):
the config command.
"""

loggers = ["poetry.masonry.publishing.publisher"]
loggers = ["poetry.publishing.publisher"]

def handle(self) -> int:
from poetry.publishing.publisher import Publisher
Expand Down
8 changes: 4 additions & 4 deletions src/poetry/inspection/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
builder.metadata_path(dest)
"""

PEP517_META_BUILD_DEPS = ["build==0.9.0", "pyproject_hooks==1.0.0"]
PEP517_META_BUILD_DEPS = ["build==0.10.0", "pyproject_hooks==1.0.0"]


class PackageInfoError(ValueError):
def __init__(self, path: Path | str, *reasons: BaseException | str) -> None:
def __init__(self, path: Path, *reasons: BaseException | str) -> None:
reasons = (f"Unable to determine package info for path: {path!s}",) + reasons
super().__init__("\n\n".join(str(msg).strip() for msg in reasons if msg))

Expand Down Expand Up @@ -617,7 +617,7 @@ def get_pep517_metadata(path: Path) -> PackageInfo:
)

cwd = Path.cwd()
os.chdir(path.as_posix())
os.chdir(path)
try:
venv.run("python", "setup.py", "egg_info")
info = PackageInfo.from_metadata(path)
Expand All @@ -626,7 +626,7 @@ def get_pep517_metadata(path: Path) -> PackageInfo:
path, "Fallback egg_info generation failed.", fbe
)
finally:
os.chdir(cwd.as_posix())
os.chdir(cwd)

if info:
logger.debug("Falling back to parsed setup.py file for %s", path)
Expand Down
2 changes: 1 addition & 1 deletion src/poetry/installation/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ def _install_directory_without_wheel_installer(
if package.source_subdirectory:
req /= package.source_subdirectory

pyproject = PyProjectTOML(os.path.join(req, "pyproject.toml"))
pyproject = PyProjectTOML(req / "pyproject.toml")

package_poetry = None
if pyproject.is_poetry_project():
Expand Down
2 changes: 1 addition & 1 deletion src/poetry/installation/pip_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def install_directory(self, package: Package) -> str | int:
if package.source_subdirectory:
req /= package.source_subdirectory

pyproject = PyProjectTOML(os.path.join(req, "pyproject.toml"))
pyproject = PyProjectTOML(req / "pyproject.toml")

package_poetry = None
if pyproject.is_poetry_project():
Expand Down
6 changes: 3 additions & 3 deletions src/poetry/installation/wheel_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class WheelDestination(SchemeDictionaryDestination):
def write_to_fs(
self,
scheme: Scheme,
path: Path | str,
path: str,
stream: BinaryIO,
is_executable: bool,
) -> RecordEntry:
Expand All @@ -58,7 +58,7 @@ def write_to_fs(
if is_executable:
make_file_executable(target_path)

return RecordEntry(str(path), Hash(self.hash_algorithm, hash_), size)
return RecordEntry(path, Hash(self.hash_algorithm, hash_), size)

def for_source(self, source: WheelFile) -> WheelDestination:
scheme_dict = self.scheme_dict.copy()
Expand Down Expand Up @@ -90,7 +90,7 @@ def __init__(self, env: Env) -> None:
schemes["headers"] = schemes["include"]

self._destination = WheelDestination(
schemes, interpreter=self._env.python, script_kind=script_kind
schemes, interpreter=str(self._env.python), script_kind=script_kind
)

def enable_bytecode_compilation(self, enable: bool = True) -> None:
Expand Down
4 changes: 2 additions & 2 deletions src/poetry/packages/locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class Locker:
_legacy_keys = ["dependencies", "source", "extras", "dev-dependencies"]
_relevant_keys = [*_legacy_keys, "group"]

def __init__(self, lock: str | Path, local_config: dict[str, Any]) -> None:
self._lock = lock if isinstance(lock, Path) else Path(lock)
def __init__(self, lock: Path, local_config: dict[str, Any]) -> None:
self._lock = lock
self._local_config = local_config
self._lock_data: dict[str, Any] | None = None
self._content_hash = self._get_content_hash()
Expand Down
5 changes: 2 additions & 3 deletions src/poetry/utils/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,8 @@ def _get_cached_archives_for_link(self, link: Link) -> list[Path]:
cache_dir = self.get_cache_directory_for_link(link)

archive_types = ["whl", "tar.gz", "tar.bz2", "bz2", "zip"]
paths = []
paths: list[Path] = []
for archive_type in archive_types:
for archive in cache_dir.glob(f"*.{archive_type}"):
paths.append(Path(archive))
paths += cache_dir.glob(f"*.{archive_type}")

return paths
Loading

0 comments on commit b933443

Please sign in to comment.