mypy Static Type Checking
#16
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces support for static type checking with mypy across the
pySWATPluscodebase. To modernize and simplify type annotations, I replaced the older style of importing generic types from the typing module—such as List, Dict, and Tuple—with the built-in generic types list, dict, and tuple, as supported in Python 3.9 and later.While preparing for mypy integration, I identified several common static typing issues in the code that will need to be addressed. These include errors such as 1) "Missing type parameters for generic type 'Pattern'", which occurs when using
re.Patternwithout specifying a type parameter likere.Pattern[str], 2) "Missing type parameters for generic type 'ndarray'", which appears when numpy.ndarray is used without specifying the expected data types and 3) “Missing type parameters for generic type "Callable"”. These issues have been noted but not yet fixed in this pull request; they will need to be resolved to ensure full compatibility with mypy and achieve clean type-checking results.