Skip to content

Commit 8351f11

Browse files
committed
Add deprecation warnings for deprecated API changes.
This also adds back in some API changes as deprecated, and switches a few more from PendingDeprecationWarnings to DeprecationWarnings.
1 parent b15b6f7 commit 8351f11

File tree

2 files changed

+80
-14
lines changed

2 files changed

+80
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ Here are some highlights of changes in this version. See the full list of change
1111

1212
### Breaking Changes
1313

14-
* Remove `name`, `legends`, `positioning`, and `positionning` properties in LegendControl [#979](https://github.com/jupyter-widgets/ipyleaflet/pull/979). Update your code with the following substitutions for a LegendControl `legend`:
14+
* Deprecate LegendControl properties `name`, `legends`, `positioning`, and `positionning` [#979](https://github.com/jupyter-widgets/ipyleaflet/pull/979) and [#1005](https://github.com/jupyter-widgets/ipyleaflet/pull/1005). Update your code with the following substitutions for a LegendControl `legend`:
1515
* `legend.name` -> `legend.title`
1616
* `legend.legends` -> `legend.legend`
1717
* `legend.positioning` -> `legend.position`
1818
* `legend.positionnning` -> `legend.position`
1919

20-
The recommended way to create a LegendControl with a given title is to use the `title` parameter: `LegendControl({}, title='My Title')`. There is a backwards compatibility shim in place, so giving the title as `name` in the constructor still works, but is not recommended: `LegendControl({}, name='My Title')`
20+
The `name` argument in creating a LegendControl is also deprecated, please use the `title` argument instead: `LegendControl({}, title='My Title')`.
2121
* Deprecate layer and control-specific methods for maps, in favor of methods that work for both layers and controls [#982](https://github.com/jupyter-widgets/ipyleaflet/pull/982). Update your code with the following substitutions for a Map `map`:
2222
* `map.add_control(...)` or `map.add_layer(...)` -> `map.add(...)`
2323
* `map.remove_control(...)` or `map.remove_layer(...)` -> `map.remove(...)`

ipyleaflet/leaflet.py

Lines changed: 78 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ def add_layer(self, layer):
11071107
layer: layer instance
11081108
The new layer to include in the group.
11091109
"""
1110-
warnings.warn("add_layer will be deprecated in future version, use add instead", PendingDeprecationWarning)
1110+
warnings.warn("add_layer is deprecated, use add instead", DeprecationWarning)
11111111

11121112
self.add(layer)
11131113

@@ -1122,7 +1122,7 @@ def remove_layer(self, rm_layer):
11221122
layer: layer instance
11231123
The layer to remove from the group.
11241124
"""
1125-
warnings.warn("remove_layer will be deprecated in future version, use remove instead", PendingDeprecationWarning)
1125+
warnings.warn("remove_layer is deprecated, use remove instead", DeprecationWarning)
11261126

11271127
self.remove(rm_layer)
11281128

@@ -1139,7 +1139,7 @@ def substitute_layer(self, old, new):
11391139
new: layer instance
11401140
The new layer to include in the group.
11411141
"""
1142-
warnings.warn("substitute_layer will be deprecated in future version, substitute instead", PendingDeprecationWarning)
1142+
warnings.warn("substitute_layer is deprecated, use substitute instead", DeprecationWarning)
11431143

11441144
self.substitute(old, new)
11451145

@@ -1151,7 +1151,7 @@ def clear_layers(self):
11511151
11521152
"""
11531153

1154-
warnings.warn("clear_layers will be deprecated in future version, use clear instead", PendingDeprecationWarning)
1154+
warnings.warn("clear_layers is deprecated, use clear instead", DeprecationWarning)
11551155

11561156
self.layers = ()
11571157

@@ -1915,6 +1915,10 @@ class LegendControl(Control):
19151915
19161916
A control which contains a legend.
19171917
1918+
.. deprecated :: 0.17.0
1919+
The constructor argument 'name' is deprecated, use the 'title' argument instead.
1920+
1921+
19181922
Attributes
19191923
----------
19201924
title: str, default 'Legend'
@@ -1936,10 +1940,72 @@ def __init__(self, legend, *args, **kwargs):
19361940
kwargs["legend"] = legend
19371941
# For backwards compatibility with ipyleaflet<=0.16.0
19381942
if 'name' in kwargs:
1943+
warnings.warn("the name argument is deprecated, use title instead", DeprecationWarning)
19391944
kwargs.setdefault('title', kwargs['name'])
19401945
del kwargs['name']
19411946
super().__init__(*args, **kwargs)
19421947

1948+
@property
1949+
def name(self):
1950+
"""The title of the legend.
1951+
1952+
.. deprecated :: 0.17.0
1953+
Use title attribute instead.
1954+
"""
1955+
warnings.warn(".name is deprecated, use .title instead", DeprecationWarning)
1956+
return self.title
1957+
1958+
@name.setter
1959+
def name(self, title):
1960+
warnings.warn(".name is deprecated, use .title instead", DeprecationWarning)
1961+
self.title = title
1962+
1963+
@property
1964+
def legends(self):
1965+
"""The legend information.
1966+
1967+
.. deprecated :: 0.17.0
1968+
Use legend attribute instead.
1969+
"""
1970+
1971+
warnings.warn(".legends is deprecated, use .legend instead", DeprecationWarning)
1972+
return self.legend
1973+
1974+
@legends.setter
1975+
def legends(self, legends):
1976+
warnings.warn(".legends is deprecated, use .legend instead", DeprecationWarning)
1977+
self.legend = legends
1978+
1979+
@property
1980+
def positioning(self):
1981+
"""The position information.
1982+
1983+
.. deprecated :: 0.17.0
1984+
Use position attribute instead.
1985+
"""
1986+
warnings.warn(".positioning is deprecated, use .position instead", DeprecationWarning)
1987+
return self.position
1988+
1989+
@positioning.setter
1990+
def positioning(self, position):
1991+
warnings.warn(".positioning is deprecated, use .position instead", DeprecationWarning)
1992+
self.position = position
1993+
1994+
@property
1995+
def positionning(self):
1996+
"""The position information.
1997+
1998+
.. deprecated :: 0.17.0
1999+
Use position attribute instead.
2000+
"""
2001+
warnings.warn(".positionning is deprecated, use .position instead", DeprecationWarning)
2002+
return self.position
2003+
2004+
@positionning.setter
2005+
def positionning(self, position):
2006+
warnings.warn(".positionning is deprecated, use .position instead", DeprecationWarning)
2007+
self.position = position
2008+
19432009
def add_legend_element(self, key, value):
19442010
"""Add a new legend element.
19452011
@@ -2286,15 +2352,15 @@ def _validate_layers(self, proposal):
22862352
def add_layer(self, layer):
22872353
"""Add a layer on the map.
22882354
2289-
.. deprecated :: 0.0
2355+
.. deprecated :: 0.17.0
22902356
Use add method instead.
22912357
22922358
Parameters
22932359
----------
22942360
layer: Layer instance
22952361
The new layer to add.
22962362
"""
2297-
warnings.warn("add_layer will be deprecated in future version, use add instead", PendingDeprecationWarning)
2363+
warnings.warn("add_layer is deprecated, use add instead", DeprecationWarning)
22982364
self.add(layer)
22992365

23002366
def remove_layer(self, rm_layer):
@@ -2308,7 +2374,7 @@ def remove_layer(self, rm_layer):
23082374
layer: Layer instance
23092375
The layer to remove.
23102376
"""
2311-
warnings.warn("remove_layer will be deprecated in future version, use remove instead", PendingDeprecationWarning)
2377+
warnings.warn("remove_layer is deprecated, use remove instead", DeprecationWarning)
23122378

23132379
self.remove(rm_layer)
23142380

@@ -2325,7 +2391,7 @@ def substitute_layer(self, old, new):
23252391
new: Layer instance
23262392
The new layer to add.
23272393
"""
2328-
warnings.warn("substitute_layer will be deprecated in future version, use substitute instead", PendingDeprecationWarning)
2394+
warnings.warn("substitute_layer is deprecated, use substitute instead", DeprecationWarning)
23292395

23302396
self.substitute(old, new)
23312397

@@ -2336,7 +2402,7 @@ def clear_layers(self):
23362402
Use add method instead.
23372403
23382404
"""
2339-
warnings.warn("clear_layers will be deprecated in future version, use clear instead", PendingDeprecationWarning)
2405+
warnings.warn("clear_layers is deprecated, use clear instead", DeprecationWarning)
23402406

23412407
self.layers = ()
23422408

@@ -2367,7 +2433,7 @@ def add_control(self, control):
23672433
The new control to add.
23682434
"""
23692435

2370-
warnings.warn("add_control will be deprecated in future version, use add instead", PendingDeprecationWarning)
2436+
warnings.warn("add_control is deprecated, use add instead", DeprecationWarning)
23712437

23722438
self.add(control)
23732439

@@ -2382,7 +2448,7 @@ def remove_control(self, control):
23822448
control: Control instance
23832449
The control to remove.
23842450
"""
2385-
warnings.warn("remove_control will be deprecated in future version, use remove instead", PendingDeprecationWarning)
2451+
warnings.warn("remove_control is deprecated, use remove instead", DeprecationWarning)
23862452

23872453
self.remove(control)
23882454

@@ -2392,7 +2458,7 @@ def clear_controls(self):
23922458
.. deprecated :: 0.17.0
23932459
Use clear method instead.
23942460
"""
2395-
warnings.warn("clear_controls will be deprecated in future version, use clear instead", PendingDeprecationWarning)
2461+
warnings.warn("clear_controls is deprecated, use clear instead", DeprecationWarning)
23962462

23972463
self.controls = ()
23982464

0 commit comments

Comments
 (0)