Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc fixes #9699

Merged
merged 5 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/poetry/installation/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _prepare(
) -> Path:
from subprocess import CalledProcessError

distribution: DistributionType = "editable" if editable else "wheel" # type: ignore[assignment]
distribution: DistributionType = "editable" if editable else "wheel"
error: Exception | None = None

try:
Expand Down
4 changes: 2 additions & 2 deletions src/poetry/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def validate_object(obj: dict[str, Any]) -> list[str]:
(CORE_SCHEMA_DIR / "poetry-schema.json").read_text(encoding="utf-8")
)

properties = {*schema["properties"].keys(), *core_schema["properties"].keys()}
additional_properties = set(obj.keys()) - properties
properties = schema["properties"].keys() | core_schema["properties"].keys()
additional_properties = obj.keys() - properties
for key in additional_properties:
errors.append(f"Additional properties are not allowed ('{key}' was unexpected)")

Expand Down
16 changes: 6 additions & 10 deletions src/poetry/utils/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def certs(self, config: Config) -> RepositoryCertificateConfig:
return RepositoryCertificateConfig.create(self.name, config)

def get_http_credentials(
self, password_manager: PasswordManager, username: str | None = None
self, password_manager: PasswordManager
) -> HTTPAuthCredential:
# try with the repository name via the password manager
credential = HTTPAuthCredential(
Expand Down Expand Up @@ -268,15 +268,15 @@ def post(self, url: str, **kwargs: Any) -> requests.Response:
return self.request("post", url, **kwargs)

def _get_credentials_for_repository(
self, repository: AuthenticatorRepositoryConfig, username: str | None = None
self, repository: AuthenticatorRepositoryConfig
) -> HTTPAuthCredential:
# cache repository credentials by repository url to avoid multiple keyring
# backend queries when packages are being downloaded from the same source
key = f"{repository.url}#username={username or ''}"
key = repository.url

if key not in self._credentials:
self._credentials[key] = repository.get_http_credentials(
password_manager=self._password_manager, username=username
password_manager=self._password_manager
)

return self._credentials[key]
Expand Down Expand Up @@ -346,9 +346,7 @@ def get_credentials_for_url(self, url: str) -> HTTPAuthCredential:
def get_pypi_token(self, name: str) -> str | None:
return self._password_manager.get_pypi_token(name)

def get_http_auth(
self, name: str, username: str | None = None
) -> HTTPAuthCredential | None:
def get_http_auth(self, name: str) -> HTTPAuthCredential | None:
if name == "pypi":
repository = AuthenticatorRepositoryConfig(
name, "https://upload.pypi.org/legacy/"
Expand All @@ -358,9 +356,7 @@ def get_http_auth(
return None
repository = self.configured_repositories[name]

return self._get_credentials_for_repository(
repository=repository, username=username
)
return self._get_credentials_for_repository(repository=repository)

def get_certs_for_repository(self, name: str) -> RepositoryCertificateConfig:
if name.lower() == "pypi" or name not in self.configured_repositories:
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def get_credential(
if password is None:
return None

return SimpleCredential(username, password) # type: ignore[no-untyped-call]
return SimpleCredential(username, password)

def delete_password(self, service: str, username: str) -> None:
if service in self._passwords and username in self._passwords[service]:
Expand Down
14 changes: 0 additions & 14 deletions tests/installation/fixtures/with-conditional-dependency.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@ optional = false
python-versions = ">=3.5"
files = []

[package.requirements]
python = ">=3.5,<4.0"

[[package]]
name = "A"
version = "1.0.1"
description = ""
optional = false
python-versions = ">=3.6"
files = []

[package.requirements]
python = ">=3.6,<4.0"

[metadata]
python-versions = "~2.7 || ^3.4"
lock-version = "2.0"
Expand Down
3 changes: 0 additions & 3 deletions tests/installation/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1791,9 +1791,6 @@ def test_run_install_duplicate_dependencies_different_constraints_with_lock_upda
assert installer.executor.removals_count == 0


@pytest.mark.skip(
"This is not working at the moment due to limitations in the resolver"
)
def test_installer_test_solver_finds_compatible_package_for_dependency_python_not_fully_compatible_with_package_python(
installer: Installer,
locker: Locker,
Expand Down
14 changes: 0 additions & 14 deletions tests/puzzle/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3811,20 +3811,6 @@ def test_solver_synchronize_single(
)


@pytest.mark.skip(reason="Poetry no longer has critical package requirements")
def test_solver_with_synchronization_keeps_critical_package(
package: ProjectPackage,
pool: RepositoryPool,
io: NullIO,
) -> None:
package_pip = get_package("setuptools", "1.0")

solver = Solver(package, pool, [package_pip], [], io)
transaction = solver.solve()

check_solver_result(transaction, [])


def test_solver_cannot_choose_another_version_for_directory_dependencies(
solver: Solver,
repo: Repository,
Expand Down
8 changes: 4 additions & 4 deletions tests/utils/test_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def test_authenticator_falls_back_to_keyring_url(

dummy_keyring.set_default_service_credential(
"https://foo.bar/simple/",
SimpleCredential("foo", "bar"), # type: ignore[no-untyped-call]
SimpleCredential("foo", "bar"),
)

authenticator = Authenticator(config, NullIO())
Expand All @@ -217,7 +217,7 @@ def test_authenticator_falls_back_to_keyring_netloc(

dummy_keyring.set_default_service_credential(
"foo.bar",
SimpleCredential("foo", "bar"), # type: ignore[no-untyped-call]
SimpleCredential("foo", "bar"),
)

authenticator = Authenticator(config, NullIO())
Expand Down Expand Up @@ -483,11 +483,11 @@ def test_authenticator_falls_back_to_keyring_url_matched_by_path(

dummy_keyring.set_default_service_credential(
"https://foo.bar/alpha/files/simple/",
SimpleCredential("foo", "bar"), # type: ignore[no-untyped-call]
SimpleCredential("foo", "bar"),
)
dummy_keyring.set_default_service_credential(
"https://foo.bar/beta/files/simple/",
SimpleCredential("foo", "baz"), # type: ignore[no-untyped-call]
SimpleCredential("foo", "baz"),
)

authenticator = Authenticator(config, NullIO())
Expand Down
Loading