Skip to content

Commit

Permalink
Merge pull request #414 from geopy/v2/drop-py2-support
Browse files Browse the repository at this point in the history
geopy 2.0: drop Python 2.7 and 3.4 support
  • Loading branch information
KostyaEsmukov committed Jun 21, 2020
2 parents dfd0675 + 965055b commit 1173e9f
Show file tree
Hide file tree
Showing 76 changed files with 257 additions and 569 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ language: python
dist: xenial

python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8"
- "3.9-dev"
- "pypy"
- "pypy3"

before_install:
Expand Down
3 changes: 0 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

If you contribute code to geopy, you agree to license your code under the MIT.

geopy runs on both Python 2 and Python 3 on both the CPython and PyPy
interpreters. You should handle any compatibility in `geopy/compat.py`.

The new code should follow [PEP8](https://pep8.org/) coding style (except
the line length limit, which is 90) and adhere to the style of
the surrounding code.
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ geopy
:alt: License


geopy is a Python 2 and 3 client for several popular geocoding web
geopy is a Python client for several popular geocoding web
services.

geopy makes it easy for Python developers to locate the coordinates of
Expand All @@ -31,8 +31,8 @@ Geocoder classes are located in `geopy.geocoders`_.
.. _Geocoders doc section: https://geopy.readthedocs.io/en/latest/#geocoders
.. _geopy.geocoders: https://github.com/geopy/geopy/tree/master/geopy/geocoders

geopy is tested against CPython (versions 2.7, 3.4, 3.5, 3.6, 3.7, 3.8),
PyPy, and PyPy3. geopy does not and will not support CPython 2.6.
geopy is tested against CPython (versions 3.5, 3.6, 3.7, 3.8)
and PyPy3. geopy 1.x line also supported CPython 2.7, 3.4 and PyPy2.

© geopy contributors 2006-2018 (see AUTHORS) under the `MIT
License <https://github.com/geopy/geopy/blob/master/LICENSE>`__.
Expand Down
5 changes: 4 additions & 1 deletion docs/changelog_2xx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ Changelog
-----
2020-XXX

XXX
Packaging changes
~~~~~~~~~~~~~~~~~

- Dropped support for Python 2.7 and 3.4.
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# GeoPy documentation build configuration file, created by
# sphinx-quickstart on Thu Oct 24 19:28:11 2013.
Expand Down
6 changes: 3 additions & 3 deletions geopy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""
geopy is a Python 2 and 3 client for several popular geocoding web services.
geopy is a Python client for several popular geocoding web services.
geopy makes it easy for Python developers to locate the coordinates of
addresses, cities, countries, and landmarks across the globe using third-party
geocoders and other data sources.
geopy is tested against CPython (versions 2.7, 3.4, 3.5, 3.6, 3.7, 3.8),
PyPy, and PyPy3. geopy does not and will not support CPython 2.6.
geopy is tested against CPython (versions 3.5, 3.6, 3.7, 3.8)
and PyPy3. geopy 1.x line also supported CPython 2.7, 3.4 and PyPy2.
"""

from geopy.geocoders import * # noqa
Expand Down
159 changes: 0 additions & 159 deletions geopy/compat.py

This file was deleted.

44 changes: 22 additions & 22 deletions geopy/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,12 @@
``ValueError`` exception.
"""
from __future__ import division

import warnings
from math import asin, atan, atan2, cos, pi, sin, sqrt, tan

from geographiclib.geodesic import Geodesic

from geopy import units, util
from geopy.compat import cmp, py3k, string_compare
from geopy.point import Point
from geopy.units import radians

Expand All @@ -159,6 +156,10 @@
}


def cmp(a, b):
return (a > b) - (a < b)


def lonlat(x, y, z=0):
"""
``geopy.distance.distance`` accepts coordinates in ``(y, x)``/``(lat, lon)``
Expand Down Expand Up @@ -198,7 +199,7 @@ def _ensure_same_altitude(a, b):
# it won't give much error.


class Distance(object):
class Distance:
"""
Base for :class:`.great_circle`, :class:`.vincenty`, and
:class:`.geodesic`.
Expand Down Expand Up @@ -269,24 +270,23 @@ def __cmp__(self, other): # py2 only
else:
return cmp(self.kilometers, other)

if py3k:
def __eq__(self, other):
return self.__cmp__(other) == 0
def __eq__(self, other):
return self.__cmp__(other) == 0

def __ne__(self, other):
return self.__cmp__(other) != 0
def __ne__(self, other):
return self.__cmp__(other) != 0

def __gt__(self, other):
return self.__cmp__(other) > 0
def __gt__(self, other):
return self.__cmp__(other) > 0

def __lt__(self, other):
return self.__cmp__(other) < 0
def __lt__(self, other):
return self.__cmp__(other) < 0

def __ge__(self, other):
return self.__cmp__(other) >= 0
def __ge__(self, other):
return self.__cmp__(other) >= 0

def __le__(self, other):
return self.__cmp__(other) <= 0
def __le__(self, other):
return self.__cmp__(other) <= 0

@property
def kilometers(self):
Expand Down Expand Up @@ -350,7 +350,7 @@ class great_circle(Distance):

def __init__(self, *args, **kwargs):
self.RADIUS = kwargs.pop('radius', EARTH_RADIUS)
super(great_circle, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def measure(self, a, b):
a, b = Point(a), Point(b)
Expand Down Expand Up @@ -439,7 +439,7 @@ def __init__(self, *args, **kwargs):
'distance.', DeprecationWarning, stacklevel=2)
kwargs.pop('iterations', 0)
major, minor, f = self.ELLIPSOID
super(geodesic, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def set_ellipsoid(self, ellipsoid):
"""
Expand Down Expand Up @@ -548,7 +548,7 @@ def __init__(self, *args, **kwargs):
self.set_ellipsoid(kwargs.pop('ellipsoid', 'WGS-84'))
self.iterations = kwargs.pop('iterations', 20)
major, minor, f = self.ELLIPSOID
super(vincenty, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def set_ellipsoid(self, ellipsoid):
"""
Expand All @@ -572,7 +572,7 @@ def measure(self, a, b):
lat1, lng1 = radians(degrees=a.latitude), radians(degrees=a.longitude)
lat2, lng2 = radians(degrees=b.latitude), radians(degrees=b.longitude)

if isinstance(self.ELLIPSOID, string_compare):
if isinstance(self.ELLIPSOID, str):
major, minor, f = ELLIPSOIDS[self.ELLIPSOID]
else:
major, minor, f = self.ELLIPSOID
Expand Down Expand Up @@ -682,7 +682,7 @@ def destination(self, point, bearing, distance=None):
distance = distance.kilometers

ellipsoid = self.ELLIPSOID
if isinstance(ellipsoid, string_compare):
if isinstance(ellipsoid, str):
ellipsoid = ELLIPSOIDS[ellipsoid]

major, minor, f = ellipsoid
Expand Down
7 changes: 3 additions & 4 deletions geopy/extra/rate_limiter.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# coding: utf-8
from itertools import chain, count
from time import sleep
from timeit import default_timer

from geopy.compat import sleep_at_least
from geopy.exc import GeocoderServiceError
from geopy.util import logger

Expand All @@ -12,7 +11,7 @@ def _is_last_gen(count):
return chain((False for _ in range(count)), [True])


class RateLimiter(object):
class RateLimiter:
"""RateLimiter allows to perform bulk operations while gracefully
handling error responses and adding delays when needed.
Expand Down Expand Up @@ -110,7 +109,7 @@ def _clock(self): # pragma: no coverage

def _sleep(self, seconds): # pragma: no coverage
logger.debug('RateLimiter sleep(%r)', seconds)
sleep_at_least(seconds)
sleep(seconds)

def _sleep_between(self):
seconds_since_last_call = self._clock() - self._last_call
Expand Down
10 changes: 3 additions & 7 deletions geopy/format.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
from geopy import units
from geopy.compat import py3k

if py3k:
unichr = chr

# Unicode characters for symbols that appear in coordinate strings.
DEGREE = unichr(176)
PRIME = unichr(8242)
DOUBLE_PRIME = unichr(8243)
DEGREE = chr(176)
PRIME = chr(8242)
DOUBLE_PRIME = chr(8243)
ASCII_DEGREE = ''
ASCII_PRIME = "'"
ASCII_DOUBLE_PRIME = '"'
Expand Down

0 comments on commit 1173e9f

Please sign in to comment.