From 3ccc120edff8ca032bad3f171299330047f8bd3d Mon Sep 17 00:00:00 2001 From: Tudor Amariei Date: Mon, 7 Oct 2024 11:01:44 +0300 Subject: [PATCH] Small formatting --- backend/donations/views/admin.py | 2 +- backend/donations/views/donations_download.py | 45 ++++++++++++++++--- backend/donations/views/my_account.py | 2 +- backend/pyproject.toml | 2 +- 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/backend/donations/views/admin.py b/backend/donations/views/admin.py index f9aba350..6e6e3d12 100644 --- a/backend/donations/views/admin.py +++ b/backend/donations/views/admin.py @@ -137,7 +137,7 @@ def get(self, request, ngo_url, *args, **kwargs): "ngo_upload_url": reverse("api-ngo-upload-url"), "counties": settings.FORM_COUNTIES_NATIONAL, "ngo": ngo, - "other_emails": ", ".join(str(x) for x in ngo.other_emails) if ngo.other_emails else "", + "other_emails": (", ".join(str(x) for x in ngo.other_emails) if ngo.other_emails else ""), } try: diff --git a/backend/donations/views/donations_download.py b/backend/donations/views/donations_download.py index 08f0b146..86973c40 100644 --- a/backend/donations/views/donations_download.py +++ b/backend/donations/views/donations_download.py @@ -103,7 +103,11 @@ def _package_donations(tmp_dir_name: str, donations: QuerySet[Donor], ngo: Ngo, file_data = _download_file(source_url) except JobDownloadError: retries_left -= 1 - logger.error("Could not download '%s'. Retries left %d.", source_url, retries_left) + logger.error( + "Could not download '%s'. Retries left %d.", + source_url, + retries_left, + ) except Exception as e: retries_left = 0 logger.error("Could not download '%s'. Exception %s", source_url, e) @@ -283,7 +287,11 @@ def _download_file(source_url: str) -> bytes: def _generate_xml_files( - ngo: Ngo, zip_archive: ZipFile, zip_64_flag: bool, zip_timestamp: datetime, cnp_idx: Dict[str, Dict[str, Any]] + ngo: Ngo, + zip_archive: ZipFile, + zip_64_flag: bool, + zip_timestamp: datetime, + cnp_idx: Dict[str, Dict[str, Any]], ): if not cnp_idx or not ngo or not zip_archive: return @@ -294,7 +302,16 @@ def _generate_xml_files( # create a single XML file if ngo_donations.count() < 2 * settings.DONATIONS_XML_LIMIT_PER_FILE: xml_name: str = "d230.xml" - _build_xml(ngo, ngo_donations, 1, xml_name, cnp_idx, zip_timestamp, zip_archive, zip_64_flag) + _build_xml( + ngo, + ngo_donations, + 1, + xml_name, + cnp_idx, + zip_timestamp, + zip_archive, + zip_64_flag, + ) return @@ -316,7 +333,16 @@ def _generate_donations_by_county(cnp_idx, ngo, ngo_donations, zip_64_flag, zip_ xml_name: str = f"d230_{county_code}.xml" county_donations: QuerySet[Donor] = ngo_donations.filter(county=current_county) - _build_xml(ngo, county_donations, xml_count, xml_name, cnp_idx, zip_timestamp, zip_archive, zip_64_flag) + _build_xml( + ngo, + county_donations, + xml_count, + xml_name, + cnp_idx, + zip_timestamp, + zip_archive, + zip_64_flag, + ) xml_count += 1 else: for i in range(math.ceil(current_county_count / donations_limit)): @@ -325,7 +351,16 @@ def _generate_donations_by_county(cnp_idx, ngo, ngo_donations, zip_64_flag, zip_ county_donations: QuerySet[Donor] = ngo_donations.filter(county=current_county)[ i * donations_limit : (i + 1) * donations_limit ] - _build_xml(ngo, county_donations, xml_count, xml_name, cnp_idx, zip_timestamp, zip_archive, zip_64_flag) + _build_xml( + ngo, + county_donations, + xml_count, + xml_name, + cnp_idx, + zip_timestamp, + zip_archive, + zip_64_flag, + ) xml_count += 1 diff --git a/backend/donations/views/my_account.py b/backend/donations/views/my_account.py index 6c75d4a8..c56cac81 100644 --- a/backend/donations/views/my_account.py +++ b/backend/donations/views/my_account.py @@ -117,7 +117,7 @@ def get(self, request: HttpRequest, *args, **kwargs): current_year_donors: Optional[QuerySet[Donor]] = grouped_donors.get(now.year) donors_metadata = { "total": current_year_donors.count() if current_year_donors else 0, - "total_signed": current_year_donors.filter(has_signed=True).count() if current_year_donors else 0, + "total_signed": (current_year_donors.filter(has_signed=True).count() if current_year_donors else 0), "years": list(grouped_donors.keys()), } diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 4e1a9c6b..5b8a9f8f 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -81,7 +81,7 @@ filterwarnings = [ [tool.black] line-length = 120 -target-version = ["py311"] +target-version = ["py312"] extend-exclude = ''' /( | _appengine_legacy