From a4cc52b2b25f1f9ed4162f99309b5e994aa79264 Mon Sep 17 00:00:00 2001 From: Chris Arridge Date: Tue, 13 Aug 2024 13:37:07 +0100 Subject: [PATCH] lint: Fix issues around variable names, type checking and whitespace 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. --- fetch_github_issues.py | 6 +++--- forwardlooking.py | 2 +- plots.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fetch_github_issues.py b/fetch_github_issues.py index 121262c9d..5266c5170 100644 --- a/fetch_github_issues.py +++ b/fetch_github_issues.py @@ -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 @@ -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: diff --git a/forwardlooking.py b/forwardlooking.py index b8f752498..81301a516 100644 --- a/forwardlooking.py +++ b/forwardlooking.py @@ -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']): diff --git a/plots.py b/plots.py index 9090c6093..aaa69948f 100644 --- a/plots.py +++ b/plots.py @@ -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 @@ -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] @@ -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: @@ -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)