Skip to content

Commit 61630a2

Browse files
committed
MAINT: Upgrade to Python 3.8
1 parent 209310e commit 61630a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+113
-127
lines changed

docs/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
#
43
# pandas-datareader documentation build configuration file, created by
54
# sphinx-quickstart on Thu Jan 18 13:34:14 2018.

pandas_datareader/av/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(
2929
session=None,
3030
api_key=None,
3131
):
32-
super(AlphaVantage, self).__init__(
32+
super().__init__(
3333
symbols=symbols,
3434
start=start,
3535
end=end,

pandas_datareader/av/forex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AVForexReader(AlphaVantage):
3030
def __init__(
3131
self, symbols=None, retry_count=3, pause=0.1, session=None, api_key=None
3232
):
33-
super(AVForexReader, self).__init__(
33+
super().__init__(
3434
symbols=symbols,
3535
start=None,
3636
end=None,
@@ -79,7 +79,7 @@ def read(self):
7979
"from_currency": self.from_curr[pair],
8080
"to_currency": self.to_curr[pair],
8181
}
82-
data = super(AVForexReader, self).read()
82+
data = super().read()
8383
result.append(data)
8484
df = pd.concat(result, axis=1)
8585
df.columns = self.symbols

pandas_datareader/av/quotes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(
3636
raise ValueError("Up to 100 symbols at once are allowed.")
3737
else:
3838
syms = symbols
39-
super(AVQuotesReader, self).__init__(
39+
super().__init__(
4040
symbols=syms,
4141
start=None,
4242
end=None,

pandas_datareader/av/time_series.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(
5555
api_key=None,
5656
):
5757
self._func = function
58-
super(AVTimeSeriesReader, self).__init__(
58+
super().__init__(
5959
symbols=symbols,
6060
start=start,
6161
end=end,
@@ -111,7 +111,7 @@ def params(self):
111111
return p
112112

113113
def _read_lines(self, out):
114-
data = super(AVTimeSeriesReader, self)._read_lines(out)
114+
data = super()._read_lines(out)
115115
# reverse since alphavantage returns descending by date
116116
data = data[::-1]
117117
start_str = self.start.strftime("%Y-%m-%d")

pandas_datareader/bankofcanada.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import unicode_literals
2-
31
from pandas_datareader.base import _BaseReader
42

53

@@ -18,7 +16,7 @@ def url(self):
1816
if not isinstance(self.symbols, str):
1917
raise ValueError("data name must be string")
2018

21-
return "{0}/{1}/csv".format(self._URL, self.symbols)
19+
return f"{self._URL}/{self.symbols}/csv"
2220

2321
@property
2422
def params(self):

pandas_datareader/base.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
)
1717

1818

19-
class _BaseReader(object):
19+
class _BaseReader:
2020
"""
2121
Parameters
2222
----------
@@ -114,7 +114,7 @@ def _read_url_as_StringIO(self, url, params=None):
114114
out = StringIO()
115115
if len(text) == 0:
116116
service = self.__class__.__name__
117-
raise IOError(
117+
raise OSError(
118118
"{} request returned no data; check URL for invalid "
119119
"inputs: {}".format(service, self.url)
120120
)
@@ -167,9 +167,9 @@ def _get_response(self, url, params=None, headers=None):
167167

168168
if params is not None and len(params) > 0:
169169
url = url + "?" + urlencode(params)
170-
msg = "Unable to read URL: {0}".format(url)
170+
msg = f"Unable to read URL: {url}"
171171
if last_response_text:
172-
msg += "\nResponse Text:\n{0}".format(last_response_text)
172+
msg += f"\nResponse Text:\n{last_response_text}"
173173

174174
raise RemoteDataError(msg)
175175

@@ -226,7 +226,7 @@ def __init__(
226226
session=None,
227227
chunksize=25,
228228
):
229-
super(_DailyBaseReader, self).__init__(
229+
super().__init__(
230230
symbols=symbols,
231231
start=start,
232232
end=end,
@@ -260,7 +260,7 @@ def _dl_mult_symbols(self, symbols):
260260
try:
261261
stocks[sym] = self._read_one_data(self.url, self._get_params(sym))
262262
passed.append(sym)
263-
except (IOError, KeyError):
263+
except (OSError, KeyError):
264264
msg = "Failed to read symbol: {0!r}, replacing with NaN."
265265
warnings.warn(msg.format(sym), SymbolWarning, stacklevel=2)
266266
failed.append(sym)
@@ -294,7 +294,7 @@ class _OptionBaseReader(_BaseReader):
294294
def __init__(self, symbol, session=None):
295295
"""Instantiates options_data with a ticker saved as symbol"""
296296
self.symbol = symbol.upper()
297-
super(_OptionBaseReader, self).__init__(symbols=symbol, session=session)
297+
super().__init__(symbols=symbol, session=session)
298298

299299
def get_options_data(self, month=None, year=None, expiry=None):
300300
"""

pandas_datareader/econdb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050
session=None,
5151
freq=None,
5252
):
53-
super(EcondbReader, self).__init__(
53+
super().__init__(
5454
symbols=symbols,
5555
start=start,
5656
end=end,
@@ -71,7 +71,7 @@ def url(self):
7171
if not isinstance(self.symbols, str):
7272
raise ValueError("data name must be string")
7373

74-
return "{0}?{1}&format=json&page_size=500&expand=both".format(
74+
return "{}?{}&format=json&page_size=500&expand=both".format(
7575
self._URL, self.symbols
7676
)
7777

pandas_datareader/enigma.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(
5555
):
5656
raise ImmediateDeprecationError(DEP_ERROR_MSG.format("Enigma"))
5757

58-
super(EnigmaReader, self).__init__(
58+
super().__init__(
5959
symbols=[], retry_count=retry_count, pause=pause, session=session
6060
)
6161
if api_key is None:
@@ -78,7 +78,7 @@ def __init__(
7878
)
7979

8080
headers = {
81-
"Authorization": "Bearer {0}".format(self._api_key),
81+
"Authorization": f"Bearer {self._api_key}",
8282
"User-Agent": "pandas-datareader",
8383
}
8484
self.session.headers.update(headers)
@@ -101,7 +101,7 @@ def _read(self):
101101

102102
def _get(self, url):
103103
"""HTTP GET Request with Retry Logic"""
104-
url = "{0}/{1}".format(self._base_url, url)
104+
url = f"{self._base_url}/{url}"
105105
attempts = 0
106106
while True:
107107
try:
@@ -125,12 +125,12 @@ def get_dataset_metadata(self, dataset_id):
125125
"""Get the Dataset Model of this EnigmaReader's dataset
126126
https://docs.public.enigma.com/resources/dataset/index.html
127127
"""
128-
url = "datasets/{0}?row_limit=0".format(dataset_id)
128+
url = f"datasets/{dataset_id}?row_limit=0"
129129
response = self._get(url)
130130
return response.json()
131131

132132
def get_snapshot_export(self, snapshot_id):
133133
"""Return raw CSV of a dataset"""
134-
url = "export/{0}".format(snapshot_id)
134+
url = f"export/{snapshot_id}"
135135
response = self._get(url)
136136
return response.content

pandas_datareader/eurostat.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import unicode_literals
2-
31
import pandas as pd
42

53
from pandas_datareader.base import _BaseReader
@@ -26,7 +24,7 @@ def dsd_url(self):
2624
if not isinstance(self.symbols, str):
2725
raise ValueError("data name must be string")
2826

29-
return "{0}/datastructure/ESTAT/DSD_{1}".format(self._URL, self.symbols)
27+
return f"{self._URL}/datastructure/ESTAT/DSD_{self.symbols}"
3028

3129
def _read_one_data(self, url, params):
3230
resp_dsd = self._get_response(self.dsd_url)

0 commit comments

Comments
 (0)