diff --git a/src/poetry/core/constraints/generic/constraint.py b/src/poetry/core/constraints/generic/constraint.py index e45c1234a..7ec1d151e 100644 --- a/src/poetry/core/constraints/generic/constraint.py +++ b/src/poetry/core/constraints/generic/constraint.py @@ -1,7 +1,6 @@ from __future__ import annotations import operator -import warnings from typing import Any from typing import Callable @@ -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 diff --git a/src/poetry/core/factory.py b/src/poetry/core/factory.py index bcf81e76a..a0c84a85b 100644 --- a/src/poetry/core/factory.py +++ b/src/poetry/core/factory.py @@ -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 @@ -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: diff --git a/src/poetry/core/masonry/builders/builder.py b/src/poetry/core/masonry/builders/builder.py index 54847309b..dab3cc2da 100644 --- a/src/poetry/core/masonry/builders/builder.py +++ b/src/poetry/core/masonry/builders/builder.py @@ -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 diff --git a/src/poetry/core/masonry/utils/helpers.py b/src/poetry/core/masonry/utils/helpers.py index ac291f270..2532ed282 100644 --- a/src/poetry/core/masonry/utils/helpers.py +++ b/src/poetry/core/masonry/utils/helpers.py @@ -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 @@ -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: diff --git a/src/poetry/core/packages/dependency.py b/src/poetry/core/packages/dependency.py index de554449d..ef6185e65 100644 --- a/src/poetry/core/packages/dependency.py +++ b/src/poetry/core/packages/dependency.py @@ -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 diff --git a/src/poetry/core/packages/file_dependency.py b/src/poetry/core/packages/file_dependency.py index 9a6e39a5b..5b29ffcce 100644 --- a/src/poetry/core/packages/file_dependency.py +++ b/src/poetry/core/packages/file_dependency.py @@ -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 @@ -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() diff --git a/src/poetry/core/packages/package.py b/src/poetry/core/packages/package.py index a841c7d45..3342388e6 100644 --- a/src/poetry/core/packages/package.py +++ b/src/poetry/core/packages/package.py @@ -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) diff --git a/src/poetry/core/utils/helpers.py b/src/poetry/core/utils/helpers.py index 887bb2532..7306973f5 100644 --- a/src/poetry/core/utils/helpers.py +++ b/src/poetry/core/utils/helpers.py @@ -7,7 +7,6 @@ import tempfile import time import unicodedata -import warnings from contextlib import contextmanager from pathlib import Path @@ -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 @@ -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): diff --git a/src/poetry/core/version/pep440/segments.py b/src/poetry/core/version/pep440/segments.py index 792348826..e333c929e 100644 --- a/src/poetry/core/version/pep440/segments.py +++ b/src/poetry/core/version/pep440/segments.py @@ -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: diff --git a/src/poetry/core/version/pep440/version.py b/src/poetry/core/version/pep440/version.py index 7f9c86a13..cf4b9c670 100644 --- a/src/poetry/core/version/pep440/version.py +++ b/src/poetry/core/version/pep440/version.py @@ -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: diff --git a/tests/masonry/builders/fixtures/script_callable_legacy_table/README.rst b/tests/masonry/builders/fixtures/script_callable_legacy_table/README.rst deleted file mode 100644 index f7fe15470..000000000 --- a/tests/masonry/builders/fixtures/script_callable_legacy_table/README.rst +++ /dev/null @@ -1,2 +0,0 @@ -My Package -========== diff --git a/tests/masonry/builders/fixtures/script_callable_legacy_table/my_package/__init__.py b/tests/masonry/builders/fixtures/script_callable_legacy_table/my_package/__init__.py deleted file mode 100644 index 10aa336ce..000000000 --- a/tests/masonry/builders/fixtures/script_callable_legacy_table/my_package/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "1.2.3" diff --git a/tests/masonry/builders/fixtures/script_callable_legacy_table/pyproject.toml b/tests/masonry/builders/fixtures/script_callable_legacy_table/pyproject.toml deleted file mode 100644 index cab2488f5..000000000 --- a/tests/masonry/builders/fixtures/script_callable_legacy_table/pyproject.toml +++ /dev/null @@ -1,21 +0,0 @@ -[tool.poetry] -name = "my-package" -version = "1.2.3" -description = "Some description." -authors = [ - "Poetry Maintainers " -] -license = "MIT" -readme = "README.rst" - -[tool.poetry.dependencies] -python = "^3.6" - -[tool.poetry.dev-dependencies] - -[tool.poetry.extras] -time = [] - -[tool.poetry.scripts] -script-legacy = { callable = "my_package.extra_legacy:main" } -extra-script-legacy = { callable = "my_package.extra_legacy:main", extras = ["time"] } diff --git a/tests/masonry/builders/test_builder.py b/tests/masonry/builders/test_builder.py index 1c2922c00..2bea1fa6c 100644 --- a/tests/masonry/builders/test_builder.py +++ b/tests/masonry/builders/test_builder.py @@ -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"]}, @@ -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]] diff --git a/tests/masonry/utils/test_helpers.py b/tests/masonry/utils/test_helpers.py deleted file mode 100644 index b03ff39dd..000000000 --- a/tests/masonry/utils/test_helpers.py +++ /dev/null @@ -1,23 +0,0 @@ -from __future__ import annotations - -import warnings - -import pytest - -from poetry.core.masonry.utils.helpers import escape_name - - -@pytest.mark.parametrize( - "name,expected", - [ - ("foo", "foo"), - ("foo-bar", "foo_bar"), - ("FOO-bAr", "foo_bar"), - ("foo.bar", "foo_bar"), - ("foo123-ba---.r", "foo123_ba_r"), - ], -) -def test_escape_name(name: str, expected: str) -> None: - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - assert escape_name(name) == expected diff --git a/tests/packages/test_file_dependency.py b/tests/packages/test_file_dependency.py index 694ff367a..3d5b8267c 100644 --- a/tests/packages/test_file_dependency.py +++ b/tests/packages/test_file_dependency.py @@ -55,71 +55,6 @@ def test_file_dependency_is_directory( mock_is_directory.assert_called_once() -def test_default_hash() -> None: - with pytest.warns(DeprecationWarning): - path = DIST_PATH / TEST_FILE - dep = FileDependency("demo", path) - sha_256 = "72e8531e49038c5f9c4a837b088bfcb8011f4a9f76335c8f0654df6ac539b3d6" - assert dep.hash() == sha_256 - - -try: - from hashlib import algorithms_guaranteed -except ImportError: - algorithms_guaranteed = {"md5", "sha1", "sha224", "sha256", "sha384", "sha512"} - - -@pytest.mark.parametrize( - "hash_name,expected", - [ - (hash_name, value) - for hash_name, value in [ - ("sha224", "972d02f36539a98599aed0566bc8aaf3e6701f4e895dd797d8f5248e"), - ( - "sha3_512", - "c04ee109ae52d6440445e24dbd6d244a1d0f0289ef79cb7ba9bc3c139c0237169af9a8f61cd1cf4fc17f853ddf84f97c475ac5bb6c91a4aff0b825b884d4896c", - ), - ( - "blake2s", - "c336ecbc9d867c9d860accfba4c3723c51c4b5c47a1e0a955e1c8df499e36741", - ), - ( - "sha3_384", - "d4abb2459941369aabf8880c5287b7eeb80678e14f13c71b9ecf64c772029dc3f93939590bea9ecdb51a1d1a74fefc5a", - ), - ( - "blake2b", - "48e70abac547ab38e2330e6e6743a0c0f6274dcaa6df2c98135a78a9dd5b04a072d551fc3851b34da03eb0bf50dd71c7f32a8c36956e99fd6c66491bc7844800", - ), - ( - "sha256", - "72e8531e49038c5f9c4a837b088bfcb8011f4a9f76335c8f0654df6ac539b3d6", - ), - ( - "sha512", - "e08a00a4b86358e49a318e7e3ba7a3d2fabdd17a2fef95559a0af681ea07ab1296b0b8e11e645297da296290661dc07ae3c8f74eab66bd18a80dce0c0ccb355b", - ), - ( - "sha384", - "aa3144e28c6700a83247e8ec8711af5d3f5f75997990d48ec41e66bd275b3d0e19ee6f2fe525a358f874aa717afd06a9", - ), - ("sha3_224", "64bfc6e4125b4c6d67fd88ad1c7d1b5c4dc11a1970e433cd576c91d4"), - ("sha1", "4c057579005ac3e68e951a11ffdc4b27c6ae16af"), - ( - "sha3_256", - "ba3d2a964b0680b6dc9565a03952e29c294c785d5a2307d3e2d785d73b75ed7e", - ), - ] - if hash_name in algorithms_guaranteed - ], -) -def test_guaranteed_hash(hash_name: str, expected: str) -> None: - with pytest.warns(DeprecationWarning): - path = DIST_PATH / TEST_FILE - dep = FileDependency("demo", path) - assert dep.hash(hash_name) == expected - - def _test_file_dependency_pep_508( mocker: MockerFixture, name: str, diff --git a/tests/packages/test_package.py b/tests/packages/test_package.py index f94de4a4e..bc187c113 100644 --- a/tests/packages/test_package.py +++ b/tests/packages/test_package.py @@ -516,25 +516,6 @@ def test_only_with_dependency_groups(package_with_groups: Package) -> None: assert len(package.all_requires) == 2 -def test_get_readme_property_with_multiple_readme_files() -> None: - package = Package("foo", "0.1.0") - - package.readmes = (Path("README.md"), Path("HISTORY.md")) - with pytest.deprecated_call(): - assert package.readme == Path("README.md") - - -def test_set_readme_property() -> None: - package = Package("foo", "0.1.0") - - with pytest.deprecated_call(): - package.readme = Path("README.md") - - assert package.readmes == (Path("README.md"),) - with pytest.deprecated_call(): - assert package.readme == Path("README.md") - - @pytest.mark.parametrize( ("package", "dependency", "ignore_source_type", "result"), [