Skip to content

Commit

Permalink
Readd backwards compatibility for Dependency/Package.develop
Browse files Browse the repository at this point in the history
  • Loading branch information
0scarB committed Oct 26, 2020
1 parent ebe0aba commit 8231c07
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
24 changes: 23 additions & 1 deletion poetry/core/packages/directory_dependency.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import List
from typing import Set
from typing import Union
from warnings import warn

from poetry.core.pyproject import PyProjectTOML
from poetry.core.utils._compat import Path
Expand All @@ -17,6 +18,7 @@ def __init__(
optional=False, # type: bool
base=None, # type: Path
editable=False, # type: bool
develop=False, # type: bool
extras=None, # type: Union[List[str], Set[str]]
):
self._path = path
Expand All @@ -29,7 +31,18 @@ def __init__(
except FileNotFoundError:
raise ValueError("Directory {} does not exist".format(self._path))

self._editable = editable
# TODO: Remove the following once poetry has been updated to use editable in source.
if develop:
if editable:
raise ValueError(
'Deprecated "develop" parameter may not be passed with new "editable" parameter. '
'Only use "editable"!'
)
warn(
'"develop" parameter is deprecated, use "editable" instead.',
DeprecationWarning,
)
self._editable = editable or develop
self._supports_poetry = False

if not self._full_path.exists():
Expand Down Expand Up @@ -78,6 +91,15 @@ def base(self):
def editable(self):
return self._editable

# TODO: Remove the following once poetry has been updated to use editable in source.
@property
def develop(self): # type: () -> bool
warn(
'"develop" property is deprecated, use "editable" instead.',
DeprecationWarning,
)
return self.editable

def supports_poetry(self):
return self._supports_poetry

Expand Down
19 changes: 19 additions & 0 deletions poetry/core/packages/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from contextlib import contextmanager
from typing import List
from warnings import warn

from poetry.core.semver import Version
from poetry.core.semver import parse_constraint
Expand Down Expand Up @@ -287,6 +288,24 @@ def urls(self):

return urls

# TODO: Remove the following once poetry has been updated to use editable in source.
@property
def develop(self): # type: () -> bool
warn(
'"develop" attribute is deprecated, use "editable" instead.',
DeprecationWarning,
)
return self.editable

# TODO: Remove the following once poetry has been updated to use editable in source.
@develop.setter
def develop(self, value): # type: (bool) -> None
warn(
'"develop" attribute is deprecated, use "editable" instead.',
DeprecationWarning,
)
self.editable = value

def is_prerelease(self):
return self._version.is_prerelease()

Expand Down
22 changes: 22 additions & 0 deletions poetry/core/packages/vcs_dependency.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import List
from typing import Set
from typing import Union
from warnings import warn

from poetry.core.vcs import git

Expand All @@ -24,6 +25,7 @@ def __init__(
category="main",
optional=False,
editable=False,
develop=False,
extras=None, # type: Union[List[str], Set[str]]
):
self._vcs = vcs
Expand All @@ -36,6 +38,17 @@ def __init__(
self._branch = branch
self._tag = tag
self._rev = rev
# TODO: Remove the following once poetry has been updated to use editable in source.
if develop:
if editable:
raise ValueError(
'Deprecated "develop" parameter may not be passed with new "editable" parameter. '
'Only use "editable"!'
)
warn(
'"develop" parameter is deprecated, use "editable" instead.',
DeprecationWarning,
)
self._editable = editable

super(VCSDependency, self).__init__(
Expand Down Expand Up @@ -75,6 +88,15 @@ def rev(self):
def editable(self): # type: () -> bool
return self._editable

# TODO: Remove the following once poetry has been updated to use editable in source.
@property
def develop(self): # type: () -> bool
warn(
'"develop" property is deprecated, use "editable" instead.',
DeprecationWarning,
)
return self.editable

@property
def reference(self): # type: () -> str
return self._branch or self._tag or self._rev
Expand Down

0 comments on commit 8231c07

Please sign in to comment.