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

Apply Type Comments: Allow for skipping quotes when applying type comments #644

Merged
merged 3 commits into from
Feb 10, 2022

Conversation

stroxler
Copy link
Contributor

Summary

The motivation for this is pytorch, where type comments mostly are maintained and it is
better to avoid quotes in methods that have jit compiler decorators.

Test Plan

I added a new test case verifying that the flag is properly propagated for all node types
that we would transform. Tests pass.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 10, 2022
@stroxler stroxler changed the title Type comments: Allow for skipping quotes when applying type comments Apply Type Comments: Allow for skipping quotes when applying type comments Feb 10, 2022
@codecov-commenter
Copy link

codecov-commenter commented Feb 10, 2022

Codecov Report

Merging #644 (1858568) into main (fb56fa6) will decrease coverage by 0.00%.
The diff coverage is 80.95%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #644      +/-   ##
==========================================
- Coverage   94.79%   94.78%   -0.01%     
==========================================
  Files         245      245              
  Lines       25289    25304      +15     
==========================================
+ Hits        23973    23985      +12     
- Misses       1316     1319       +3     
Impacted Files Coverage Δ
libcst/codemod/commands/convert_type_comments.py 95.14% <76.92%> (-1.07%) ⬇️
...demod/commands/tests/test_convert_type_comments.py 97.29% <87.50%> (+0.19%) ⬆️
libcst/codemod/visitors/_apply_type_annotations.py 95.18% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb56fa6...1858568. Read the comment docs.

@@ -388,7 +412,7 @@ class ConvertTypeComments(VisitorBasedCodemodCommand):
- For parameters, we prefer inline type comments to
function-level type comments if we find both.

We always apply the type comments as quoted annotations, unless
We always apply the type comments as quote_annotations annotations, unless
Copy link
Member

Choose a reason for hiding this comment

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

whoops

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this one is intended - in the docstring I do want to talk about "quoted annotations" when discussing the impact of the flag on output, quote_annotations is just the name of the python variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants