From d71e8c4a70b2be70be3342baaee1c884f7bd7ea2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:41:11 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.3.2) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cb44ee0..1f745a7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: language: fail files: "\\.rej$" - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.2.2' + rev: 'v0.3.2' hooks: - id: ruff args: [ --fix, --exit-non-zero-on-fix ] From f283c70e12fdf289d4761d376a7d28eebb7d1770 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:41:20 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- climate_categories/_categories.py | 6 +++--- climate_categories/_conversions.py | 13 ++++++------- climate_categories/tests/test_iso3.py | 1 + data_generation/BURDI.py | 1 + data_generation/BURDI_class.py | 4 ++-- data_generation/CRFDI.py | 1 + data_generation/CRFDI_class.py | 4 ++-- data_generation/IPCC2006.py | 12 ++++++------ data_generation/IPCC2006_PRIMAP.py | 1 + data_generation/ISO3.py | 1 + data_generation/ISO3_GCAM.py | 1 + update_changelog.py | 7 ++++--- 12 files changed, 29 insertions(+), 23 deletions(-) diff --git a/climate_categories/_categories.py b/climate_categories/_categories.py index 99b106e..c1eb9c4 100644 --- a/climate_categories/_categories.py +++ b/climate_categories/_categories.py @@ -762,9 +762,9 @@ def to_spec(self) -> dict[str, typing.Any]: spec["version"] = self.version spec["total_sum"] = self.total_sum if self.canonical_top_level_category is not None: - spec[ - "canonical_top_level_category" - ] = self.canonical_top_level_category.codes[0] + spec["canonical_top_level_category"] = ( + self.canonical_top_level_category.codes[0] + ) spec["categories"] = {} for cat in self.values(): diff --git a/climate_categories/_conversions.py b/climate_categories/_conversions.py index d01319a..4cedc30 100644 --- a/climate_categories/_conversions.py +++ b/climate_categories/_conversions.py @@ -1,4 +1,5 @@ """Classes to represent conversions between categorizations.""" + import csv import dataclasses import datetime @@ -66,9 +67,9 @@ def hydrate( auxiliary_categories_hydrated = {} for aux_categorization_name, categories in self.auxiliary_categories.items(): aux_categorization = cats[aux_categorization_name] - auxiliary_categories_hydrated[ - aux_categorization - ] = self._hydrate_handle_errors(categories, aux_categorization) + auxiliary_categories_hydrated[aux_categorization] = ( + self._hydrate_handle_errors(categories, aux_categorization) + ) return ConversionRule( factors_categories_a=self._hydrate_handle_errors( @@ -86,14 +87,12 @@ def hydrate( @typing.overload def _hydrate_handle_errors( self, to_hydrate: dict[str, int], categorization: "Categorization" - ) -> dict["Category", int]: - ... + ) -> dict["Category", int]: ... @typing.overload def _hydrate_handle_errors( self, to_hydrate: set[str], categorization: "Categorization" - ) -> set["Category"]: - ... + ) -> set["Category"]: ... def _hydrate_handle_errors( self, diff --git a/climate_categories/tests/test_iso3.py b/climate_categories/tests/test_iso3.py index 8181836..c9c8b8d 100644 --- a/climate_categories/tests/test_iso3.py +++ b/climate_categories/tests/test_iso3.py @@ -1,4 +1,5 @@ """Tests for the 'ISO3' categorization.""" + import pytest import climate_categories diff --git a/data_generation/BURDI.py b/data_generation/BURDI.py index 915deb4..858b99a 100644 --- a/data_generation/BURDI.py +++ b/data_generation/BURDI.py @@ -1,4 +1,5 @@ """Run this via `make climate_categories/data/BURDI.yaml` in the main directory.""" + import pathlib import natsort diff --git a/data_generation/BURDI_class.py b/data_generation/BURDI_class.py index 35c8bfc..eab165d 100644 --- a/data_generation/BURDI_class.py +++ b/data_generation/BURDI_class.py @@ -1,5 +1,5 @@ -"""Run this via `make climate_categories/data/BURDI_class.yaml` in the main directory. -""" +"""Run this via `make climate_categories/data/BURDI_class.yaml` in the main directory.""" + import datetime import pathlib diff --git a/data_generation/CRFDI.py b/data_generation/CRFDI.py index 1aa80f6..f7b5c68 100644 --- a/data_generation/CRFDI.py +++ b/data_generation/CRFDI.py @@ -1,4 +1,5 @@ """Run this via `make climate_categories/data/CRFDI.yaml` in the main directory.""" + import pathlib import natsort diff --git a/data_generation/CRFDI_class.py b/data_generation/CRFDI_class.py index 005be52..3c4be1a 100644 --- a/data_generation/CRFDI_class.py +++ b/data_generation/CRFDI_class.py @@ -1,5 +1,5 @@ -"""Run this via `make climate_categories/data/CRFDI_class.yaml` in the main directory. -""" +"""Run this via `make climate_categories/data/CRFDI_class.yaml` in the main directory.""" + import datetime import pathlib diff --git a/data_generation/IPCC2006.py b/data_generation/IPCC2006.py index dea32be..73a62ef 100644 --- a/data_generation/IPCC2006.py +++ b/data_generation/IPCC2006.py @@ -231,13 +231,13 @@ def main(): ] categories["3.B.3.a"]["title"] = "Grassland Remaining Grassland" - categories["3.B.3.a"][ - "comment" - ] = "Emissions and removals from grassland remaining grassland." + categories["3.B.3.a"]["comment"] = ( + "Emissions and removals from grassland remaining grassland." + ) - categories["3.B.3.b"][ - "comment" - ] = "Emissions and removals from land converted to grassland." + categories["3.B.3.b"]["comment"] = ( + "Emissions and removals from land converted to grassland." + ) categories["3.B.3.b"]["info"]["corresponding_categories_IPCC1996"] = [ "5B", "5C", diff --git a/data_generation/IPCC2006_PRIMAP.py b/data_generation/IPCC2006_PRIMAP.py index f9e5cb5..b28a151 100644 --- a/data_generation/IPCC2006_PRIMAP.py +++ b/data_generation/IPCC2006_PRIMAP.py @@ -1,5 +1,6 @@ """Run this via `make climate_categories/data/IPCC2006_PRIMAP.yaml` in the main directory.""" + import datetime import pathlib diff --git a/data_generation/ISO3.py b/data_generation/ISO3.py index b192d76..5095324 100644 --- a/data_generation/ISO3.py +++ b/data_generation/ISO3.py @@ -1,4 +1,5 @@ """Run this via `make climate_categories/data/ISO3.yaml` in the main directory.""" + import pathlib import typing diff --git a/data_generation/ISO3_GCAM.py b/data_generation/ISO3_GCAM.py index 21cdb51..49adb2b 100644 --- a/data_generation/ISO3_GCAM.py +++ b/data_generation/ISO3_GCAM.py @@ -1,5 +1,6 @@ """Run this via `make climate_categories/data/ISO3_GCAM.yaml` in the main directory.""" + import datetime import pathlib diff --git a/update_changelog.py b/update_changelog.py index 617447b..37a5c6e 100644 --- a/update_changelog.py +++ b/update_changelog.py @@ -8,9 +8,10 @@ with open("CHANGELOG.rst") as fd: old_content = fd.read().splitlines(keepends=True) -with open("CHANGELOG.rst", "w") as fd, open( - ".changelog_latest_version.rst", "w" -) as lfd: +with ( + open("CHANGELOG.rst", "w") as fd, + open(".changelog_latest_version.rst", "w") as lfd, +): # Write header fd.writelines(old_content[:4])