From ea32038724cdc52c3f3e675cd17a4b3ed04acc63 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Mon, 25 Sep 2023 19:15:25 +0200 Subject: [PATCH] remove last bits of python2 / six (#1295) --- fiona/_crs.pyx | 6 +----- fiona/_err.pyx | 2 -- fiona/_geometry.pyx | 4 +--- fiona/_transform.pyx | 1 - fiona/_vendor/munch/__init__.py | 10 +++++----- fiona/_vendor/munch/python3_compat.py | 6 ------ fiona/crs.py | 4 +--- fiona/ogrext.pyx | 1 - pyproject.toml | 1 - 9 files changed, 8 insertions(+), 27 deletions(-) delete mode 100644 fiona/_vendor/munch/python3_compat.py diff --git a/fiona/_crs.pyx b/fiona/_crs.pyx index 4184180a0..f63141790 100644 --- a/fiona/_crs.pyx +++ b/fiona/_crs.pyx @@ -3,12 +3,8 @@ Calls methods from GDAL's OSR module. """ -from __future__ import absolute_import - import logging -from six import string_types - from fiona cimport _cpl from fiona._err cimport exc_wrap_pointer from fiona._err import CPLE_BaseError @@ -38,7 +34,7 @@ def crs_to_wkt(crs): crs = crs.to_wkt() # First, check for CRS strings like "EPSG:3857". - if isinstance(crs, string_types): + if isinstance(crs, str): proj_b = crs.encode('utf-8') proj_c = proj_b OSRSetFromUserInput(cogr_srs, proj_c) diff --git a/fiona/_err.pyx b/fiona/_err.pyx index 37855e9cb..0dff3b3fc 100644 --- a/fiona/_err.pyx +++ b/fiona/_err.pyx @@ -29,8 +29,6 @@ manager raises a more useful and informative error: ValueError: The PNG driver does not support update access to existing datasets. """ -from __future__ import absolute_import - # CPL function declarations. cdef extern from "cpl_error.h": diff --git a/fiona/_geometry.pyx b/fiona/_geometry.pyx index 55fb87d01..bdc33c983 100644 --- a/fiona/_geometry.pyx +++ b/fiona/_geometry.pyx @@ -1,7 +1,5 @@ # Coordinate and geometry transformations. -from __future__ import absolute_import - include "gdal.pxi" import logging @@ -20,7 +18,7 @@ log.addHandler(NullHandler()) # mapping of GeoJSON type names to OGR integer geometry types -GEOJSON2OGR_GEOMETRY_TYPES = dict((v, k) for k, v in GEOMETRY_TYPES.iteritems()) +GEOJSON2OGR_GEOMETRY_TYPES = dict((v, k) for k, v in GEOMETRY_TYPES.items()) cdef int ogr_get_geometry_type(void *geometry): # OGR_G_GetGeometryType with NULL geometry support diff --git a/fiona/_transform.pyx b/fiona/_transform.pyx index 772b673dd..f159fd5f9 100644 --- a/fiona/_transform.pyx +++ b/fiona/_transform.pyx @@ -1,7 +1,6 @@ # distutils: language = c++ # # Coordinate and geometry transformations. -from __future__ import absolute_import include "gdal.pxi" diff --git a/fiona/_vendor/munch/__init__.py b/fiona/_vendor/munch/__init__.py index 5b32fe764..f43e12920 100644 --- a/fiona/_vendor/munch/__init__.py +++ b/fiona/_vendor/munch/__init__.py @@ -21,7 +21,7 @@ converted via Munch.to/fromDict(). """ -from .python3_compat import iterkeys, iteritems, Mapping #, u +from collections.abc import Mapping __version__ = "2.5.0" VERSION = tuple(map(int, __version__.split('.')[:3])) @@ -190,7 +190,7 @@ def __repr__(self): return '{0}({1})'.format(self.__class__.__name__, dict.__repr__(self)) def __dir__(self): - return list(iterkeys(self)) + return list(self.keys()) def __getstate__(self): """ Implement a serializable interface used for pickling. @@ -229,7 +229,7 @@ def update(self, *args, **kwargs): Override built-in method to call custom __setitem__ method that may be defined in subclasses. """ - for k, v in iteritems(dict(*args, **kwargs)): + for k, v in dict(*args, **kwargs).items(): self[k] = v def get(self, k, d=None): @@ -428,7 +428,7 @@ def post_munchify(partial, obj): # Here we finish munchifying the parts of obj that were deferred by pre_munchify because they # might be involved in a cycle if isinstance(obj, Mapping): - partial.update((k, munchify_cycles(obj[k])) for k in iterkeys(obj)) + partial.update((k, munchify_cycles(obj[k])) for k in obj.keys()) elif isinstance(obj, list): partial.extend(munchify_cycles(item) for item in obj) elif isinstance(obj, tuple): @@ -490,7 +490,7 @@ def post_unmunchify(partial, obj): # Here we finish unmunchifying the parts of obj that were deferred by pre_unmunchify because they # might be involved in a cycle if isinstance(obj, Mapping): - partial.update((k, unmunchify_cycles(obj[k])) for k in iterkeys(obj)) + partial.update((k, unmunchify_cycles(obj[k])) for k in obj.keys()) elif isinstance(obj, list): partial.extend(unmunchify_cycles(v) for v in obj) elif isinstance(obj, tuple): diff --git a/fiona/_vendor/munch/python3_compat.py b/fiona/_vendor/munch/python3_compat.py deleted file mode 100644 index 4f30702fc..000000000 --- a/fiona/_vendor/munch/python3_compat.py +++ /dev/null @@ -1,6 +0,0 @@ -from six import u, iteritems, iterkeys # pylint: disable=unused-import -try: - from collections.abc import Mapping # pylint: disable=unused-import -except ImportError: - # Legacy Python - from collections import Mapping # pylint: disable=unused-import diff --git a/fiona/crs.py b/fiona/crs.py index 27bf8ca41..ce344123e 100644 --- a/fiona/crs.py +++ b/fiona/crs.py @@ -10,8 +10,6 @@ {'proj': 'longlat', 'ellps': 'WGS84', 'datum': 'WGS84', 'no_defs': True} """ -from six import string_types - def to_string(crs): """Turn a parameter mapping into a more conventional PROJ.4 string. @@ -25,7 +23,7 @@ def to_string(crs): for k, v in sorted(filter( lambda x: x[0] in all_proj_keys and x[1] is not False and ( isinstance(x[1], (bool, int, float)) or - isinstance(x[1], string_types)), + isinstance(x[1], str)), crs.items())): items.append( "+" + "=".join( diff --git a/fiona/ogrext.pyx b/fiona/ogrext.pyx index 25d6dc821..dfd6fe715 100644 --- a/fiona/ogrext.pyx +++ b/fiona/ogrext.pyx @@ -1,5 +1,4 @@ # These are extension functions and classes using the OGR C API. -from __future__ import absolute_import include "gdal.pxi" diff --git a/pyproject.toml b/pyproject.toml index d64694822..cb78880c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,6 @@ dependencies = [ "click-plugins>=1.0", "cligj>=0.5", 'importlib-metadata;python_version<"3.10"', - "six", ] [project.optional-dependencies]