From 5670366e429c14ca82a5a32026c7d8e315e4d8ba Mon Sep 17 00:00:00 2001 From: Martin Fleischmann Date: Mon, 11 Apr 2022 23:19:44 +0100 Subject: [PATCH] CI: update black (#2404) --- .pre-commit-config.yaml | 20 +++++++++---------- geopandas/_compat.py | 2 -- geopandas/_config.py | 4 ++-- geopandas/io/sql.py | 2 +- .../io/tests/generate_legacy_storage_files.py | 2 +- geopandas/tests/test_geom_methods.py | 2 +- geopandas/tests/test_plotting.py | 12 +++++------ geopandas/tools/tests/test_sjoin.py | 12 +++++------ 8 files changed, 27 insertions(+), 29 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0ec4099..22f1460 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,12 @@ files: 'geopandas\/' repos: -- repo: https://github.com/python/black - rev: 20.8b1 - hooks: - - id: black - language_version: python3 -- repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.3 - hooks: - - id: flake8 - language: python_venv + - repo: https://github.com/psf/black + rev: 22.3.0 + hooks: + - id: black + language_version: python3 + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.3 + hooks: + - id: flake8 + language: python_venv diff --git a/geopandas/_compat.py b/geopandas/_compat.py index ab6edc2..8a68cdb 100644 --- a/geopandas/_compat.py +++ b/geopandas/_compat.py @@ -149,7 +149,6 @@ if shapely_warning is not None and not SHAPELY_GE_20: ) yield - elif (Version(np.__version__) >= Version("1.21")) and not SHAPELY_GE_20: @contextlib.contextmanager @@ -162,7 +161,6 @@ elif (Version(np.__version__) >= Version("1.21")) and not SHAPELY_GE_20: ) yield - else: @contextlib.contextmanager diff --git a/geopandas/_config.py b/geopandas/_config.py index 99a2fca..cdfa557 100644 --- a/geopandas/_config.py +++ b/geopandas/_config.py @@ -50,7 +50,7 @@ class Options(object): cls = self.__class__.__name__ description = "" for key, option in self._options.items(): - descr = u"{key}: {cur!r} [default: {default!r}]\n".format( + descr = "{key}: {cur!r} [default: {default!r}]\n".format( key=key, cur=self._config[key], default=option.default_value ) description += descr @@ -58,7 +58,7 @@ class Options(object): if option.doc: doc_text = "\n".join(textwrap.wrap(option.doc, width=70)) else: - doc_text = u"No description available." + doc_text = "No description available." doc_text = textwrap.indent(doc_text, prefix=" ") description += doc_text + "\n" space = "\n " diff --git a/geopandas/io/sql.py b/geopandas/io/sql.py index 17e7c40..89e8016 100644 --- a/geopandas/io/sql.py +++ b/geopandas/io/sql.py @@ -272,7 +272,7 @@ def _convert_linearring_to_linestring(gdf, geom_name): def _convert_to_ewkb(gdf, geom_name, srid): - """Convert geometries to ewkb. """ + """Convert geometries to ewkb.""" if compat.USE_PYGEOS: from pygeos import set_srid, to_wkb diff --git a/geopandas/io/tests/generate_legacy_storage_files.py b/geopandas/io/tests/generate_legacy_storage_files.py index cc39273..9cf4a0c 100644 --- a/geopandas/io/tests/generate_legacy_storage_files.py +++ b/geopandas/io/tests/generate_legacy_storage_files.py @@ -31,7 +31,7 @@ from shapely.geometry import Point def create_pickle_data(): - """ create the pickle data """ + """create the pickle data""" # custom geometry column name gdf_the_geom = geopandas.GeoDataFrame( diff --git a/geopandas/tests/test_geom_methods.py b/geopandas/tests/test_geom_methods.py index 05e3d5c..705b5eb 100644 --- a/geopandas/tests/test_geom_methods.py +++ b/geopandas/tests/test_geom_methods.py @@ -490,7 +490,7 @@ class TestGeomMethods: ) assert_array_dtype_equal(expected, self.na_none.distance(self.p0)) - expected = Series(np.array([np.sqrt(4 ** 2 + 4 ** 2), np.nan]), self.g6.index) + expected = Series(np.array([np.sqrt(4**2 + 4**2), np.nan]), self.g6.index) assert_array_dtype_equal(expected, self.g6.distance(self.na_none)) expected = Series(np.array([np.nan, 0, 0, 0, 0, 0, np.nan, np.nan]), range(8)) diff --git a/geopandas/tests/test_plotting.py b/geopandas/tests/test_plotting.py index 39cf3de..368a044 100644 --- a/geopandas/tests/test_plotting.py +++ b/geopandas/tests/test_plotting.py @@ -1090,9 +1090,9 @@ class TestMapclassifyPlotting: ) labels = [t.get_text() for t in ax.get_legend().get_texts()] expected = [ - u" 140.00, 5217064.00", - u" 5217064.00, 19532732.33", - u" 19532732.33, 1379302771.00", + " 140.00, 5217064.00", + " 5217064.00, 19532732.33", + " 19532732.33, 1379302771.00", ] assert labels == expected @@ -1125,7 +1125,7 @@ class TestMapclassifyPlotting: column="NEGATIVES", scheme="FISHER_JENKS", k=3, cmap="OrRd", legend=True ) labels = [t.get_text() for t in ax.get_legend().get_texts()] - expected = [u"-10.00, -3.41", u" -3.41, 3.30", u" 3.30, 10.00"] + expected = ["-10.00, -3.41", " -3.41, 3.30", " 3.30, 10.00"] assert labels == expected def test_fmt(self): @@ -1138,7 +1138,7 @@ class TestMapclassifyPlotting: legend_kwds={"fmt": "{:.0f}"}, ) labels = [t.get_text() for t in ax.get_legend().get_texts()] - expected = [u"-10, -3", u" -3, 3", u" 3, 10"] + expected = ["-10, -3", " -3, 3", " 3, 10"] assert labels == expected def test_interval(self): @@ -1151,7 +1151,7 @@ class TestMapclassifyPlotting: legend_kwds={"interval": True}, ) labels = [t.get_text() for t in ax.get_legend().get_texts()] - expected = [u"[-10.00, -3.41]", u"( -3.41, 3.30]", u"( 3.30, 10.00]"] + expected = ["[-10.00, -3.41]", "( -3.41, 3.30]", "( 3.30, 10.00]"] assert labels == expected @pytest.mark.parametrize("scheme", ["FISHER_JENKS", "FISHERJENKS"]) diff --git a/geopandas/tools/tests/test_sjoin.py b/geopandas/tools/tests/test_sjoin.py index c14367c..80a9972 100644 --- a/geopandas/tools/tests/test_sjoin.py +++ b/geopandas/tools/tests/test_sjoin.py @@ -767,14 +767,14 @@ class TestNearest: [Point(1, 1), Point(0.25, 1)], [0, 1], [1, 0], - [math.sqrt(0.25 ** 2 + 1), 0], + [math.sqrt(0.25**2 + 1), 0], ), ( [Point(0, 0), Point(1, 1)], [Point(-10, -10), Point(100, 100)], [0, 1], [0, 0], - [math.sqrt(10 ** 2 + 10 ** 2), math.sqrt(11 ** 2 + 11 ** 2)], + [math.sqrt(10**2 + 10**2), math.sqrt(11**2 + 11**2)], ), ( [Point(0, 0), Point(1, 1)], @@ -788,7 +788,7 @@ class TestNearest: [Point(1.1, 1.1), Point(0, 0)], [0, 1, 2], [1, 0, 1], - [0, np.sqrt(0.1 ** 2 + 0.1 ** 2), 0], + [0, np.sqrt(0.1**2 + 0.1**2), 0], ), ], ) @@ -852,21 +852,21 @@ class TestNearest: [Point(-10, -10), Point(100, 100)], [0, 1], [0, 1], - [math.sqrt(10 ** 2 + 10 ** 2), math.sqrt(99 ** 2 + 99 ** 2)], + [math.sqrt(10**2 + 10**2), math.sqrt(99**2 + 99**2)], ), ( [Point(0, 0), Point(1, 1)], [Point(x, y) for x, y in zip(np.arange(10), np.arange(10))], [0, 1] + [1] * 8, list(range(10)), - [0, 0] + [np.sqrt(x ** 2 + x ** 2) for x in np.arange(1, 9)], + [0, 0] + [np.sqrt(x**2 + x**2) for x in np.arange(1, 9)], ), ( [Point(0, 0), Point(1, 1), Point(0, 0)], [Point(1.1, 1.1), Point(0, 0)], [1, 0, 2], [0, 1, 1], - [np.sqrt(0.1 ** 2 + 0.1 ** 2), 0, 0], + [np.sqrt(0.1**2 + 0.1**2), 0, 0], ), ], )