-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Complete type annotations #399
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tons of types 💃
Why did you remove py.typed
? It is currently broken, but the whole goal of this operaiton should be to make linopy a typed package. Otherwise it is only useful for internal development.
@@ -26,3 +26,4 @@ benchmark/notebooks/.ipynb_checkpoints | |||
benchmark/scripts/__pycache__ | |||
benchmark/scripts/benchmarks-pypsa-eur/__pycache__ | |||
benchmark/scripts/leftovers/ | |||
.aider* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@overload | ||
def iterate_slices( | ||
ds: Dataset, | ||
slice_size: int | None = 10_000, | ||
slice_dims: list | None = None, | ||
) -> Generator[Dataset, None, None]: ... | ||
|
||
|
||
@overload | ||
def iterate_slices( | ||
ds: Variable, | ||
slice_size: int | None = 10_000, | ||
slice_dims: list | None = None, | ||
) -> Generator[Variable, None, None]: ... | ||
|
||
|
||
@overload | ||
def iterate_slices( | ||
ds: LinearExpression, | ||
slice_size: int | None = 10_000, | ||
slice_dims: list | None = None, | ||
) -> Generator[LinearExpression, None, None]: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Were you just playing around, or do you think we could use overloading a lot more everywhere?
I wasn't sure. Probably great for type checking and IDE hints, but also adds a bit of boilerplate. We'll probably want to do stub files at some point.
@@ -11,7 +11,7 @@ | |||
import numpy as np | |||
import pandas as pd | |||
|
|||
logger = logging.getLogger(__name__) | |||
logger: logging.Logger = logging.getLogger(__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the mypy issue here? Type Any
because logging is not typed? But you did not set that rule
@@ -685,7 +688,7 @@ class Constraints: | |||
""" | |||
|
|||
data: dict[str, Constraint] | |||
model: "Model" # Model is not defined due to circular imports | |||
model: Model # Model is not defined due to circular imports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model: Model # Model is not defined due to circular imports | |
model: Model |
| Mapping | ||
| DataArrayCoordinates | ||
| DatasetCoordinates | ||
| None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't CoordsLike
still a more consistent name, even if there is no Coords
class? Otherwise, when reading the types, my first assumption is that this is a class and not a type alias.
Also, should None
also go in there?
No description provided.