From d14cd8710b7c27b06cdaa49657bbc67a7de232aa Mon Sep 17 00:00:00 2001 From: Alex Parsons Date: Fri, 21 Jun 2024 12:37:12 +0000 Subject: [PATCH] Ruff linting catchup - all blank lines except... - lower case unicode \b in import_air_quality_data --- hub/management/commands/base_importers.py | 2 -- .../commands/import_2024_aid_alliance_power_postcodes.py | 1 - hub/management/commands/import_air_quality_data.py | 5 ++--- hub/management/commands/import_brexit_votes.py | 1 - hub/management/commands/import_brexit_votes_new_cons.py | 1 - hub/management/commands/import_cen_nzsg_members.py | 1 - .../commands/import_christian_aid_campaign_organisers.py | 1 - .../commands/import_christian_aid_group_locations.py | 1 - hub/management/commands/import_council_scorecards_score.py | 1 - hub/management/commands/import_efpc_fuel_poverty_data.py | 1 - hub/management/commands/import_foe_constituency_reports.py | 1 - hub/management/commands/import_foe_supporters.py | 1 - hub/management/commands/import_hftf_trained_constituents.py | 1 - hub/management/commands/import_hnh_polling_data.py | 4 ---- hub/management/commands/import_last_election_data.py | 1 - hub/management/commands/import_mp_job_titles.py | 2 -- hub/management/commands/import_mps_appg_data.py | 1 - hub/management/commands/import_mps_standing_down_2024.py | 1 - hub/management/commands/import_new_constituencies.py | 1 - hub/management/commands/import_nt_property_locations.py | 1 - hub/management/commands/import_onward_polling_data.py | 1 - .../commands/import_red_blue_wall_constituencies.py | 1 - hub/management/commands/import_rspb_nature_reserves.py | 1 - hub/management/commands/import_tcc_open_letter_signatures.py | 1 - hub/management/commands/import_wi_group_locations.py | 1 - hub/management/commands/import_wildlife_trust_reserves.py | 1 - hub/management/commands/import_wildlife_trusts_regions.py | 1 - hub/management/commands/import_wwf_supporters.py | 1 - manage.py | 1 + 29 files changed, 3 insertions(+), 35 deletions(-) diff --git a/hub/management/commands/base_importers.py b/hub/management/commands/base_importers.py index 27be5254f..c65ec10ff 100644 --- a/hub/management/commands/base_importers.py +++ b/hub/management/commands/base_importers.py @@ -312,7 +312,6 @@ class BaseConstituencyGroupListImportCommand(BaseAreaImportCommand): do_not_convert = True def process_data(self, df: pd.DataFrame): - if not self._quiet: self.stdout.write(f"{self.message} ({self.area_type})") @@ -372,7 +371,6 @@ def set_data_type(self): self.data_type = list(self.data_types.values())[0] def get_dataframe(self): - if not self.data_file.exists(): return None diff --git a/hub/management/commands/import_2024_aid_alliance_power_postcodes.py b/hub/management/commands/import_2024_aid_alliance_power_postcodes.py index 2b7687bd1..ab4703630 100644 --- a/hub/management/commands/import_2024_aid_alliance_power_postcodes.py +++ b/hub/management/commands/import_2024_aid_alliance_power_postcodes.py @@ -89,7 +89,6 @@ def add_area(self, gss): return None def get_df(self): - if self.data_file.exists() is False: return None diff --git a/hub/management/commands/import_air_quality_data.py b/hub/management/commands/import_air_quality_data.py index 2b5373317..a42c0a6d4 100644 --- a/hub/management/commands/import_air_quality_data.py +++ b/hub/management/commands/import_air_quality_data.py @@ -62,7 +62,7 @@ class Command(BaseCommand): "pollutant": "NOx", "metric": "Annual mean", "header_label": "nox2021", - "comments": "µg m\u207B\u00B3 (NO\u2093 as NO\u2082)", + "comments": "µg m\u207b\u00b3 (NO\u2093 as NO\u2082)", "csv_link": "https://uk-air.defra.gov.uk/datastore/pcm/mapnox2021.csv", }, "so_2": { @@ -75,7 +75,7 @@ class Command(BaseCommand): "pollutant": "Ozone", "metric": "DGT120", "header_label": "dgt12021", - "comments": "number of days on which the daily max 8-hr concentration is greater than 120 µg m\u207B\u00B3", + "comments": "number of days on which the daily max 8-hr concentration is greater than 120 µg m\u207b\u00b3", "csv_link": "https://uk-air.defra.gov.uk/datastore/pcm/mapdgt12021.csv", }, "benzene": { @@ -155,7 +155,6 @@ def delete_data(self): AreaData.objects.filter(data_type__in=self.data_types).delete() def get_dataframe(self): - if not self.gridcode_lookup_file.exists(): return None diff --git a/hub/management/commands/import_brexit_votes.py b/hub/management/commands/import_brexit_votes.py index 5d785223a..e0f8cc25b 100644 --- a/hub/management/commands/import_brexit_votes.py +++ b/hub/management/commands/import_brexit_votes.py @@ -39,7 +39,6 @@ class Command(BaseImportFromDataFrameCommand): } def get_dataframe(self): - if not self.data_file.exists(): return None diff --git a/hub/management/commands/import_brexit_votes_new_cons.py b/hub/management/commands/import_brexit_votes_new_cons.py index 505f078d7..5c2f15494 100644 --- a/hub/management/commands/import_brexit_votes_new_cons.py +++ b/hub/management/commands/import_brexit_votes_new_cons.py @@ -36,7 +36,6 @@ class Command(BaseImportFromDataFrameCommand): } def get_dataframe(self): - if not self.data_file.exists(): return None diff --git a/hub/management/commands/import_cen_nzsg_members.py b/hub/management/commands/import_cen_nzsg_members.py index 3dcf737dc..463169b68 100644 --- a/hub/management/commands/import_cen_nzsg_members.py +++ b/hub/management/commands/import_cen_nzsg_members.py @@ -16,7 +16,6 @@ def handle(self, quiet=False, *args, **options): self.import_results() def get_df(self): - file_loc = Path("data", "cen_nzsg_members.csv") if not file_loc.exists(): return None diff --git a/hub/management/commands/import_christian_aid_campaign_organisers.py b/hub/management/commands/import_christian_aid_campaign_organisers.py index 44080691e..1bf286680 100644 --- a/hub/management/commands/import_christian_aid_campaign_organisers.py +++ b/hub/management/commands/import_christian_aid_campaign_organisers.py @@ -45,7 +45,6 @@ class Command(BaseImportFromDataFrameCommand): } def get_dataframe(self): - if self.data_file.exists() is False: return None diff --git a/hub/management/commands/import_christian_aid_group_locations.py b/hub/management/commands/import_christian_aid_group_locations.py index 0fdae3b9b..e6ea75051 100644 --- a/hub/management/commands/import_christian_aid_group_locations.py +++ b/hub/management/commands/import_christian_aid_group_locations.py @@ -89,7 +89,6 @@ def build_constituency_name_lookup(self): return names_lookup_dict def get_df(self): - if self.data_file.exists() is False: return None diff --git a/hub/management/commands/import_council_scorecards_score.py b/hub/management/commands/import_council_scorecards_score.py index 8e55046d3..705442861 100644 --- a/hub/management/commands/import_council_scorecards_score.py +++ b/hub/management/commands/import_council_scorecards_score.py @@ -142,7 +142,6 @@ def add_data_sets(self, df): self.data_types[name] = data_type def get_dataframe(self): - if self.data_file.exists() is False: return None diff --git a/hub/management/commands/import_efpc_fuel_poverty_data.py b/hub/management/commands/import_efpc_fuel_poverty_data.py index 03e0c7be7..f86c5b92a 100644 --- a/hub/management/commands/import_efpc_fuel_poverty_data.py +++ b/hub/management/commands/import_efpc_fuel_poverty_data.py @@ -45,7 +45,6 @@ def delete_data(self): ).delete() def get_dataframe(self): - if self.data_file.exists() is False: return None diff --git a/hub/management/commands/import_foe_constituency_reports.py b/hub/management/commands/import_foe_constituency_reports.py index a4a523c0d..22390a8ba 100644 --- a/hub/management/commands/import_foe_constituency_reports.py +++ b/hub/management/commands/import_foe_constituency_reports.py @@ -39,7 +39,6 @@ def get_row_data(self, row, conf): } def get_dataframe(self): - if self.data_file.exists() is False: return None diff --git a/hub/management/commands/import_foe_supporters.py b/hub/management/commands/import_foe_supporters.py index 85e8de191..6a4ceb214 100644 --- a/hub/management/commands/import_foe_supporters.py +++ b/hub/management/commands/import_foe_supporters.py @@ -56,7 +56,6 @@ class Command(BaseImportFromDataFrameCommand): } def get_dataframe(self): - if self.data_file.exists() is False: return None diff --git a/hub/management/commands/import_hftf_trained_constituents.py b/hub/management/commands/import_hftf_trained_constituents.py index 3ed725cd9..7c287b0a8 100644 --- a/hub/management/commands/import_hftf_trained_constituents.py +++ b/hub/management/commands/import_hftf_trained_constituents.py @@ -44,7 +44,6 @@ class Command(BaseImportFromDataFrameCommand): } def get_dataframe(self): - if self.data_file.exists() is False: return None diff --git a/hub/management/commands/import_hnh_polling_data.py b/hub/management/commands/import_hnh_polling_data.py index c52a8c1b0..c1ed8b646 100644 --- a/hub/management/commands/import_hnh_polling_data.py +++ b/hub/management/commands/import_hnh_polling_data.py @@ -347,12 +347,10 @@ def log(self, message): self.stdout.write(message) def extract_and_save_data(self): - self.log(self.message) area_type = self.get_area_type() for file in self.files: - file_loc = settings.BASE_DIR / "data" / file["source_filename"] if not file_loc.exists(): @@ -435,7 +433,6 @@ def delete_data(self): def update_averages(self): self.log("Calculating averages for DataTypes:") for file in self.files: - file_loc = settings.BASE_DIR / "data" / file["source_filename"] if not file_loc.exists(): @@ -469,7 +466,6 @@ def update_averages(self): def update_max_min(self): self.log("Calculating min/max values for DataTypes:") for file in self.files: - file_loc = settings.BASE_DIR / "data" / file["source_filename"] if not file_loc.exists(): diff --git a/hub/management/commands/import_last_election_data.py b/hub/management/commands/import_last_election_data.py index 81437be63..230487d22 100644 --- a/hub/management/commands/import_last_election_data.py +++ b/hub/management/commands/import_last_election_data.py @@ -89,7 +89,6 @@ def get_area_type(self): return AreaType.objects.get(code=self.area_type) def get_general_election_data(self): - df = pd.read_csv( self.general_election_source_file, usecols=[ diff --git a/hub/management/commands/import_mp_job_titles.py b/hub/management/commands/import_mp_job_titles.py index 24df14c12..8512a7a2f 100644 --- a/hub/management/commands/import_mp_job_titles.py +++ b/hub/management/commands/import_mp_job_titles.py @@ -32,7 +32,6 @@ def get_area_type(self): return AreaType.objects.get(code="WMC") def get_df(self): - if not self.data_file.exists(): self.stderr.write(f"Data file {self.data_file} does not exist") return None @@ -109,7 +108,6 @@ def add_results(self, results, data_type): PersonData.objects.filter(data_type=data_type).exclude(pk__in=mp_list).delete() def import_results(self): - df = self.get_df() if df is None: diff --git a/hub/management/commands/import_mps_appg_data.py b/hub/management/commands/import_mps_appg_data.py index d940c0668..a4d0d97e6 100644 --- a/hub/management/commands/import_mps_appg_data.py +++ b/hub/management/commands/import_mps_appg_data.py @@ -54,7 +54,6 @@ def add_mps(self, df): return df def get_climate_appgs(self): - climate_appgs_list = Path("data", "climate_APPGs.txt") if not climate_appgs_list.exists(): diff --git a/hub/management/commands/import_mps_standing_down_2024.py b/hub/management/commands/import_mps_standing_down_2024.py index 135c9400a..c0b021f07 100644 --- a/hub/management/commands/import_mps_standing_down_2024.py +++ b/hub/management/commands/import_mps_standing_down_2024.py @@ -48,7 +48,6 @@ def get_person_from_name(self, name): return None def get_df(self): - if not self.data_file.exists(): self.stderr.write(f"Data file {self.data_file} does not exist") return None diff --git a/hub/management/commands/import_new_constituencies.py b/hub/management/commands/import_new_constituencies.py index c574c3f9e..6cf5040cb 100644 --- a/hub/management/commands/import_new_constituencies.py +++ b/hub/management/commands/import_new_constituencies.py @@ -23,7 +23,6 @@ def add_arguments(self, parser): ) def download_constituencies(self): - source_file = "https://pages.mysociety.org/2025-constituencies/data/parliament_con_2025/latest/parl_constituencies_2025.parquet" parquet_path = settings.BASE_DIR / "data" / "parl_constituencies_2025.parquet" diff --git a/hub/management/commands/import_nt_property_locations.py b/hub/management/commands/import_nt_property_locations.py index 9f3f90d1d..5c5d8780a 100644 --- a/hub/management/commands/import_nt_property_locations.py +++ b/hub/management/commands/import_nt_property_locations.py @@ -81,7 +81,6 @@ def get_df(self) -> Optional[pd.DataFrame]: return pd.read_csv(self.data_file) def process_data(self, df: pd.DataFrame): - # df.group_name = df.group_name.apply( # lambda x: x.split(" | ")[0] if type(x) == str else x # ) diff --git a/hub/management/commands/import_onward_polling_data.py b/hub/management/commands/import_onward_polling_data.py index dbd2c07b0..40d30d724 100644 --- a/hub/management/commands/import_onward_polling_data.py +++ b/hub/management/commands/import_onward_polling_data.py @@ -88,7 +88,6 @@ def build_constituency_name_lookup(self): return names_lookup_dict def get_dataframe(self): - if not self.data_file.exists(): return None diff --git a/hub/management/commands/import_red_blue_wall_constituencies.py b/hub/management/commands/import_red_blue_wall_constituencies.py index 1b2af4ccf..b8975c4f5 100644 --- a/hub/management/commands/import_red_blue_wall_constituencies.py +++ b/hub/management/commands/import_red_blue_wall_constituencies.py @@ -40,7 +40,6 @@ class Command(BaseImportFromDataFrameCommand): } def get_dataframe(self): - if self.data_file.exists() is False: return None diff --git a/hub/management/commands/import_rspb_nature_reserves.py b/hub/management/commands/import_rspb_nature_reserves.py index 8aa7af902..9a44962d8 100644 --- a/hub/management/commands/import_rspb_nature_reserves.py +++ b/hub/management/commands/import_rspb_nature_reserves.py @@ -70,7 +70,6 @@ class Command(MultipleAreaTypesMixin, BaseConstituencyGroupListImportCommand): count_data_type = "rspb_reserves_count" def get_df(self): - if self.data_file.exists() is False: return None diff --git a/hub/management/commands/import_tcc_open_letter_signatures.py b/hub/management/commands/import_tcc_open_letter_signatures.py index a2775eaba..3597cfcc2 100644 --- a/hub/management/commands/import_tcc_open_letter_signatures.py +++ b/hub/management/commands/import_tcc_open_letter_signatures.py @@ -66,7 +66,6 @@ class Command(BaseConstituencyGroupListImportCommand): count_data_type = "tcc_open_letter_signatories_count" def get_df(self): - if self.data_file.exists() is False: return None diff --git a/hub/management/commands/import_wi_group_locations.py b/hub/management/commands/import_wi_group_locations.py index 891154eed..70124f677 100644 --- a/hub/management/commands/import_wi_group_locations.py +++ b/hub/management/commands/import_wi_group_locations.py @@ -78,7 +78,6 @@ class Command(MultipleAreaTypesMixin, BaseConstituencyGroupListImportCommand): count_data_type = "constituency_wi_group_count" def get_df(self): - if self.data_file.exists() is False: return None diff --git a/hub/management/commands/import_wildlife_trust_reserves.py b/hub/management/commands/import_wildlife_trust_reserves.py index 044faab00..602e2977e 100644 --- a/hub/management/commands/import_wildlife_trust_reserves.py +++ b/hub/management/commands/import_wildlife_trust_reserves.py @@ -76,7 +76,6 @@ class Command(MultipleAreaTypesMixin, BaseConstituencyGroupListImportCommand): } def get_df(self): - if self.data_file.exists() is False: return None diff --git a/hub/management/commands/import_wildlife_trusts_regions.py b/hub/management/commands/import_wildlife_trusts_regions.py index 542049e13..8bcdb3626 100644 --- a/hub/management/commands/import_wildlife_trusts_regions.py +++ b/hub/management/commands/import_wildlife_trusts_regions.py @@ -39,7 +39,6 @@ class Command(BaseConstituencyGroupListImportCommand): group_data_type = "wildlife_trusts_regions" def get_df(self): - if not self.data_file.exists(): return None diff --git a/hub/management/commands/import_wwf_supporters.py b/hub/management/commands/import_wwf_supporters.py index 21e3578d0..ee1f8da08 100644 --- a/hub/management/commands/import_wwf_supporters.py +++ b/hub/management/commands/import_wwf_supporters.py @@ -39,7 +39,6 @@ class Command(BaseImportFromDataFrameCommand): } def get_dataframe(self): - if self.data_file.exists() is False: return None diff --git a/manage.py b/manage.py index 502b9fc20..941d762e6 100755 --- a/manage.py +++ b/manage.py @@ -1,5 +1,6 @@ #!/usr/bin/env python """Django's command-line utility for administrative tasks.""" + import os import sys