Skip to content

Loosen overspecified type hints in functional #7529

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

Conversation

qthequartermasterman
Copy link

In the transforms.functional module, many functions accept either an int or a sequence of ints (such as size parameters). These are correctly documented in the docstring, but the static type hints incorrectly mark them as List[int], which is too specific. This does not allow ints or Tuple[int], which are valid inputs.

@pytorch-bot
Copy link

pytorch-bot bot commented Apr 18, 2023

@facebook-github-bot
Copy link

Hi @qthequartermasterman!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@NicolasHug NicolasHug requested a review from pmeier April 19, 2023 11:05
Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

Hey @qthequartermasterman. Believe me when I say that I desperately want this change, but unfortunately it breaks JIT. Sequence is not supported by it and thus we cannot use it.

The singular List[int] annotation stems from a time where JIT didn't even support Union. Since your goal is to "allow" int and Tuple[int, int] or the like as well, you can try a larger Union of these. However, JIT also has some undocumented automagic in the background that we sometimes rely upon. See #7252 for details. Meaning, I can't give you any guarantees that this will work. In turn, we can only accept such a PR when CI is fully green.

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.

3 participants