Skip to content

Commit

Permalink
lint: Fix issues around variable names, type checking and whitespace
Browse files Browse the repository at this point in the history
Fixed a couple of linting issues that were flagged by the newer
version of flake8, specifically using `l` as a variable name,
type checking using `=` rather than `is`, and missing whitespace
after keywords.
  • Loading branch information
chrisarridge committed Aug 13, 2024
1 parent 6df9eb9 commit a4cc52b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions fetch_github_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
issues = json.load(f)
for issue in issues:
awaiting_triage = [
l for l in issue['labels']
if l['name'] == 'awaiting triage']
x for x in issue['labels']
if x['name'] == 'awaiting triage']
if awaiting_triage:
# ignore these
continue
Expand All @@ -38,7 +38,7 @@
'created_at': issue['created_at'],
'updated_at': issue['updated_at'],
'state': issue['state'],
'labels': [l for l in issue['labels'] if not l['name'].startswith('publisher: ')],
'labels': [x for x in issue['labels'] if not x['name'].startswith('publisher: ')],
})
for pub_id, issues in publishers.items():
with open(Path(f'data/github/publishers/{pub_id}.json'), 'w') as f:
Expand Down
2 changes: 1 addition & 1 deletion forwardlooking.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def generate_row(publisher):

# Loop over each of the three years (i.e. this year and the following two years) to generate the statistics for the table
for year in years:
if(len(hierarchies_with_budget_not_provided) > 0):
if (len(hierarchies_with_budget_not_provided) > 0):
row['budget_not_provided'] = True
# If 'forwardlooking_activities_current' and 'forwardlooking_activities_with_budgets' or 'forwardlooking_activities_with_budget_not_provided' are in the bottom hierarchy
if 'forwardlooking_activities_current' in publisher_stats['bottom_hierarchy'] and ('forwardlooking_activities_with_budgets' in publisher_stats['bottom_hierarchy'] or 'forwardlooking_activities_with_budget_not_provided' in publisher_stats['bottom_hierarchy']):
Expand Down
8 changes: 4 additions & 4 deletions plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __getitem__(self, key):


def make_plot(stat_path, git_stats, img_prefix=''):
if type(stat_path) == tuple:
if type(stat_path) is tuple:
stat_name = stat_path[0]
else:
stat_name = stat_path
Expand All @@ -60,7 +60,7 @@ def make_plot(stat_path, git_stats, img_prefix=''):
return
items = sorted(stat_dict.items())
x_values = [datetime.date(int(x[0:4]), int(x[5:7]), int(x[8:10])) for x, y in items]
if type(stat_path) == tuple:
if type(stat_path) is tuple:
y_values = [dict((k, v) for k, v in y.items() if stat_path[1](k)) for x, y in items]
else:
y_values = [float(y) for x, y in items]
Expand All @@ -75,7 +75,7 @@ def make_plot(stat_path, git_stats, img_prefix=''):
dpi = 96
fig.set_size_inches(600.0 / dpi, 600.0 / dpi)

if type(y_values[0]) == dict:
if type(y_values[0]) is dict:
keys = set([tm for y in y_values for tm in y.keys()])
plots = {}
for key in keys:
Expand Down Expand Up @@ -115,7 +115,7 @@ def make_plot(stat_path, git_stats, img_prefix=''):

ax.ticklabel_format(axis='y', style='plain', useOffset=False)

fig.savefig('out/{0}{1}{2}.png'.format(img_prefix, stat_name, stat_path[2] if type(stat_path) == tuple else ''), dpi=dpi)
fig.savefig('out/{0}{1}{2}.png'.format(img_prefix, stat_name, stat_path[2] if type(stat_path) is tuple else ''), dpi=dpi)
plt.close('all')

fn = 'out/{0}{1}.csv'.format(img_prefix, stat_name)
Expand Down

0 comments on commit a4cc52b

Please sign in to comment.