Skip to content

Commit

Permalink
improve type hints based on mypy analysis (#105)
Browse files Browse the repository at this point in the history
* improve type hints based on mypy analysis

* use cast instead of type: ignore

* create root-level horizontal standard variables with precise domain

* work around missing typing.Final in python 3.7

* try another python 3.7 workaround

* run mypy as part of github actions

* tweaks for online mypy tests

* mypy: install types-pyyaml

* add type hints to fabm_evaluate.py

* install netcdf4 for type checking

* skip mypy checks on python 3.8 (no type-aware netcdf4)

* further improvements to type annotation

* use sys.platform to detect windows
  • Loading branch information
jornbr authored Dec 11, 2024
1 parent 2a9328b commit 2178e41
Show file tree
Hide file tree
Showing 10 changed files with 476 additions and 320 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/fabm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ jobs:
conda install ipython jupyterlab ipympl matplotlib scipy
cd testcases/python
for f in *.ipynb; do ipython --gui qt -c "%run $f"; done
- name: Type checking with mypy
if: matrix.python-version != '3.7' && matrix.python-version != '3.8'
run: |
conda install mypy pyyaml types-pyyaml netcdf4 pyqt-stubs
mypy src/pyfabm
- name: Install with customization via command line arguments
run: |
rm -rf build
Expand Down
3 changes: 2 additions & 1 deletion src/fabm_coupling.F90
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ recursive subroutine process_coupling_tasks(self, final, log_unit)
standard_variable=standard_variable, presence=presence_external_optional, link=link)
class is (type_horizontal_standard_variable)
call root%add_horizontal_variable(standard_variable%name, standard_variable%units, standard_variable%name, &
standard_variable=standard_variable, presence=presence_external_optional, link=link)
standard_variable=standard_variable, presence=presence_external_optional, link=link, &
domain=standard_variable2domain(standard_variable))
class is (type_global_standard_variable)
call root%add_scalar_variable(standard_variable%name, standard_variable%units, standard_variable%name, &
standard_variable=standard_variable, presence=presence_external_optional, link=link)
Expand Down
Loading

0 comments on commit 2178e41

Please sign in to comment.