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

Make IntoPy conversion fallible #639

Merged
merged 3 commits into from
Feb 7, 2022
Merged

Conversation

zsol
Copy link
Member

@zsol zsol commented Feb 7, 2022

Summary

This PR creates a new TryIntoPy trait which is a fallible version of IntoPy. It's an uncivilized, special-purpose version of the trait discussed here: PyO3/pyo3#1813

The point is to avoid panicking while converting the parsed CST back into Python-land when an exception is encountered during conversion; this panic is important to avoid because in some multiprocessing scenarios it can cause a crash.

While we're at it, this PR simplifies the proc-macro deriving: the new TryIntoPy trait converts Vec directly into PyTuple instead of a list.

Test Plan

Added a test to exercise the exception being thrown.

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

codecov-commenter commented Feb 7, 2022

Codecov Report

Merging #639 (e416a53) into main (f0cca36) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #639   +/-   ##
=======================================
  Coverage   94.78%   94.79%           
=======================================
  Files         245      245           
  Lines       25281    25289    +8     
=======================================
+ Hits        23963    23973   +10     
+ Misses       1318     1316    -2     
Impacted Files Coverage Δ
libcst/_parser/tests/test_parse_errors.py 100.00% <100.00%> (ø)
libcst/_parser/base_parser.py 89.28% <0.00%> (+2.38%) ⬆️

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 f0cca36...e416a53. Read the comment docs.

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.

3 participants