PyPSA / linopy

Linear optimization with N-D labeled arrays in Python
https://linopy.readthedocs.io
MIT License
153 stars 40 forks source link

Annotate typing #310

Closed FabianHofmann closed 19 hours ago

FabianHofmann commented 1 week ago

Add type annotations & add MyPy to pre-commit hooks. This is quite a large change, but the functional change is kept to a minimum.

closes #303 closes #185

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 87.84091% with 107 lines in your changes missing coverage. Please review.

Project coverage is 88.29%. Comparing base (3d2a72b) to head (201b164). Report is 3 commits behind head on master.

:exclamation: Current head 201b164 differs from pull request most recent head 5949eca

Please upload reports for the commit 5949eca to get more accurate results.

Files Patch % Lines
linopy/expressions.py 90.15% 12 Missing and 7 partials :warning:
linopy/model.py 87.03% 9 Missing and 5 partials :warning:
linopy/solvers.py 85.05% 8 Missing and 5 partials :warning:
linopy/variables.py 91.15% 9 Missing and 4 partials :warning:
linopy/io.py 81.25% 6 Missing and 6 partials :warning:
linopy/common.py 81.66% 6 Missing and 5 partials :warning:
linopy/constraints.py 91.13% 2 Missing and 5 partials :warning:
linopy/constants.py 66.66% 3 Missing and 2 partials :warning:
linopy/matrices.py 87.09% 2 Missing and 2 partials :warning:
linopy/types.py 82.60% 3 Missing and 1 partial :warning:
... and 2 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #310 +/- ## ========================================== - Coverage 89.72% 88.29% -1.43% ========================================== Files 16 17 +1 Lines 4037 4159 +122 Branches 942 978 +36 ========================================== + Hits 3622 3672 +50 - Misses 282 316 +34 - Partials 133 171 +38 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

FabianHofmann commented 1 week ago

@lkstrp could I kindly ask you to take over fixing the pre-commit bot. It looks like the pre-commit CI is sort of stuck with another set of (cached ?) arguments. Locally it works fine. What I want in the end is to run mypy checks on linopy/ and test/

FabianHofmann commented 1 week ago

@lkstrp awesome thanks