Skip to content

Commit bac7c15

Browse files
Chore: Bump osc-ingest-tools version (#554)
Signed-off-by: Matthew Watkins <[email protected]>
1 parent c45c3cf commit bac7c15

10 files changed

+114
-42
lines changed

.pre-commit-config.yaml

+52-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
2+
# SPDX-License-Identifier: Apache-2.0
3+
# SPDX-FileCopyrightText: 2024 The Linux Foundation
4+
25
ci:
3-
autofix_commit_msg: "Chore: pre-commit autoupdate"
6+
autofix_commit_msg: "Chore: pre-commit.ci automated update"
47

58
exclude: |
69
(?x)^(
@@ -9,37 +12,52 @@ exclude: |
912
)$
1013
1114
repos:
12-
1315
- repo: https://github.com/pre-commit/pre-commit-hooks
1416
rev: v5.0.0
1517
hooks:
1618
- id: check-added-large-files
19+
- id: check-ast
20+
- id: check-builtin-literals
1721
- id: check-case-conflict
22+
- id: check-docstring-first
1823
- id: check-executables-have-shebangs
24+
- id: check-illegal-windows-names
1925
- id: check-json
2026
- id: check-merge-conflict
2127
- id: check-shebang-scripts-are-executable
2228
- id: check-symlinks
2329
- id: check-toml
24-
# - id: detect-aws-credentials
30+
- id: check-vcs-permalinks
2531
- id: check-xml
2632
- id: check-yaml
33+
- id: debug-statements
34+
- id: destroyed-symlinks
35+
- id: detect-aws-credentials
36+
args: ["--allow-missing-credentials"]
37+
# - id: double-quote-string-fixer
2738
- id: detect-private-key
2839
- id: end-of-file-fixer
29-
# - id: mixed-line-ending
30-
# args: ["--fix=lf"]
40+
- id: file-contents-sorter
41+
- id: fix-byte-order-marker
42+
- id: forbid-new-submodules
43+
- id: forbid-submodules
44+
- id: mixed-line-ending
45+
args: ["--fix=lf"]
3146
- id: name-tests-test
3247
args: ["--pytest-test-first"]
3348
- id: no-commit-to-branch
3449
# - id: pretty-format-json
3550
- id: requirements-txt-fixer
51+
- id: sort-simple-yaml
52+
# Without specifying files, the above is inactive
53+
# files: ^config/simple/
54+
- id: trailing-whitespace
3655

3756
- repo: https://github.com/pre-commit/mirrors-prettier
3857
rev: v4.0.0-alpha.8
3958
hooks:
4059
- id: prettier
41-
args:
42-
['--no-error-on-unmatched-pattern', '--ignore-unknown']
60+
args: ["--no-error-on-unmatched-pattern", "--ignore-unknown"]
4361

4462
- repo: https://github.com/igorshubovych/markdownlint-cli
4563
rev: v0.44.0
@@ -51,6 +69,7 @@ repos:
5169
rev: v0.19.1
5270
hooks:
5371
- id: gitlint
72+
args: ["-c body-max-line-length=120", "-c title-max-length=120"]
5473

5574
- repo: https://github.com/openstack/bashate
5675
rev: 2.1.1
@@ -62,7 +81,7 @@ repos:
6281
rev: v0.10.0.1
6382
hooks:
6483
- id: shellcheck
65-
args: ["-x"] # Check external files
84+
args: ["-x"] # Check external files
6685

6786
- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
6887
rev: v1.7.7.23
@@ -73,9 +92,12 @@ repos:
7392
rev: v1.35.1
7493
hooks:
7594
- id: yamllint
95+
types: [yaml]
7696
args:
77-
["-d", "{rules: {line-length: {max: 120}},
78-
ignore-from-file: [.gitignore],}"]
97+
[
98+
"-d",
99+
"{rules: {line-length: {max: 100}}, ignore-from-file: [.gitignore],}",
100+
]
79101

80102
- repo: https://github.com/astral-sh/ruff-pre-commit
81103
rev: v0.9.9
@@ -90,8 +112,14 @@ repos:
90112
name: "create mypy cache"
91113
language: system
92114
pass_filenames: false
93-
entry: bash -c 'if [ ! -d .mypy_cache ];
94-
then /bin/mkdir .mypy_cache; fi; exit 0'
115+
entry: bash -c 'if [ ! -d .mypy_cache ]; then /bin/mkdir .mypy_cache; fi; exit 0'
116+
117+
- repo: https://github.com/abravalheri/validate-pyproject
118+
rev: v0.23
119+
hooks:
120+
- id: validate-pyproject
121+
# Optional extra validations from SchemaStore:
122+
additional_dependencies: ["validate-pyproject-schema-store[all]"]
95123

96124
- repo: https://github.com/pre-commit/mirrors-mypy
97125
rev: "v1.15.0"
@@ -101,17 +129,26 @@ repos:
101129
args: ["--show-error-codes", "--install-types", "--non-interactive"]
102130
additional_dependencies: ["pytest", "types-requests"]
103131

104-
# yamllint disable rule:comments-indentation
132+
# - repo: https://github.com/fsfe/reuse-tool
133+
# rev: v5.0.2
134+
# hooks:
135+
# - id: reuse
136+
137+
# - repo: https://github.com/btford/write-good
138+
# rev: ab66ce10136dfad5146e69e70f82a3efac8842c1 # frozen: v1.0.8
139+
# hooks:
140+
# - id: write-good
141+
# files: "\\.(rst|md|markdown|mdown|mkdn)$"
142+
105143
# Check for misspellings in documentation files
106144
# - repo: https://github.com/codespell-project/codespell
107145
# rev: v2.2.2
108146
# hooks:
109-
# - id: codespell
147+
# - id: codespell
110148

111149
# Automatically upgrade Python syntax for newer versions
112150
# - repo: https://github.com/asottile/pyupgrade
113151
# rev: v3.15.0
114152
# hooks:
115153
# - id: pyupgrade
116154
# args: ['--py37-plus']
117-
# yamllint enable rule:comments-indentation

pyproject.toml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[project]
22
name = "ITR"
3-
version = "v1.1.9"
3+
version = "v1.1.10"
44
description = "Assess the temperature alignment of current targets, commitments, and investment and lending portfolios."
55
authors = [
66
{ name = "Michael Tiemann", email = "[email protected]" },
77
]
8-
requires-python = ">=3.9"
8+
requires-python = ">=3.10"
99
readme = "README.md"
1010
license = { text = "Apache-2.0" }
1111
keywords = ["Climate", "ITR", "Finance"]
@@ -23,7 +23,6 @@ classifiers = [
2323
"Programming Language :: Python :: 3.12",
2424
"Programming Language :: Python :: 3.11",
2525
"Programming Language :: Python :: 3.10",
26-
"Programming Language :: Python :: 3.9",
2726
"Topic :: Office/Business :: Financial",
2827
"Topic :: Scientific/Engineering",
2928
"Topic :: Software Development",
@@ -36,7 +35,7 @@ dependencies = [
3635
"openpyxl==3.1.2",
3736
"openscm-units==0.6.1",
3837
"orca==1.8",
39-
"osc-ingest-tools>=0.5.2",
38+
"osc-ingest-tools>=v0.5.5",
4039
"pandas>=2.2.1",
4140
"pip>=23.1.2",
4241
"Pint>=0.23",
@@ -51,7 +50,7 @@ dependencies = [
5150
"sphinx<8,>=6",
5251
"sphinx-autoapi>=2.0.1",
5352
"sphinx-autodoc-typehints",
54-
"sphinx-rtd-theme==1.3.0",
53+
"sphinx-rtd-theme",
5554
"SQLAlchemy>=2.0.29",
5655
"tables>=3.8.0",
5756
"trino==0.328.0",

src/ITR/data/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def translate_currency_symbols_1(text):
6565
return text
6666
if len(split_text) & 1 and split_text[-1] != "":
6767
split_text.append("")
68-
pairs = zip(split_text[::2], split_text[1::2])
68+
pairs = zip(split_text[::2], split_text[1::2], strict=False)
6969
retval = "".join(
7070
map(
7171
lambda x: f"{x[0]}{'USD' if x[1] == '$' or x[1] == 'US$' else currency_dict.get(x[1], '')}",
@@ -82,7 +82,7 @@ def translate_currency_symbols(text):
8282
return translate_currency_symbols_1(text)
8383
if len(keep_text) & 1 and keep_text[-1] != "":
8484
keep_text.append("")
85-
pairs = zip(keep_text[::2], keep_text[1::2])
85+
pairs = zip(keep_text[::2], keep_text[1::2], strict=False)
8686
retval = "".join(
8787
[
8888
inner

src/ITR/data/base_providers.py

+18-4
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,13 @@ def _convert_benchmark_to_series(
155155
# Benchmarks don't need work-around for https://github.com/hgrecco/pint/issues/1687, but if they did:
156156
# units = ureg.parse_units(benchmark.benchmark_metric)
157157
years, values = list(
158-
map(list, zip(*{r.year: r.value.m for r in benchmark.projections}.items()))
158+
map(
159+
list,
160+
zip(
161+
*{r.year: r.value.m for r in benchmark.projections}.items(),
162+
strict=False,
163+
),
164+
)
159165
)
160166
return pd.Series(
161167
PA_(np.array(values), dtype="pint[dimensionless]"),
@@ -985,7 +991,7 @@ def get_company_projected_trajectories(
985991
if len(projections) == 0:
986992
return pd.DataFrame()
987993
index = pd.MultiIndex.from_tuples(
988-
zip(c_ids, scopes), names=["company_id", "scope"]
994+
zip(c_ids, scopes, strict=False), names=["company_id", "scope"]
989995
)
990996
if year is not None:
991997
values = list(
@@ -1207,7 +1213,11 @@ def _allocate_emissions(
12071213
else em_p[0].value / em_p[1].value
12081214
),
12091215
),
1210-
zip(historic_sector.emissions[scope.name], prod_list),
1216+
zip(
1217+
historic_sector.emissions[scope.name],
1218+
prod_list,
1219+
strict=False,
1220+
),
12111221
)
12121222
)
12131223
setattr(historic_sector.emissions_intensities, scope.name, ei_list)
@@ -1775,7 +1785,11 @@ def _extrapolate_mini(col, trend):
17751785
.T.cumprod()
17761786
.rename(
17771787
index=dict(
1778-
zip(range(0, len(projection_years[1:])), projection_years[1:])
1788+
zip(
1789+
range(0, len(projection_years[1:])),
1790+
projection_years[1:],
1791+
strict=False,
1792+
)
17791793
)
17801794
)
17811795
.mul(historic_ei_t.iloc[-1], axis=1)

src/ITR/data/template.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,13 @@ def _solve_intensities(
292292
# https://stackoverflow.com/a/61021228/1291237
293293
compare_cols = ["company_id", "report_date"]
294294
has_reported_production_mask = pd.Series(
295-
list(zip(*[df_esg[c] for c in compare_cols]))
295+
list(zip(*[df_esg[c] for c in compare_cols], strict=False))
296296
).isin(
297297
list(
298-
zip(*[df_esg[df_esg.metric.eq("production")][c] for c in compare_cols])
298+
zip(
299+
*[df_esg[df_esg.metric.eq("production")][c] for c in compare_cols],
300+
strict=False,
301+
)
299302
)
300303
)
301304
df_esg_missing_production = df_esg[~has_reported_production_mask.values]

src/ITR/data/vault_providers.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def dequantify_column(df_col: pd.Series) -> pd.DataFrame:
6363
lambda x: (np.nan, "dimensionless")
6464
if pd.isna(x)
6565
else (x.m, str(x.u))
66-
)
66+
),
67+
strict=False,
6768
)
6869
)
6970
return pd.DataFrame(
@@ -911,7 +912,8 @@ def __init__(
911912
(c.company_id, c.sector, c.region, c.base_year_production)
912913
for c in company_data._companies
913914
if c.company_id in company_data.get_company_ids()
914-
]
915+
],
916+
strict=False,
915917
)
916918
with warnings.catch_warnings():
917919
warnings.simplefilter("ignore")

src/ITR/interfaces.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ def __str__(self):
401401
*[
402402
(x.year, round(ITR.Q_m_as(x.value, ei_metric), 4))
403403
for x in self.projections
404-
]
404+
],
405+
strict=False,
405406
)
406407
)
407408
)
@@ -449,7 +450,8 @@ def __init__(self, icompany_ei_projections=None, *args, **kwargs):
449450
else ITR.Q_m_as(x["value"], ei_metric, inplace=True),
450451
)
451452
for x in projections_gen
452-
]
453+
],
454+
strict=False,
453455
),
454456
)
455457
)
@@ -629,7 +631,8 @@ def __str__(self):
629631
*[
630632
(x.year, round(x.value.to("Mt CO2e").m, 4))
631633
for x in getattr(self, scope)
632-
]
634+
],
635+
strict=False,
633636
)
634637
)
635638
)
@@ -696,7 +699,8 @@ def __str__(self):
696699
*[
697700
(x.year, round(x.value.to(ei_metric).m, 4))
698701
for x in getattr(self, scope)
699-
]
702+
],
703+
strict=False,
700704
)
701705
)
702706
)

src/ITR/temperature_score.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,10 @@ def _prepare_data(self, data: pd.DataFrame, target_probability: float):
274274
scoring_data[self.c.COLS.TARGET_SCORE],
275275
scoring_data[self.c.COLS.TARGET_OVERSHOOT],
276276
scoring_data[self.c.SCORE_RESULT_TYPE],
277-
) = zip(*scoring_data.apply(lambda row: self.get_score(row), axis=1))
277+
) = zip(
278+
*scoring_data.apply(lambda row: self.get_score(row), axis=1),
279+
strict=False,
280+
)
278281

279282
# Fix up dtypes for the new columns we just added
280283
for col in [

test/test_base_providers.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,11 @@ def test_get_projected_targets(self):
359359
Q_(0.04623233372785435, "t CO2 / GJ"),
360360
],
361361
index=pd.MultiIndex.from_tuples(
362-
zip(self.company_ids, [EScope.S1S2] * len(self.company_ids))
362+
zip(
363+
self.company_ids,
364+
[EScope.S1S2] * len(self.company_ids),
365+
strict=False,
366+
)
363367
),
364368
name=2025,
365369
)

0 commit comments

Comments
 (0)