Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit 4c0366c

Browse files
committed
Fix most flake8 errors
1 parent 0e5918e commit 4c0366c

12 files changed

Lines changed: 26 additions & 43 deletions

elex/api/delegates.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,10 @@ def get_report_id(self, reports, key):
203203
"""
204204

205205
for report in reports:
206-
if (
207-
key == 'delSum' and
208-
report.get('title') == 'Delegates / delsum'
209-
) or (
210-
key == 'delSuper' and
211-
report.get('title') == 'Delegates / delsuper'
212-
):
206+
delsum = key == 'delSum' and report.get('title') == 'Delegates / delsum'
207+
delsuper = key == 'delSuper' and report.get('title') == 'Delegates / delsuper'
208+
209+
if delsum or delsuper:
213210
id = report.get('id').rsplit('/', 1)[-1]
214211
return id
215212

elex/api/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ def set_id_field(self):
894894
self.id = self.electiondate
895895

896896
def get(self, path, **params):
897-
"""
897+
r"""
898898
Farms out request to api_request.
899899
Could possibly handle choosing which
900900
parser backend to use -- API-only right now.
@@ -947,7 +947,7 @@ def get_uniques(self, candidate_reporting_units):
947947
return candidates, ballot_measures
948948

949949
def get_raw_races(self, **params):
950-
"""
950+
r"""
951951
Convenience method for fetching races by election date.
952952
Accepts an AP formatting date string, e.g., YYYY-MM-DD.
953953
Accepts any number of URL params as kwargs.

elex/api/trends.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@ def get_report_id(self, reports, key):
105105
organization-specific report ID.
106106
"""
107107
for report in reports:
108-
if (
109-
key == self.office_code and
110-
report.get('title') in [self.api_report_id, self.api_test_report_id]
111-
):
108+
if (key == self.office_code and report.get('title') in [self.api_report_id, self.api_test_report_id]):
112109
id = report.get('id').rsplit('/', 1)[-1]
113110
return id
114111
return None

elex/api/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def write_recording(payload):
6969

7070

7171
def api_request(path, **params):
72-
"""
72+
r"""
7373
Function wrapping Python-requests
7474
for making a request to the AP's
7575
elections API.

elex/cli/app.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,7 @@ def delegates(self):
360360
361361
"""
362362
self.app.log.info('Getting delegate reports')
363-
if (
364-
self.app.pargs.delegate_super_file and
365-
self.app.pargs.delegate_sum_file
366-
):
363+
if (self.app.pargs.delegate_super_file and self.app.pargs.delegate_sum_file):
367364
report = DelegateReport(
368365
delsuper_datafile=self.app.pargs.delegate_super_file,
369366
delsum_datafile=self.app.pargs.delegate_sum_file

elex/cli/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def decorated(self):
5757
self.app.log.error('HTTP Error {0} - {1}'.format(e.response.status_code, message))
5858
self.app.log.debug('HTTP Error {0} ({1})'.format(e.response.status_code, e.response.url))
5959
self.app.close(1)
60-
except APAPIKeyException as e:
60+
except APAPIKeyException:
6161
text = 'APAPIKeyError: AP_API_KEY environment variable is not set.'
6262
self.app.log.error(text)
6363
self.app.close(1)

elex/cli/hooks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ def add_election_hook(app):
3838
app.close(1)
3939
else:
4040
app.election.officeids = app.pargs.officeids
41-
# kept as a comma-delimited string so officeID as a param always appears once in request url (e.g. officeID=P%2CH%2CG)
41+
# kept as a comma-delimited string so officeID as a param always appears once in request url
42+
# (e.g. officeID=P%2CH%2CG)
4243

4344

4445
def cachecontrol_logging_hook(app):

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
universal = 1
33

44
[flake8]
5-
max-line-length = 119
5+
max-line-length = 135
66
ignore = E731
77

88
[metadata]

tests/test_ap_network.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import unittest
3-
import tests
43

54
from elex.cli.app import ElexApp
65
from requests.exceptions import HTTPError

tests/test_candidate_reporting_unit.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ def test_candidate_reporting_unit_sums_reportingunit_pct(self):
135135
reporting_unit = self.reporting_units[0]
136136
candidate_reporting_units = self.candidate_reporting_units[0:2]
137137
self.assertEqual(
138-
(
139-
candidate_reporting_units[0].votecount /
140-
float(reporting_unit.votecount)
141-
),
138+
(candidate_reporting_units[0].votecount / float(reporting_unit.votecount)),
142139
0.694266390666554
143140
)
144141

0 commit comments

Comments
 (0)