Enforce strict mypy type checking and additional ruff rules#492
Open
FabianHofmann wants to merge 22 commits intomasterfrom
Open
Enforce strict mypy type checking and additional ruff rules#492FabianHofmann wants to merge 22 commits intomasterfrom
FabianHofmann wants to merge 22 commits intomasterfrom
Conversation
…nd removing unnecessary type: ignore comments
…tions, remove stray code
…all 61 violations
…te_time helper, consistent keep_attrs, use fixtures in tests
for more information, see https://pre-commit.ci
…ypes across codebase - Add NumPy-style docstrings to all functions in datasets/era5.py and improve convert.py docstrings - Define shared Literal type aliases (TrackingType, ClearskyModel, TrigonModel, etc.) in _types.py - Update ~30 function signatures across convert.py, pv/, and data.py to use Literal types - Fix CSPConfig TypedDict missing 'technology' key and widen orientation/panel param types
Per-file ignores for datasets modules still lacking docstrings (cordex, ncep, sarah, gebco).
…d remove per-file D103 ignores
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes proposed in this Pull Request
This PR enforces strict static type checking with mypy and enables additional ruff lint rules across the entire codebase (including
test/anddoc/).Docstrings
Mypy
pyproject.toml:disallow_incomplete_defs = true,check_untyped_defs = trueatlite/,test/, anddoc/.pre-commit-config.yamlto matchatlite/_types.pytype aliases and addedTypeAliasannotations where needed (e.g.csp.py,utils.py)convert.py)__all__in__init__.pyto use strings instead of object referencesRuff
Enabled 9 new rule sets and fixed all violations (~260 fixes):
from err/from Noneto re-raised exceptions, fixed mutable defaultsifstatements, simplified dict operationselseafterreturn/raisedict()/list()constructorsTYPE_CHECKINGblocksnp.random.seed/np.random.randwithnp.random.default_rng%formattingos.path.*andopen()withpathlibequivalents# noqacommentsTODO
cast()where possible, need bump python version for mypyChecklist
doc.environment.yaml,environment_docs.yamlandsetup.py(if applicable).doc/release_notes.rstof the upcoming release is included.