-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add typing for LightningOptimizer
#9990
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
Conversation
…htning-opt-typing
Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id> |
Codecov Report
@@ Coverage Diff @@
## master #9990 +/- ##
=======================================
- Coverage 93% 89% -4%
=======================================
Files 179 179
Lines 15822 15815 -7
=======================================
- Hits 14660 14031 -629
- Misses 1162 1784 +622 |
... | ||
|
||
@overload | ||
def optimizers(self, use_pl_optimizer: Literal[False]) -> Union[Optimizer, List[Optimizer]]: |
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 believe we need to add a third overload here for this to work as expected.
Eg.
@overload
def optimizer(self, use_pl_optimizer: bool) -> Union[...]
See the error that is raised as currently written here: https://mypy-play.net/?mypy=latest&python=3.8&gist=183e84ea2331260b77cf58c0bfbf1151
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.
You are correct, this only works if True
or False
are explicitly passed.
I'll open a PR with the fix.
What does this PR do?
Part of #7037
Also some docs changes
Does your PR introduce any breaking changes? If yes, please list them.
None
Before submitting
PR review