Skip to content

Commit 6572ed4

Browse files
committed
MAINT: Restore flake8
Restore flake8 tests to improve code quality
1 parent aaaa4ed commit 6572ed4

File tree

12 files changed

+49
-14
lines changed

12 files changed

+49
-14
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
- [ ] closes #xxxx
22
- [ ] tests added / passed
3+
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
34
- [ ] passes `black --check pandas_datareader`
45
- [ ] added entry to docs/source/whatsnew/vLATEST.txt

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ script:
4848
- if [[ -n "${TEST_TYPE+x}" ]]; then export MARKERS="-m ${TEST_TYPE}"; fi
4949
- pytest -v -s -r xX "${MARKERS}" --cov-config .coveragerc --cov=pandas_datareader --cov-report xml:/tmp/cov-datareader.xml --junitxml=/tmp/datareader.xml
5050
- |
51-
if [[ "$TRAVIS_PYTHON_VERSION" -gt 3.5 ]]; then
51+
if (( $(echo "$TRAVIS_PYTHON_VERSION > 3.5" | bc -l) )); then
5252
black --check pandas_datareader
5353
fi
54+
- flake8 --version
55+
- flake8 pandas_datareader
5456

5557
after_script:
5658
- |

ci/pypi-install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env bash
22

33
pip install pip --upgrade
4-
pip install numpy=="$NUMPY" pytz python-dateutil coverage setuptools html5lib lxml pytest pytest-cov wrapt codecov coveralls beautifulsoup4 isort
4+
pip install numpy=="$NUMPY" pytz python-dateutil coverage setuptools html5lib lxml pytest pytest-cov wrapt codecov coveralls beautifulsoup4 isort flake8
55

6-
if [[ "$TRAVIS_PYTHON_VERSION" != 2.7 ]]; then
7-
pip install black
6+
if (( $(echo "$TRAVIS_PYTHON_VERSION > 3.5" | bc -l) )); then
7+
pip install black flake8-bugbear
88
fi
99

1010
if [[ "$PANDAS" == "MASTER" ]]; then

pandas_datareader/_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def versions_from_parentdir(parentdir_prefix, root, verbose):
116116
"""
117117
rootdirs = []
118118

119-
for i in range(3):
119+
for _ in range(3):
120120
dirname = os.path.basename(root)
121121
if dirname.startswith(parentdir_prefix):
122122
return {
@@ -524,7 +524,7 @@ def get_versions():
524524
# versionfile_source is the relative path from the top of the source
525525
# tree (where the .git directory might live) to this file. Invert
526526
# this to find the root from __file__.
527-
for i in cfg.versionfile_source.split("/"):
527+
for _ in cfg.versionfile_source.split("/"):
528528
root = os.path.dirname(root)
529529
except NameError:
530530
return {

pandas_datareader/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def _get_response(self, url, params=None, headers=None):
144144
# initial attempt + retry
145145
pause = self.pause
146146
last_response_text = ""
147-
for i in range(self.retry_count + 1):
147+
for _ in range(self.retry_count + 1):
148148
response = self.session.get(url, params=params, headers=headers)
149149
if response.status_code == requests.codes.ok:
150150
return response

pandas_datareader/compat/__init__.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@
1515
PANDAS_0230 = PANDAS_VERSION >= LooseVersion("0.23.0")
1616

1717

18+
__all__ = [
19+
"HTTPError",
20+
"StringIO",
21+
"PANDAS_0210",
22+
"PANDAS_0220",
23+
"PANDAS_0230",
24+
"get_filepath_or_buffer",
25+
"str_to_bytes",
26+
"string_types",
27+
"assert_frame_equal",
28+
"is_list_like",
29+
"is_number",
30+
"lmap",
31+
"lrange",
32+
"concat",
33+
]
34+
35+
1836
def get_filepath_or_buffer(filepath_or_buffer, encoding=None, compression=None):
1937

2038
# Dictionaries are no longer considered valid inputs
@@ -48,7 +66,7 @@ def bytes_to_str(b, encoding=None):
4866

4967
reduce = reduce
5068
binary_type = str
51-
string_types = (basestring,)
69+
string_types = (basestring,) # noqa: F821
5270

5371
def bytes_to_str(b, encoding=None):
5472
return b

pandas_datareader/data.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Module contains tools for collecting data from various remote sources
33
"""
44

5+
# flake8: noqa
6+
57
import warnings
68

79
from pandas_datareader.av.forex import AVForexReader

pandas_datareader/moex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def read(self):
138138
urls = self.url # generate urls per symbols
139139
dfs = [] # an array of pandas dataframes per symbol to concatenate
140140

141-
for i, symbol in enumerate(self.symbols):
141+
for i in range(len(self.symbols)):
142142
out_list = []
143143
date_column = None
144144

pandas_datareader/tests/io/test_jsdmx.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ def test_land_use(dirpath):
150150

151151
@pytest.mark.skipif(not PANDAS_0210, reason="Broken on old pandas")
152152
def test_quartervalue(dirpath):
153-
# https://stats.oecd.org/sdmx-json/data/QNA/AUS+AUT+BEL+CAN+CHL.GDP+B1_GE.CUR+VOBARSA.Q/all?startTime=2009-Q1&endTime=2011-Q4
153+
# https://stats.oecd.org/sdmx-json/data/QNA/AUS+AUT+BEL+CAN+CHL.GDP+B1_
154+
# GE.CUR+VOBARSA.Q/all?startTime=2009-Q1&endTime=2011-Q4
154155
result = read_jsdmx(os.path.join(dirpath, "jsdmx", "oecd1.json"))
155156
assert isinstance(result, pd.DataFrame)
156157
expected = pd.DatetimeIndex(

pandas_datareader/tests/yahoo/test_options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def data1(aapl, json1):
6969

7070

7171
class TestYahooOptions(object):
72+
@classmethod
7273
def setup_class(cls):
7374
pytest.skip("Skip all Yahoo! tests.")
7475

0 commit comments

Comments
 (0)