Skip to content

Commit

Permalink
Make version required
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnan-chandra committed May 11, 2024
1 parent a1124da commit 5938ff1
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/python/pants/backend/python/subsystems/python_tool_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from __future__ import annotations
from functools import cache

import importlib.resources
import json
import logging
import os
from dataclasses import dataclass
from typing import ClassVar, Iterable, Optional, Sequence
from functools import cache
from typing import ClassVar, Iterable, Sequence
from urllib.parse import urlparse

from pants.backend.python.target_types import ConsoleScript, EntryPoint, MainSpecification
Expand Down Expand Up @@ -70,8 +70,6 @@ def _install_from_resolve_help(cls) -> str:
package_and_version = cls._default_package_name_and_version()
version_clause = (
f", which uses {package_and_version.name} version {package_and_version.version}"
if package_and_version is not None
else ""
)
return softwrap(
f"""\
Expand Down Expand Up @@ -218,15 +216,12 @@ def _default_package_name_and_version(cls) -> _PackageNameAndVersion:
# this will pick up the wrong requirement.
first_default_requirement = PipRequirement.parse(cls.default_requirements[0])
return next(
(
_PackageNameAndVersion(
name=first_default_requirement.project_name, version=requirement["version"]
)
for resolve in lockfile_contents["locked_resolves"]
for requirement in resolve["locked_requirements"]
if requirement["project_name"] == first_default_requirement.project_name
),
None,
_PackageNameAndVersion(
name=first_default_requirement.project_name, version=requirement["version"]
)
for resolve in lockfile_contents["locked_resolves"]
for requirement in resolve["locked_requirements"]
if requirement["project_name"] == first_default_requirement.project_name
)

@classproperty
Expand All @@ -238,7 +233,6 @@ def help_extended(cls) -> str:
all_paragraphs = [base_help]

package_name_and_version = cls._default_package_name_and_version()
assert package_name_and_version is not None
all_paragraphs.append(
f"This version of Pants uses {package_name_and_version.name} {package_name_and_version.version} by default. "
+ "Use a dedicated lockfile and the `install_from_resolve` option to control this."
Expand Down

0 comments on commit 5938ff1

Please sign in to comment.