Skip to content

refactor: modern type hints in NDSL#270

Merged
FlorianDeconinck merged 3 commits into
NOAA-GFDL:developfrom
romanc:romanc/modern-types
Oct 20, 2025
Merged

refactor: modern type hints in NDSL#270
FlorianDeconinck merged 3 commits into
NOAA-GFDL:developfrom
romanc:romanc/modern-types

Conversation

@romanc
Copy link
Copy Markdown
Collaborator

@romanc romanc commented Oct 18, 2025

Description

With #258 merged, it's somewhat safe to do type transformations. So lets update our types in NDSL to be a bit more modern. Generics like list & dict now expose the proper type and there's no need to import List & Dict from typings anymore. Along the same lines, Sequence, Iterator, and Generator are now deprecated aliases in the typing module because they natively exist in collections.abc. On top of that, since python 3.10, we can leverage | to replace Union and Optional. See typing docs.

How has this been tested?

Current tests, in particular mypy are still happy.

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
    N/A
  • I have made corresponding changes to the documentation (e.g. add new modules to docs/docstrings/)
    N/A
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
    N/A
  • New check tests, if applicable, are included
    N/A

@romanc romanc marked this pull request as ready for review October 20, 2025 07:03
@romanc romanc changed the title wip: modern type hints in NDSL refactor: modern type hints in NDSL Oct 20, 2025
Copy link
Copy Markdown
Collaborator

@FlorianDeconinck FlorianDeconinck left a comment

Choose a reason for hiding this comment

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

Sweet - are we becoming an actual python repository ?! #Pinocchio

Close but unrelated, I think we can probably kill some of the TYPE_CHECKING left in there

@FlorianDeconinck FlorianDeconinck added this pull request to the merge queue Oct 20, 2025
@romanc
Copy link
Copy Markdown
Collaborator Author

romanc commented Oct 20, 2025

Sweet - are we becoming an actual python repository ?! #Pinocchio

who knows, maybe we get there one day ...

Close but unrelated, I think we can probably kill some of the TYPE_CHECKING left in there

good point - I'll put it on my mental list for Friday afternoon cleanups. although, if you want to look like a python repo, there's absolutely nothing wrong with TYPE_CHECKING

@FlorianDeconinck
Copy link
Copy Markdown
Collaborator

good point - I'll put it on my mental list for Friday afternoon cleanups. although, if you want to look like a python repo, there's absolutely nothing wrong with TYPE_CHECKING

There isn't, but they always looked like a crouch to me. I'd rather have straightforward imports, rather than pre-processing tool dependent code in there. It is minor.

Merged via the queue into NOAA-GFDL:develop with commit f4f9fca Oct 20, 2025
6 checks passed
@romanc romanc deleted the romanc/modern-types branch October 20, 2025 21:02
@romanc romanc mentioned this pull request Oct 22, 2025
1 task
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.

2 participants