Skip to content

Commit

Permalink
Deprecate rather than remove parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Jan 22, 2023
1 parent 80b8193 commit 56bbd6b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/poetry/core/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def create_poetry(
def get_package(cls, name: str, version: str) -> ProjectPackage:
from poetry.core.packages.project_package import ProjectPackage

return ProjectPackage(name, version, version)
return ProjectPackage(name, version)

@classmethod
def _add_package_group_dependencies(
Expand Down
14 changes: 10 additions & 4 deletions src/poetry/core/packages/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import copy
import re
import warnings

from contextlib import contextmanager
from pathlib import Path
Expand Down Expand Up @@ -54,6 +55,7 @@ def __init__(
self,
name: str,
version: str | Version,
pretty_version: str | None = None,
source_type: str | None = None,
source_url: str | None = None,
source_reference: str | None = None,
Expand All @@ -68,6 +70,14 @@ def __init__(
"""
from poetry.core.version.markers import AnyMarker

if pretty_version is not None:
warnings.warn(
"The `pretty_version` parameter is deprecated and will be removed"
" in a future release.",
DeprecationWarning,
stacklevel=2,
)

super().__init__(
name,
source_type=source_type,
Expand Down Expand Up @@ -364,8 +374,6 @@ def urls(self) -> dict[str, str]:

@property
def readme(self) -> Path | None:
import warnings

warnings.warn(
"`readme` is deprecated: you are getting only the first readme file. Please"
" use the plural form `readmes`.",
Expand All @@ -375,8 +383,6 @@ def readme(self) -> Path | None:

@readme.setter
def readme(self, path: Path) -> None:
import warnings

warnings.warn(
"`readme` is deprecated. Please assign a tuple to the plural form"
" `readmes`.",
Expand Down
12 changes: 11 additions & 1 deletion src/poetry/core/packages/project_package.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import warnings

from typing import TYPE_CHECKING
from typing import Any

Expand All @@ -22,7 +24,15 @@ def __init__(
version: str | Version,
pretty_version: str | None = None,
) -> None:
super().__init__(name, version, pretty_version)
if pretty_version is not None:
warnings.warn(
"The `pretty_version` parameter is deprecated and will be removed"
" in a future release.",
DeprecationWarning,
stacklevel=2,
)

super().__init__(name, version)

self.build_config: dict[str, Any] = {}
self.packages: list[dict[str, Any]] = []
Expand Down

0 comments on commit 56bbd6b

Please sign in to comment.