Skip to content

fix type issues surfaced from pace integration#81

Merged
oelbert merged 3 commits into
NOAA-GFDL:developfrom
romanc:romanc/types-patches
Jan 15, 2026
Merged

fix type issues surfaced from pace integration#81
oelbert merged 3 commits into
NOAA-GFDL:developfrom
romanc:romanc/types-patches

Conversation

@romanc
Copy link
Copy Markdown
Collaborator

@romanc romanc commented Jan 13, 2026

Description

Continuing the quest towards the 2026.01.00 release, this PR fixes linting issues revealed in PR NOAA-GFDL/pace#173. mypy didn't catch those in pySHiELD because mypy was effectively de-activated in the pySHiELD repo. The proper fix is a follow-up in #82. Here we just fix what's urgently needed to move the 2026.01.00 release of NDSL forward.

/cc @FlorianDeconinck

How Has This Been Tested?

Self-review of code, passing CI and I have pace-linting working locally with these changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas (code review)
  • I have made corresponding changes to the documentation: N/A
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included: N/A
  • Targeted model, if this change was triggered by a model need/shortcoming: N/A

Copy link
Copy Markdown
Collaborator Author

@romanc romanc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see inline

Comment thread pyshield/_config.py
Comment on lines -70 to -72
ntiw: int = DEFAULT_INT
ntcw: int = DEFAULT_INT
ntke: int = DEFAULT_INT
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are already defined below with a comment (same default values)

import datetime
import re
from pathlib import Path
from typing import Union
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modern typing uses str | float instead of Union[str, float].


def read_NOAA_solar_file(
solar_fname: Path,
) -> dict[str : Union[float, int, dict[str : Union[int, float, dict[str:float]]]]]:
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the format for typing dictionaries is dict[str, Any] not dict[str : Any]

solar_constant_data["icy1"] = int(table_dat[2])
solar_constant_data["icy2"] = int(table_dat[3])
solar_constant_data["smean"] = float(table_dat[4])
elif re.fullmatch(r"^(\*)\1{1,}$", table_dat[0]):
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always use is (not) None to compare against None to help the type system.

cfc11,
cfc12,
cfc22,
cfc113,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was an inconsistency with those 14 or 15 return values. From usage, I inferred that the 15 one is probably what we want ... please double-check

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like that's the missing one to me too based off of RTE_RRTMGPDriver in rte_rrtmgp.py.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol that's correct, whoops! Now I'm worried how that isn't causing issues currently

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oelbert If I were you, I'd want #82 to merge as soon as possible. to avoid such issues. There are two science questions in that PR over there, which I think are for you to decide.

Comment thread pyshield/radiation/rte_rrtmgp.py Outdated
@romanc romanc changed the title WIP: fix type issues surfaced from pace integration fix type issues surfaced from pace integration Jan 13, 2026
@romanc romanc marked this pull request as ready for review January 13, 2026 19:36
@romanc romanc requested review from jjuyeonkim and oelbert January 13, 2026 19:36
The Quanity constructor will require a backend with the next version of
NDSL.
@romanc
Copy link
Copy Markdown
Collaborator Author

romanc commented Jan 13, 2026

Update: added a commit to add backend as a required argument to Quantity() constructor calls after looking at the logs of tests and checking for remaining deprecation warnings. This is in preparation for PR NOAA-GFDL/NDSL#357 on the NDSL side (to be released with NDSL 2026.01.00).

jjuyeonkim
jjuyeonkim previously approved these changes Jan 13, 2026
Copy link
Copy Markdown
Collaborator

@jjuyeonkim jjuyeonkim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks okay to me.

cfc11,
cfc12,
cfc22,
cfc113,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like that's the missing one to me too based off of RTE_RRTMGPDriver in rte_rrtmgp.py.

Copy link
Copy Markdown
Collaborator

@jjuyeonkim jjuyeonkim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looks okay to me. However, I'm going to wait on Oliver for this one.

@romanc
Copy link
Copy Markdown
Collaborator Author

romanc commented Jan 15, 2026

@oelbert the NASA team would appreciate rapid feedback on this one: it is blocking (via NOAA-GFDL/pace#173) the release of NDSL version 2026.01.00. This PR a duct-tape fix for what's needed for release.

The proper fix (re-enabling mypy) is in PR #82 and can take longer if needed (though I'd suggest merging it as soon as possible since mypy is an indispensable tool in situations where functions routinely have 10+ arguments 🙈). Let me know if I can help in any way.

Copy link
Copy Markdown
Collaborator

@oelbert oelbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for going through all of this @romanc

cfc11,
cfc12,
cfc22,
cfc113,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol that's correct, whoops! Now I'm worried how that isn't causing issues currently

@oelbert oelbert added this pull request to the merge queue Jan 15, 2026
Merged via the queue into NOAA-GFDL:develop with commit 9e2cee1 Jan 15, 2026
3 checks passed
@romanc romanc deleted the romanc/types-patches branch January 16, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants