Skip to content
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

fix mypy typing errors in pytorch_lightning/tuner/lr_finder.py #13513

Merged
merged 13 commits into from
Jul 8, 2022
Merged

fix mypy typing errors in pytorch_lightning/tuner/lr_finder.py #13513

merged 13 commits into from
Jul 8, 2022

Conversation

donlapark
Copy link
Contributor

@donlapark donlapark commented Jul 2, 2022

What does this PR do?

Fixes mypy typing errors in pytorch_lightning/tuner/lr_finder.py in #13445.

  • Import of matplotlib has been moved to the beginning of the file in order to enable plt.Figure type.
  • Line 129: The type of scheduler in LRSchedulerConfig is expected to be Union[_LRScheduler, ReduceLROnPlateau], but both _LinearLR and _ExponentialLR inherit from torch.optim.lr_scheduler._LRScheduler.
  • Line 209: sometimes mypy will throw Return value expected error when it detects a lone return (Return value expected on def f() -> Optional[Type]: with plain return python/mypy#1003), in which case I added # type: ignore to the line.
  • Line 231: mypy will throw in an error if a function is assigned to a method (Unable to assign a function a method python/mypy#2427).
  • Line 332: Union[_LRScheduler, ReduceLROnPlateau] has no attribute lr.

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 🙃

@akihironitta akihironitta added code quality community This PR is from the community labels Jul 3, 2022
@akihironitta akihironitta added this to the pl:1.7 milestone Jul 3, 2022
Copy link
Contributor

@akihironitta akihironitta left a comment

Choose a reason for hiding this comment

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

Thank you for working on this!

src/pytorch_lightning/tuner/lr_finder.py Outdated Show resolved Hide resolved
src/pytorch_lightning/tuner/lr_finder.py Outdated Show resolved Hide resolved
@mergify mergify bot added the ready PRs ready to be merged label Jul 4, 2022
@donlapark donlapark closed this Jul 4, 2022
@donlapark donlapark reopened this Jul 4, 2022
@donlapark
Copy link
Contributor Author

Sorry for the closing and reopening PR -- most of the checks are stuck with Expected — Waiting for status to be reported so I am trying to unstuck it.

@justusschock
Copy link
Member

Sorry for the closing and reopening PR -- most of the checks are stuck with Expected — Waiting for status to be reported so I am trying to unstuck it.

That is because as a first-time contributor you need approval from our team to run our CI (which I just approved)

src/pytorch_lightning/tuner/lr_finder.py Outdated Show resolved Hide resolved
src/pytorch_lightning/tuner/lr_finder.py Outdated Show resolved Hide resolved
src/pytorch_lightning/tuner/lr_finder.py Show resolved Hide resolved
donlapark and others added 4 commits July 4, 2022 11:34
Co-authored-by: Justus Schock <12886177+justusschock@users.noreply.github.com>
Co-authored-by: Justus Schock <12886177+justusschock@users.noreply.github.com>
Co-authored-by: Justus Schock <12886177+justusschock@users.noreply.github.com>
@donlapark donlapark requested review from Borda and justusschock July 6, 2022 01:30
@otaj otaj mentioned this pull request Jul 8, 2022
52 tasks
@otaj otaj enabled auto-merge (squash) July 8, 2022 15:06
@otaj otaj merged commit b59f802 into Lightning-AI:master Jul 8, 2022
@donlapark donlapark deleted the fix/#13445_mypy-tuner-lr_finder branch July 9, 2022 05:24
jerome-habana pushed a commit to jerome-habana/lightning that referenced this pull request Jul 14, 2022
…ning-AI#13513)

Co-authored-by: Akihiro Nitta <nitta@akihironitta.com>
Co-authored-by: Justus Schock <12886177+justusschock@users.noreply.github.com>
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 ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants