Skip to content

Modernize typing annotations for Python 3.10+#57

Merged
pnorton-usgs merged 12 commits into
developmentfrom
modernize-typing-annotations
May 19, 2026
Merged

Modernize typing annotations for Python 3.10+#57
pnorton-usgs merged 12 commits into
developmentfrom
modernize-typing-annotations

Conversation

@pnorton-usgs
Copy link
Copy Markdown
Member

Modernize typing annotations for Python 3.10+

Replace deprecated typing module imports with modern Python 3.10+ equivalents across the package.

Changes

  • Built-in generics: Dictdict, Listlist, Setset
  • PEP 604 union syntax: Optional[X]X | None, Union[X, Y]X | Y
  • collections.abc: Iterator, Callable, Sequence imported from collections.abc instead of typing
  • from __future__ import annotations added to files that needed it

Files updated

  • pyPRMS/constants.py
  • pyPRMS/prms_helpers.py
  • pyPRMS/plot_helpers.py
  • pyPRMS/control/Control.py
  • pyPRMS/control/ControlFile.py
  • pyPRMS/control/ControlVariable.py
  • pyPRMS/parameters/Parameters.py

What's still imported from typing

Only constructs with no built-in replacement remain: Any, cast, NamedTuple, Literal.

Testing

  • All 301 tests pass
  • No new mypy errors introduced

- added test_outputCSV_streamflow()
- added test_outputCSV_basin_and_stream()
Replace deprecated typing imports (Dict, List, Set, Tuple, Optional,
Union, Iterator, Callable, Sequence) with modern equivalents:

- Use built-in generics: dict, list, set, tuple
- Use PEP 604 union syntax: X | Y, X | None
- Use collections.abc for Iterator, Callable, Sequence
- Add 'from __future__ import annotations' where needed

Files updated:
- constants.py
- prms_helpers.py
- plot_helpers.py
- control/Control.py
- control/ControlFile.py
- control/ControlVariable.py
- parameters/Parameters.py
@pnorton-usgs pnorton-usgs self-assigned this May 19, 2026
@pnorton-usgs pnorton-usgs merged commit 7b51271 into development May 19, 2026
14 checks passed
@pnorton-usgs pnorton-usgs deleted the modernize-typing-annotations branch May 19, 2026 15:43
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.

1 participant