Skip to content

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

Merged
merged 9 commits into from
Oct 18, 2021
Merged

Conversation

carmocca
Copy link
Contributor

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

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • [n/a] Did you make sure to update the documentation with your changes? (if necessary)
  • [n/a] Did you write any new necessary tests? (not for typos and docs)
  • [n/a] Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • [n/a] Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

@carmocca carmocca added docs Documentation related refactor labels Oct 18, 2021
@carmocca carmocca added this to the v1.5 milestone Oct 18, 2021
@carmocca carmocca self-assigned this Oct 18, 2021
@github-actions
Copy link
Contributor

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

@codecov
Copy link

codecov bot commented Oct 18, 2021

Codecov Report

Merging #9990 (10f9f26) into master (3f355d0) will decrease coverage by 4%.
The diff coverage is 85%.

@@           Coverage Diff           @@
##           master   #9990    +/-   ##
=======================================
- Coverage      93%     89%    -4%     
=======================================
  Files         179     179            
  Lines       15822   15815     -7     
=======================================
- Hits        14660   14031   -629     
- Misses       1162    1784   +622     

@carmocca carmocca enabled auto-merge (squash) October 18, 2021 14:15
@mergify mergify bot added the ready PRs ready to be merged label Oct 18, 2021
@carmocca carmocca merged commit efc8727 into master Oct 18, 2021
@carmocca carmocca deleted the refactor/lightning-opt-typing branch October 18, 2021 15:29
rohitgr7 pushed a commit to Tshimanga/pytorch-lightning that referenced this pull request Oct 18, 2021
...

@overload
def optimizers(self, use_pl_optimizer: Literal[False]) -> Union[Optimizer, List[Optimizer]]:
Copy link
Contributor

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

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation related ready PRs ready to be merged refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants