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

follow through on deprecations #702

Merged
merged 1 commit into from
Feb 25, 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
11 changes: 0 additions & 11 deletions src/poetry/core/constraints/generic/constraint.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import operator
import warnings

from typing import Any
from typing import Callable
Expand Down Expand Up @@ -39,16 +38,6 @@ def __init__(self, value: str, operator: str = "==") -> None:
def value(self) -> str:
return self._value

@property
def version(self) -> str:
warnings.warn(
"The property 'version' is deprecated and will be removed. "
"Please use the property 'value' instead.",
DeprecationWarning,
stacklevel=2,
)
return self.value

@property
def operator(self) -> str:
return self._operator
Expand Down
14 changes: 1 addition & 13 deletions src/poetry/core/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from typing import Dict
from typing import List
from typing import Union
from warnings import warn

from packaging.utils import canonicalize_name

Expand Down Expand Up @@ -265,18 +264,7 @@ def create_dependency(
python_versions = constraint.get("python")
platform = constraint.get("platform")
markers = constraint.get("markers")
if "allows-prereleases" in constraint:
message = (
f'The "{name}" dependency specifies '
'the "allows-prereleases" property, which is deprecated. '
'Use "allow-prereleases" instead.'
)
warn(message, DeprecationWarning, stacklevel=2)
logger.warning(message)

allows_prereleases = constraint.get(
"allow-prereleases", constraint.get("allows-prereleases", False)
)
allows_prereleases = constraint.get("allow-prereleases", False)

dependency: Dependency
if "git" in constraint:
Expand Down
12 changes: 0 additions & 12 deletions src/poetry/core/masonry/builders/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,6 @@ def convert_entry_points(self) -> dict[str, list[str]]:
# TODO: deprecate this in favour or reference
specification = {"reference": specification, "type": "console"}

if "callable" in specification:
warnings.warn(
f"Use of callable in script specification ({name}) is"
" deprecated. Use reference instead.",
DeprecationWarning,
stacklevel=1,
)
specification = {
"reference": specification["callable"],
"type": "console",
}

if specification.get("type") != "console":
continue

Expand Down
32 changes: 0 additions & 32 deletions src/poetry/core/masonry/utils/helpers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from __future__ import annotations

import re
import warnings

from typing import TYPE_CHECKING
from typing import NewType
from typing import cast
Expand Down Expand Up @@ -31,35 +28,6 @@ def normalize_file_permissions(st_mode: int) -> int:
return new_mode


def escape_version(version: str) -> str:
"""
Escaped version in wheel filename. Doesn't exactly follow
the escaping specification in :pep:`427#escaping-and-unicode`
because this conflicts with :pep:`440#local-version-identifiers`.
"""
warnings.warn(
"escape_version() is deprecated. Use Version.parse().to_string() instead.",
DeprecationWarning,
stacklevel=2,
)
return re.sub(r"[^\w\d.+]+", "_", version, flags=re.UNICODE)


def escape_name(name: str) -> str:
"""
Escaped wheel name as specified in https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode.
This function should only be used for the generation of artifact names,
and not to normalize or filter existing artifact names.
"""
warnings.warn(
"escape_name() is deprecated. Use packaging.utils.canonicalize_name() and"
" distribution_name() instead.",
DeprecationWarning,
stacklevel=2,
)
return re.sub(r"[-_.]+", "_", name, flags=re.UNICODE).lower()


def distribution_name(name: NormalizedName) -> DistributionName:
"""
A normalized name, but with "-" replaced by "_". This is used in various places:
Expand Down
9 changes: 0 additions & 9 deletions src/poetry/core/packages/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,6 @@ def constraint(self, constraint: str | VersionConstraint) -> None:

self._pretty_constraint = str(constraint)

def set_constraint(self, constraint: str | VersionConstraint) -> None:
warnings.warn(
"Calling method 'set_constraint' is deprecated and will be removed. "
"It has been replaced by the property 'constraint' for consistency.",
DeprecationWarning,
stacklevel=2,
)
self.constraint = constraint # type: ignore[assignment]

@property
def pretty_constraint(self) -> str:
return self._pretty_constraint
Expand Down
17 changes: 0 additions & 17 deletions src/poetry/core/packages/file_dependency.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from __future__ import annotations

import hashlib
import io
import warnings

from typing import TYPE_CHECKING

from poetry.core.packages.path_dependency import PathDependency
Expand Down Expand Up @@ -63,16 +59,3 @@ def _validate(self) -> str:
" expected a file"
)
return ""

def hash(self, hash_name: str = "sha256") -> str:
warnings.warn(
"hash() is deprecated. Use poetry.utils.helpers.get_file_hash() instead.",
DeprecationWarning,
stacklevel=2,
)
h = hashlib.new(hash_name)
with self._full_path.open("rb") as fp:
for content in iter(lambda: fp.read(io.DEFAULT_BUFFER_SIZE), b""):
h.update(content)

return h.hexdigest()
20 changes: 0 additions & 20 deletions src/poetry/core/packages/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,26 +391,6 @@ def category(self, category: str) -> None:
)
self._category = category

@property
def readme(self) -> Path | None:
warnings.warn(
"`readme` is deprecated: you are getting only the first readme file."
" Please use the plural form `readmes`.",
DeprecationWarning,
stacklevel=2,
)
return next(iter(self.readmes), None)

@readme.setter
def readme(self, path: Path) -> None:
warnings.warn(
"`readme` is deprecated. Please assign a tuple to the plural form"
" `readmes`.",
DeprecationWarning,
stacklevel=2,
)
self.readmes = (path,)

@property
def yanked(self) -> bool:
return isinstance(self._yanked, str) or bool(self._yanked)
Expand Down
12 changes: 0 additions & 12 deletions src/poetry/core/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import tempfile
import time
import unicodedata
import warnings

from contextlib import contextmanager
from pathlib import Path
Expand All @@ -16,8 +15,6 @@

from packaging.utils import canonicalize_name

from poetry.core.version.pep440 import PEP440Version


if TYPE_CHECKING:
from collections.abc import Iterator
Expand All @@ -31,15 +28,6 @@ def module_name(name: str) -> str:
return canonicalize_name(name).replace("-", "_")


def normalize_version(version: str) -> str:
warnings.warn(
"normalize_version() is deprecated. Use Version.parse().to_string() instead.",
DeprecationWarning,
stacklevel=2,
)
return PEP440Version.parse(version).to_string()


@contextmanager
def temporary_directory(*args: Any, **kwargs: Any) -> Iterator[str]:
if sys.version_info >= (3, 10):
Expand Down
12 changes: 1 addition & 11 deletions src/poetry/core/version/pep440/segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,7 @@ def __post_init__(self) -> None:
self, "phase", RELEASE_PHASE_NORMALIZATIONS.get(self.phase, self.phase)
)

def to_string(self, short: bool = False) -> str:
if short:
import warnings

warnings.warn(
"Parameter 'short' has no effect and will be removed. "
"(Release tags are always normalized according to PEP 440 now.)",
DeprecationWarning,
stacklevel=2,
)

def to_string(self) -> str:
return f"{self.phase}{self.number}"

def next(self) -> ReleaseTag:
Expand Down
12 changes: 1 addition & 11 deletions src/poetry/core/version/pep440/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,7 @@ def non_semver_parts(self) -> Sequence[int]:
def parts(self) -> Sequence[int]:
return self.release.to_parts()

def to_string(self, short: bool = False) -> str:
if short:
import warnings

warnings.warn(
"Parameter 'short' has no effect and will be removed. "
"(Versions are always normalized according to PEP 440 now.)",
DeprecationWarning,
stacklevel=2,
)

def to_string(self) -> str:
version_string = self.release.to_string()

if self.epoch:
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

23 changes: 0 additions & 23 deletions tests/masonry/builders/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,31 +217,9 @@ def test_invalid_script_files_definition() -> None:
assert "scripts.invalid_definition" in str(err.value)


@pytest.mark.parametrize(
"fixture",
[
"script_callable_legacy_table",
],
)
def test_entrypoint_scripts_legacy_warns(fixture: str) -> None:
with pytest.warns(DeprecationWarning):
Builder(
Factory().create_poetry(Path(__file__).parent / "fixtures" / fixture)
).convert_entry_points()


@pytest.mark.parametrize(
"fixture, result",
[
(
"script_callable_legacy_table",
{
"console_scripts": [
"extra-script-legacy = my_package.extra_legacy:main",
"script-legacy = my_package.extra_legacy:main",
]
},
),
(
"script_callable_legacy_string",
{"console_scripts": ["script-legacy = my_package:main"]},
Expand All @@ -261,7 +239,6 @@ def test_entrypoint_scripts_legacy_warns(fixture: str) -> None:
),
],
)
@pytest.mark.filterwarnings("ignore:.* callable .* deprecated:DeprecationWarning")
@pytest.mark.filterwarnings("ignore:.* script .* extra:DeprecationWarning")
def test_builder_convert_entry_points(
fixture: str, result: dict[str, list[str]]
Expand Down
23 changes: 0 additions & 23 deletions tests/masonry/utils/test_helpers.py

This file was deleted.

Loading