diff --git a/geojson/geometry.py b/geojson/geometry.py index ccf596c..883cebf 100644 --- a/geojson/geometry.py +++ b/geojson/geometry.py @@ -1,17 +1,9 @@ -import sys from decimal import Decimal from numbers import Number from geojson.base import GeoJSON -if sys.version_info[0] == 3: - # Python 3.x has no long type - _JSON_compliant_types = (float, int, Decimal) -else: - _JSON_compliant_types = (float, int, Decimal, long) # noqa - - class Geometry(GeoJSON): """ Represents an abstract base class for a WGS84 geometry. @@ -50,7 +42,7 @@ def clean_coordinates(cls, coords, precision): new_coords.append(cls.clean_coordinates(coord, precision)) elif isinstance(coord, Geometry): new_coords.append(coord['coordinates']) - elif isinstance(coord, _JSON_compliant_types): + elif isinstance(coord, (float, int, Decimal)): new_coords.append(round(coord, precision)) else: raise ValueError("%r is not a JSON compliant number" % coord) diff --git a/geojson/mapping.py b/geojson/mapping.py index 80c410c..1ceffbc 100644 --- a/geojson/mapping.py +++ b/geojson/mapping.py @@ -1,7 +1,4 @@ -try: - from collections.abc import MutableMapping -except ImportError: - from collections import MutableMapping +from collections.abc import MutableMapping try: import simplejson as json diff --git a/geojson/utils.py b/geojson/utils.py index 93b5222..5fb5f2e 100644 --- a/geojson/utils.py +++ b/geojson/utils.py @@ -13,8 +13,6 @@ def coords(obj): # Handle recursive case first if 'features' in obj: # FeatureCollection for f in obj['features']: - # For Python 2 compatibility - # See https://www.reddit.com/r/learnpython/comments/4rc15s/yield_from_and_python_27/ # noqa: E501 yield from coords(f) elif 'geometry' in obj: # Feature yield from coords(obj['geometry']) diff --git a/setup.py b/setup.py index 99ea3d0..eeee95a 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -import io from setuptools import setup import sys import re @@ -19,10 +18,7 @@ def test_suite(): import doctest - try: - import unittest2 as unittest - except ImportError: - import unittest + import unittest suite = unittest.TestLoader().discover("tests") suite.addTest(doctest.DocFileSuite("README.rst")) diff --git a/tests/test_features.py b/tests/test_features.py index d833cdd..77477e3 100644 --- a/tests/test_features.py +++ b/tests/test_features.py @@ -1,7 +1,4 @@ -try: - from StringIO import StringIO -except ImportError: - from io import StringIO +from io import StringIO import unittest import geojson