Skip to content

fix mypy typing errors in pytorch_lightning/strategies/strategy.py #13519

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 19 commits into from
Jul 26, 2022
Merged

fix mypy typing errors in pytorch_lightning/strategies/strategy.py #13519

merged 19 commits into from
Jul 26, 2022

Conversation

CyprienRicque
Copy link
Contributor

@CyprienRicque CyprienRicque commented Jul 3, 2022

What does this PR do?

Fixes mypy typing errors in pytorch_lightning/strategies/strategy.py in #13445.

  • model becomes explicitly Optional[] in plugins functions such as optimizer_step and _after_closure
  • self.accelerator becomes explicitly Optional[] in strategy classes
  • The existence of self.accelerator, self.model and self.lightning_module is checked in strategy classes using assert when needed
  • Variable output in training_step_end, validation_step_end and test_step_end has been renamed to step_output to stay consistent with other functions
  • self.model has to be of type pl.LightningModule or _LightningPrecisionModuleWrapperBase to use training_step, validation_step, test_step and predict_step

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?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:

  • 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

Did you have fun?

Make sure you had fun coding 🙃

@CyprienRicque CyprienRicque marked this pull request as ready for review July 3, 2022 14:44
@CyprienRicque CyprienRicque changed the title fix mypy typing errors in pytorch_lightning.strategies.strategy.py fix mypy typing errors in pytorch_lightning/strategies/strategy.py Jul 3, 2022
@CyprienRicque CyprienRicque mentioned this pull request Jul 3, 2022
52 tasks
@awaelchli awaelchli added code quality strategy community This PR is from the community labels Jul 4, 2022
@awaelchli awaelchli added this to the pl:1.7 milestone Jul 4, 2022
@carmocca carmocca modified the milestones: pl:1.7, pl:1.8 Jul 19, 2022
@mergify mergify bot removed the has conflicts label Jul 21, 2022
@github-actions github-actions bot added the pl Generic label for PyTorch Lightning package label Jul 21, 2022
Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work. Allowed myself to make minor cosmetic edits :)

@mergify mergify bot added ready PRs ready to be merged and removed has conflicts ready PRs ready to be merged labels Jul 25, 2022
@codecov
Copy link

codecov bot commented Jul 25, 2022

Codecov Report

Merging #13519 (65eed42) into master (85b0356) will decrease coverage by 10%.
The diff coverage is 86%.

@@            Coverage Diff            @@
##           master   #13519     +/-   ##
=========================================
- Coverage      86%      76%    -10%     
=========================================
  Files         330      330             
  Lines       25941    25971     +30     
=========================================
- Hits        22241    19745   -2496     
- Misses       3700     6226   +2526     

@otaj otaj enabled auto-merge (squash) July 26, 2022 07:57
@otaj otaj merged commit 6a9d626 into Lightning-AI:master Jul 26, 2022
@carmocca carmocca modified the milestones: pl:1.8, pl:1.7 Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality community This PR is from the community pl Generic label for PyTorch Lightning package ready PRs ready to be merged strategy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants