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

PEP610: handle optional vcs_info.requested_version #5274

Merged
merged 2 commits into from
Mar 5, 2022
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
4 changes: 3 additions & 1 deletion src/poetry/repositories/installed_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@ def create_package_from_pep610(cls, distribution: metadata.Distribution) -> Pack
# VCS distribution
source_type = url_reference["vcs_info"]["vcs"]
source_url = url_reference["url"]
source_reference = url_reference["vcs_info"]["requested_revision"]
source_resolved_reference = url_reference["vcs_info"]["commit_id"]
source_reference = url_reference["vcs_info"].get(
"requested_revision", source_resolved_reference
)
abn marked this conversation as resolved.
Show resolved Hide resolved

package = Package(
distribution.metadata["name"],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Metadata-Version: 2.1
Name: git-pep-610-no-requested-version
Version: 1.2.3
Summary: Foo
License: MIT
Requires-Python: >=3.6
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"url": "https://github.com/demo/git-pep-610-no-requested-version.git",
"vcs_info": {
"vcs": "git",
"commit_id": "123456"
}
}
22 changes: 22 additions & 0 deletions tests/repositories/test_installed_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
metadata.PathDistribution(SITE_PLATLIB / "lib64-2.3.4.dist-info"),
metadata.PathDistribution(SITE_PLATLIB / "bender-2.0.5.dist-info"),
metadata.PathDistribution(SITE_PURELIB / "git_pep_610-1.2.3.dist-info"),
metadata.PathDistribution(
SITE_PURELIB / "git_pep_610_no_requested_version-1.2.3.dist-info"
),
metadata.PathDistribution(SITE_PURELIB / "url_pep_610-1.2.3.dist-info"),
metadata.PathDistribution(SITE_PURELIB / "file_pep_610-1.2.3.dist-info"),
metadata.PathDistribution(SITE_PURELIB / "directory_pep_610-1.2.3.dist-info"),
Expand Down Expand Up @@ -189,6 +192,25 @@ def test_load_pep_610_compliant_git_packages(repository: InstalledRepository):
assert package.source_resolved_reference == "123456"


def test_load_pep_610_compliant_git_packages_no_requested_version(
repository: InstalledRepository,
):
package = get_package_from_repository(
"git-pep-610-no-requested-version", repository
)

assert package is not None
assert package.name == "git-pep-610-no-requested-version"
assert package.version.text == "1.2.3"
assert package.source_type == "git"
assert (
package.source_url
== "https://github.com/demo/git-pep-610-no-requested-version.git"
)
assert package.source_resolved_reference == "123456"
assert package.source_reference == package.source_resolved_reference


def test_load_pep_610_compliant_url_packages(repository: InstalledRepository):
package = get_package_from_repository("url-pep-610", repository)

Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ def test_create_venv_uses_patch_version_to_detect_compatibility_with_executable(


def test_create_venv_fails_if_current_python_version_is_not_supported(
manager: EnvManager, poetry: "Poetry"
manager: EnvManager, poetry: Poetry
):
if "VIRTUAL_ENV" in os.environ:
del os.environ["VIRTUAL_ENV"]
Expand Down