-
Notifications
You must be signed in to change notification settings - Fork 62
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
Mypy #217
Mypy #217
Conversation
def max_ladeleistung_w_field(default: Optional[float] = None) -> Optional[float]: | ||
return Field( | ||
default, | ||
default=default, | ||
gt=0, | ||
description="An integer representing the charging power of the battery in watts.", | ||
) |
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.
I'm not familiar with pydantic, but shouldn't the return type hint be Field
?
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.
Field is actually a function but it returns a FieldInfo. The type annotation for the Field function however is Any as return type as it is assigned to the pydantic model field (with a user type like Optional[float]). Therefore this type hint cheats a bit in the way similar as it's done with the deap.creator.Individual -> list[int].
id like to merge this next before it got hit by the very large PR #220 |
* Add to pre-commit (currently installs own deps, could maybe changed to poetry venv in the future to reuse environment and don't need duplicated types deps). * Add type hints.
Add Mypy support:
In second commit:
Remarks: