Skip to content

Commit

Permalink
Merge pull request #132 from pik-primap/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
mikapfl authored Mar 13, 2024
2 parents 795bed8 + f283c70 commit 52a9361
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down
6 changes: 3 additions & 3 deletions climate_categories/_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
13 changes: 6 additions & 7 deletions climate_categories/_conversions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Classes to represent conversions between categorizations."""

import csv
import dataclasses
import datetime
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions climate_categories/tests/test_iso3.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for the 'ISO3' categorization."""

import pytest

import climate_categories
Expand Down
1 change: 1 addition & 0 deletions data_generation/BURDI.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Run this via `make climate_categories/data/BURDI.yaml` in the main directory."""

import pathlib

import natsort
Expand Down
4 changes: 2 additions & 2 deletions data_generation/BURDI_class.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions data_generation/CRFDI.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Run this via `make climate_categories/data/CRFDI.yaml` in the main directory."""

import pathlib

import natsort
Expand Down
4 changes: 2 additions & 2 deletions data_generation/CRFDI_class.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
12 changes: 6 additions & 6 deletions data_generation/IPCC2006.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions data_generation/IPCC2006_PRIMAP.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Run this via `make climate_categories/data/IPCC2006_PRIMAP.yaml` in the main
directory."""

import datetime
import pathlib

Expand Down
1 change: 1 addition & 0 deletions data_generation/ISO3.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Run this via `make climate_categories/data/ISO3.yaml` in the main directory."""

import pathlib
import typing

Expand Down
1 change: 1 addition & 0 deletions data_generation/ISO3_GCAM.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Run this via `make climate_categories/data/ISO3_GCAM.yaml` in the main
directory."""

import datetime
import pathlib

Expand Down
7 changes: 4 additions & 3 deletions update_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down

0 comments on commit 52a9361

Please sign in to comment.