Skip to content

Conversation

@stancld
Copy link
Contributor

@stancld stancld commented Aug 5, 2021

What does this PR do?

Part of #7037. This PR disentangles large #7218. It fixes mypy typing in utilities.xla_device.py.

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 internal minor changes/refactorings)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing make sure you have read 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 🙃

@codecov
Copy link

codecov bot commented Aug 5, 2021

Codecov Report

Merging #8755 (205b71f) into master (4928dc5) will increase coverage by 0%.
The diff coverage is 83%.

@@          Coverage Diff           @@
##           master   #8755   +/-   ##
======================================
  Coverage      89%     89%           
======================================
  Files         169     169           
  Lines       14073   14074    +1     
======================================
+ Hits        12466   12467    +1     
  Misses       1607    1607           

@awaelchli awaelchli added this to the v1.5 milestone Aug 5, 2021
_TORCHMETRICS_LOWER_THAN_0_3 = _compare_version("torchmetrics", operator.lt, "0.3.0")
_TORCHMETRICS_GREATER_EQUAL_0_3 = _compare_version("torchmetrics", operator.ge, "0.3.0")
_XLA_AVAILABLE = _module_available("torch_xla")
_XLA_AVAILABLE: bool = _module_available("torch_xla")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this necessary?

_module_available is annotated with -> bool

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, mypy is not able to figure that out without this explicit type hint.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mergify mergify bot added the ready PRs ready to be merged label Aug 6, 2021
@SkafteNicki SkafteNicki enabled auto-merge (squash) August 6, 2021 13:18
@SkafteNicki SkafteNicki merged commit d063059 into Lightning-AI:master Aug 6, 2021
four4fish pushed a commit to four4fish/pytorch-lightning that referenced this pull request Aug 16, 2021
* Fix mypy for utilities.xla_device

* Add explicit type hint for _XLA_AVAILABLE in utilities.imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready PRs ready to be merged refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants