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

Add support for PEP-646 #696

Merged
merged 3 commits into from
Jun 13, 2022
Merged

Add support for PEP-646 #696

merged 3 commits into from
Jun 13, 2022

Conversation

zsol
Copy link
Member

@zsol zsol commented Jun 12, 2022

Summary

Implementation and tests based on python/cpython#31018
The CST is modeled slightly differently from the AST:

  • Index can now have an optional star (and corresponding whitespace_after_star)
  • StarredElement is now a BaseExpression

Test Plan

  • roundtrip tests
  • negative parse tests
  • parse tests
  • node construction tests

TODO

  • Maybe make whitespace_after_star into a MaybeSentinel instead of Optional and add corresponding codegen logic

@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 Jun 12, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jun 12, 2022

Codecov Report

Merging #696 (0130225) into main (380f045) will decrease coverage by 0.02%.
The diff coverage is 82.05%.

@@            Coverage Diff             @@
##             main     #696      +/-   ##
==========================================
- Coverage   94.82%   94.79%   -0.03%     
==========================================
  Files         246      246              
  Lines       25653    25689      +36     
==========================================
+ Hits        24325    24353      +28     
- Misses       1328     1336       +8     
Impacted Files Coverage Δ
libcst/_nodes/tests/base.py 98.29% <ø> (ø)
libcst/matchers/_return_types.py 100.00% <ø> (ø)
libcst/_nodes/tests/test_funcdef.py 86.66% <78.57%> (-6.89%) ⬇️
libcst/_nodes/expression.py 96.66% <80.00%> (-0.13%) ⬇️
libcst/_typed_visitor.py 97.00% <83.33%> (-0.04%) ⬇️
libcst/matchers/__init__.py 100.00% <100.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 380f045...0130225. Read the comment docs.

@zsol zsol merged commit ebe1851 into main Jun 13, 2022
@zsol zsol deleted the pep-646 branch June 13, 2022 15:52
@zsol zsol mentioned this pull request Jun 13, 2022
@tusharsadhwani
Copy link

Can whitespace_after_star not be a MaybeSentinel then? Are there complications?

@zsol
Copy link
Member Author

zsol commented Jun 14, 2022

@tusharsadhwani I decided against it because there doesn't seem to be any difference in behavior (the value of None always translates to the same as MaybeSentinel would) and Optional seems more semantically correct. I'm open to be convinced otherwise, though

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Sep 16, 2022
0.4.7 - 2022-07-12

Fixed
* Fix get_qualified_names_for matching on prefixes of the given name by @lpetre in Instagram/LibCST#719

Added
* Implement lazy loading mechanism for expensive metadata providers by @Chenguang-Zhu in Instagram/LibCST#720


0.4.6 - 2022-07-04

New Contributors
- @superbobry made their first contribution in Instagram/LibCST#702

Fixed
- convert_type_comments now preserves comments following type comments by @superbobry in Instagram/LibCST#702
- QualifiedNameProvider optimizations
  - Cache the scope name prefix to prevent scope traversal in a tight loop by @lpetre in Instagram/LibCST#708
  - Faster qualified name formatting by @lpetre in Instagram/LibCST#710
  - Prevent unnecessary work in Scope.get_qualified_names_for_ by @lpetre in Instagram/LibCST#709
- Fix parsing of parenthesized empty tuples by @zsol in Instagram/LibCST#712
- Support whitespace after ParamSlash by @zsol in Instagram/LibCST#713
- [parser] bail on deeply nested expressions by @zsol in Instagram/LibCST#718


0.4.5 - 2022-06-17

New Contributors

-   @zzl0 made their first contribution in Instagram/LibCST#704

Fixed

-   Only skip supported escaped characters in f-strings by @zsol in Instagram/LibCST#700
-   Escaping quote characters in raw string literals causes a tokenizer error by @zsol in Instagram/LibCST#668
-   Corrected a code example in the documentation by @zzl0 in Instagram/LibCST#703
-   Handle multiline strings that start with quotes by @zzl0 in Instagram/LibCST#704
-   Fixed a performance regression in libcst.metadata.ScopeProvider by @lpetre in Instagram/LibCST#698


0.4.4 - 2022-06-13

New Contributors

-   @adamchainz made their first contribution in Instagram/LibCST#688

Added

-   Add package links to PyPI by @adamchainz in Instagram/LibCST#688
-   native: add overall benchmark by @zsol in Instagram/LibCST#692
-   Add support for PEP-646 by @zsol in Instagram/LibCST#696

Updated

-   parser: use references instead of smart pointers for Tokens by @zsol in Instagram/LibCST#691
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