Skip to content

[WIP] Add typing for pytorch_lightning.utilities #7218

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

Closed
wants to merge 64 commits into from

Conversation

stancld
Copy link
Contributor

@stancld stancld commented Apr 26, 2021

What does this PR do?

Part of #7037

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 update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is free to review the PR once the tests have passed.
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 🙃

@pep8speaks
Copy link

pep8speaks commented Apr 26, 2021

Hello @stancld! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-05-27 21:20:42 UTC

@codecov
Copy link

codecov bot commented Apr 26, 2021

Codecov Report

Merging #7218 (eb902c7) into master (9097347) will decrease coverage by 48%.
The diff coverage is 80%.

@@           Coverage Diff            @@
##           master   #7218     +/-   ##
========================================
- Coverage      92%     44%    -48%     
========================================
  Files         199     199             
  Lines       12996   13014     +18     
========================================
- Hits        12003    5726   -6277     
- Misses        993    7288   +6295     

@Borda Borda removed the ready PRs ready to be merged label May 19, 2021
@stancld stancld changed the title Add typing for pytorch_lightning.utilities [WIP] Add typing for pytorch_lightning.utilities May 25, 2021
@mergify mergify bot removed the has conflicts label May 25, 2021
hook=ddp_comm_hook,
)
# If condition required for mypy compatibility
if ddp_comm_hook is not None:
Copy link
Member

Choose a reason for hiding this comment

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

rather allow passing None, or what happen if none is passed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this condition is dropped, the following mypy issue is raised:

utilities/distributed.py:320: error: Item "None" of "Optional[Callable[..., Any]]" has no attribute "__qualname__"

return collect_init_args(frame.f_back, path_args, inside=True)
elif not inside:
return collect_init_args(frame.f_back, path_args, inside)
if isinstance(frame.f_back, FrameType):
Copy link
Member

Choose a reason for hiding this comment

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

mind comment on why this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dropping this condition leads to the following two issues:

utilities/parsing.py:174: error: Argument 1 to "collect_init_args" has incompatible type "Optional[FrameType]"; expected "FrameType"
utilities/parsing.py:176: error: Argument 1 to "collect_init_args" has incompatible type "Optional[FrameType]"; expected "FrameType"

Maybe, there's another nice workaround.

@stancld
Copy link
Contributor Author

stancld commented Jun 24, 2021

@Borda Hi, sorry for not responding. This PR looks now obsolete and pretty complicated to merge due to its large extent. Would you mind if I close this PR and maybe open some little PRs for individual files to finish this mypy task?

@awaelchli
Copy link
Contributor

If it's possible to break down in smaller pieces that would be awesome! very welcomed!
a smaller, incremental PRs would make it easier to review, lower the changes of conflicts and increase the changes to get merged <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants