Skip to content

Commit d88ecb5

Browse files
committed
__unicode__ is a left-over from python 2
1 parent db6071b commit d88ecb5

8 files changed

Lines changed: 6 additions & 30 deletions

File tree

‎opencage/geocoder.py‎

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,9 @@ def __init__(self, message, bad_value=None):
9595
self.message = message
9696
self.bad_value = bad_value
9797

98-
def __unicode__(self):
98+
def __str__(self):
9999
return self.message
100100

101-
__str__ = __unicode__
102-
103101

104102
class UnknownError(OpenCageGeocodeError):
105103
"""There was a problem with the OpenCage server."""
@@ -108,33 +106,27 @@ class UnknownError(OpenCageGeocodeError):
108106
class RateLimitExceededError(OpenCageGeocodeError):
109107
"""Exception raised when account has exceeded its limit."""
110108

111-
def __unicode__(self):
109+
def __str__(self):
112110
"""Convert exception to a string."""
113111
return ("You have used the requests available on your plan. "
114112
"Please purchase more if you wish to continue: https://opencagedata.com/pricing")
115113

116-
__str__ = __unicode__
117-
118114

119115
class NotAuthorizedError(OpenCageGeocodeError):
120116
"""Exception raised when an unauthorized API key is used."""
121117

122-
def __unicode__(self):
118+
def __str__(self):
123119
"""Convert exception to a string."""
124120
return "Your API key is not authorized. You may have entered it incorrectly."
125121

126-
__str__ = __unicode__
127-
128122

129123
class ForbiddenError(OpenCageGeocodeError):
130124
"""Exception raised when a blocked or suspended API key is used."""
131125

132-
def __unicode__(self):
126+
def __str__(self):
133127
"""Convert exception to a string."""
134128
return "Your API key has been blocked or suspended."
135129

136-
__str__ = __unicode__
137-
138130

139131
class AioHttpError(OpenCageGeocodeError):
140132
"""Exception raised for errors related to async HTTP calls with aiohttp."""
@@ -143,14 +135,12 @@ class AioHttpError(OpenCageGeocodeError):
143135
class SSLError(OpenCageGeocodeError):
144136
"""Exception raised when SSL connection to OpenCage server fails."""
145137

146-
def __unicode__(self):
138+
def __str__(self):
147139
"""Convert exception to a string."""
148140
return ("SSL Certificate error connecting to OpenCage API. This is usually due to "
149141
"outdated CA root certificates of the operating system. "
150142
)
151143

152-
__str__ = __unicode__
153-
154144

155145
class NetworkError(OpenCageGeocodeError):
156146
"""Exception raised when the connection to the OpenCage API fails."""
@@ -620,7 +610,7 @@ def floatify_latlng(input_value):
620610
# This dict has only 2 keys 'lat' & 'lon'
621611
return {'lat': float_if_float(input_value["lat"]), 'lng': float_if_float(input_value["lng"])}
622612

623-
return dict((key, floatify_latlng(value)) for key, value in input_value.items())
613+
return {key: floatify_latlng(value) for key, value in input_value.items()}
624614

625615
if isinstance(input_value, collections.abc.MutableSequence):
626616
return [floatify_latlng(x) for x in input_value]

‎test/test_all.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: utf-8
2-
31
from pathlib import Path
42

53
import os

‎test/test_async.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: utf-8
2-
31
import pytest
42

53
from opencage.geocoder import ForbiddenError, OpenCageGeocode, AioHttpError

‎test/test_error_network.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: utf-8
2-
31
import asyncio
42
import os
53
import socket

‎test/test_error_ssl.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: utf-8
2-
31
import ssl
42
import pytest
53
from opencage.geocoder import OpenCageGeocode, SSLError

‎test/test_geocoder_args.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: utf-8
2-
31
import os
42

53
import pytest

‎test/test_headers.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: utf-8
2-
31
from pathlib import Path
42

53
import os

‎test/test_session.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: utf-8
2-
31
from pathlib import Path
42

53
import pytest

0 commit comments

Comments
 (0)