From 5512a3f010cffd133dc776a08b7d07a15f0aecdd Mon Sep 17 00:00:00 2001 From: Matt Richards <45483497+m-richards@users.noreply.github.com> Date: Fri, 3 Jun 2022 22:38:49 +1000 Subject: [PATCH] MAINT: switch old deprecationwarnings to futurewarnings (#2447) --- geopandas/geodataframe.py | 8 ++++---- geopandas/geoseries.py | 8 ++++---- geopandas/io/file.py | 4 ++-- geopandas/io/sql.py | 2 +- geopandas/io/tests/test_file.py | 4 ++-- geopandas/io/tests/test_sql.py | 2 +- geopandas/plotting.py | 4 ++-- geopandas/tests/test_geom_methods.py | 24 ++++++++++++------------ geopandas/tests/test_plotting.py | 12 ++++++------ 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/geopandas/geodataframe.py b/geopandas/geodataframe.py index 0f3f780..d6444e2 100644 --- a/geopandas/geodataframe.py +++ b/geopandas/geodataframe.py @@ -1864,7 +1864,7 @@ individually so that features may have different properties warnings.warn( "'^' operator will be deprecated. Use the 'symmetric_difference' " "method instead.", - DeprecationWarning, + FutureWarning, stacklevel=2, ) return self.geometry.symmetric_difference(other) @@ -1873,7 +1873,7 @@ individually so that features may have different properties """Implement | operator as for builtin set type""" warnings.warn( "'|' operator will be deprecated. Use the 'union' method instead.", - DeprecationWarning, + FutureWarning, stacklevel=2, ) return self.geometry.union(other) @@ -1882,7 +1882,7 @@ individually so that features may have different properties """Implement & operator as for builtin set type""" warnings.warn( "'&' operator will be deprecated. Use the 'intersection' method instead.", - DeprecationWarning, + FutureWarning, stacklevel=2, ) return self.geometry.intersection(other) @@ -1891,7 +1891,7 @@ individually so that features may have different properties """Implement - operator as for builtin set type""" warnings.warn( "'-' operator will be deprecated. Use the 'difference' method instead.", - DeprecationWarning, + FutureWarning, stacklevel=2, ) return self.geometry.difference(other) diff --git a/geopandas/geoseries.py b/geopandas/geoseries.py index eb9bd8e..cc9b5fa 100644 --- a/geopandas/geoseries.py +++ b/geopandas/geoseries.py @@ -1245,7 +1245,7 @@ e": "Feature", "properties": {}, "geometry": {"type": "Point", "coordinates": [3 warnings.warn( "'^' operator will be deprecated. Use the 'symmetric_difference' " "method instead.", - DeprecationWarning, + FutureWarning, stacklevel=2, ) return self.symmetric_difference(other) @@ -1254,7 +1254,7 @@ e": "Feature", "properties": {}, "geometry": {"type": "Point", "coordinates": [3 """Implement | operator as for builtin set type""" warnings.warn( "'|' operator will be deprecated. Use the 'union' method instead.", - DeprecationWarning, + FutureWarning, stacklevel=2, ) return self.union(other) @@ -1263,7 +1263,7 @@ e": "Feature", "properties": {}, "geometry": {"type": "Point", "coordinates": [3 """Implement & operator as for builtin set type""" warnings.warn( "'&' operator will be deprecated. Use the 'intersection' method instead.", - DeprecationWarning, + FutureWarning, stacklevel=2, ) return self.intersection(other) @@ -1272,7 +1272,7 @@ e": "Feature", "properties": {}, "geometry": {"type": "Point", "coordinates": [3 """Implement - operator as for builtin set type""" warnings.warn( "'-' operator will be deprecated. Use the 'difference' method instead.", - DeprecationWarning, + FutureWarning, stacklevel=2, ) return self.difference(other) diff --git a/geopandas/io/file.py b/geopandas/io/file.py index 0b55373..9e36641 100644 --- a/geopandas/io/file.py +++ b/geopandas/io/file.py @@ -269,7 +269,7 @@ def read_file(*args, **kwargs): warnings.warn( "geopandas.io.file.read_file() is intended for internal " "use only, and will be deprecated. Use geopandas.read_file() instead.", - DeprecationWarning, + FutureWarning, stacklevel=2, ) @@ -281,7 +281,7 @@ def to_file(*args, **kwargs): "geopandas.io.file.to_file() is intended for internal " "use only, and will be deprecated. Use GeoDataFrame.to_file() " "or GeoSeries.to_file() instead.", - DeprecationWarning, + FutureWarning, stacklevel=2, ) diff --git a/geopandas/io/sql.py b/geopandas/io/sql.py index 06c00b9..93b8c18 100644 --- a/geopandas/io/sql.py +++ b/geopandas/io/sql.py @@ -182,7 +182,7 @@ def read_postgis(*args, **kwargs): warnings.warn( "geopandas.io.sql.read_postgis() is intended for internal " "use only, and will be deprecated. Use geopandas.read_postgis() instead.", - DeprecationWarning, + FutureWarning, stacklevel=2, ) diff --git a/geopandas/io/tests/test_file.py b/geopandas/io/tests/test_file.py index 2e6314e..ec63180 100644 --- a/geopandas/io/tests/test_file.py +++ b/geopandas/io/tests/test_file.py @@ -261,7 +261,7 @@ def test_to_file_empty(tmpdir): def test_to_file_privacy(tmpdir, df_nybb): tempfilename = os.path.join(str(tmpdir), "test.shp") - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): geopandas.io.file.to_file(df_nybb, tempfilename) @@ -679,7 +679,7 @@ def test_read_file_empty_shapefile(tmpdir): def test_read_file_privacy(tmpdir, df_nybb): - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): geopandas.io.file.read_file(geopandas.datasets.get_path("nybb")) diff --git a/geopandas/io/tests/test_sql.py b/geopandas/io/tests/test_sql.py index 62d832f..360fefa 100644 --- a/geopandas/io/tests/test_sql.py +++ b/geopandas/io/tests/test_sql.py @@ -326,7 +326,7 @@ class TestIO: create_postgis(con, df_nybb) sql = "SELECT * FROM nybb;" - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): geopandas.io.sql.read_postgis(sql, con) def test_write_postgis_default(self, engine_postgis, df_nybb): diff --git a/geopandas/plotting.py b/geopandas/plotting.py index 8555dcc..aa198d5 100644 --- a/geopandas/plotting.py +++ b/geopandas/plotting.py @@ -11,14 +11,14 @@ from packaging.version import Version from ._decorator import doc -def deprecated(new): +def deprecated(new, warning_type=FutureWarning): """Helper to provide deprecation warning.""" def old(*args, **kwargs): warnings.warn( "{} is intended for internal ".format(new.__name__[1:]) + "use only, and will be deprecated.", - DeprecationWarning, + warning_type, stacklevel=2, ) new(*args, **kwargs) diff --git a/geopandas/tests/test_geom_methods.py b/geopandas/tests/test_geom_methods.py index 705b5eb..013dc45 100644 --- a/geopandas/tests/test_geom_methods.py +++ b/geopandas/tests/test_geom_methods.py @@ -1224,39 +1224,39 @@ class TestGeomMethods: # Test '&', '|', '^', and '-' # def test_intersection_operator(self): - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): self._test_binary_operator("__and__", self.t1, self.g1, self.g2) - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): self._test_binary_operator("__and__", self.t1, self.gdf1, self.g2) def test_union_operator(self): - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): self._test_binary_operator("__or__", self.sq, self.g1, self.g2) - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): self._test_binary_operator("__or__", self.sq, self.gdf1, self.g2) def test_union_operator_polygon(self): - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): self._test_binary_operator("__or__", self.sq, self.g1, self.t2) - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): self._test_binary_operator("__or__", self.sq, self.gdf1, self.t2) def test_symmetric_difference_operator(self): - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): self._test_binary_operator("__xor__", self.sq, self.g3, self.g4) - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): self._test_binary_operator("__xor__", self.sq, self.gdf3, self.g4) def test_difference_series2(self): expected = GeoSeries([GeometryCollection(), self.t2]) - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): self._test_binary_operator("__sub__", expected, self.g1, self.g2) - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): self._test_binary_operator("__sub__", expected, self.gdf1, self.g2) def test_difference_poly2(self): expected = GeoSeries([self.t1, self.t1]) - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): self._test_binary_operator("__sub__", expected, self.g1, self.t2) - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): self._test_binary_operator("__sub__", expected, self.gdf1, self.t2) diff --git a/geopandas/tests/test_plotting.py b/geopandas/tests/test_plotting.py index 368a044..26291ce 100644 --- a/geopandas/tests/test_plotting.py +++ b/geopandas/tests/test_plotting.py @@ -1438,8 +1438,8 @@ class TestPlotCollections: with pytest.raises((TypeError, ValueError)): _plot_point_collection(ax, self.points, color="not color") - # check DeprecationWarning - with pytest.warns(DeprecationWarning): + # check FutureWarning + with pytest.warns(FutureWarning): plot_point_collection(ax, self.points) def test_points_values(self): @@ -1511,8 +1511,8 @@ class TestPlotCollections: # not a color with pytest.raises((TypeError, ValueError)): _plot_linestring_collection(ax, self.lines, color="not color") - # check DeprecationWarning - with pytest.warns(DeprecationWarning): + # check FutureWarning + with pytest.warns(FutureWarning): plot_linestring_collection(ax, self.lines) def test_linestrings_values(self): @@ -1603,8 +1603,8 @@ class TestPlotCollections: # not a color with pytest.raises((TypeError, ValueError)): _plot_polygon_collection(ax, self.polygons, color="not color") - # check DeprecationWarning - with pytest.warns(DeprecationWarning): + # check FutureWarning + with pytest.warns(FutureWarning): plot_polygon_collection(ax, self.polygons) def test_polygons_values(self):