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
Unable to format 3.10 code with a match
statement
#216
Comments
I think this is because LibCST only supports 3.10 syntax using the new rust parser, which is not yet enabled by default. Try setting
|
Yup, that works. Should that be documented somewhere to save others being confused? What's the default plan? Can it maybe be default / set for >= 3.10? 3.10 is pretty common now.
|
amyreese
added a commit
that referenced
this issue
Mar 12, 2023
Adds a helper function to detect the presence of the `libcst.native` parser module, and enable its use in LibCST appropriately. If the native module is not available, or it does not contain the `parse_module` function that we expect to use, then the native parser is not enabled. Adds support for parsing 3.10 match statements, as well as future syntax that requires use of the PEG parsing features only available in LibCST's native parser. This is currently only enabled in the µsort CLI entrypoint. Programs using the µsort API directly will need to call or enable the native parser separately if desired. Fixes #216 [ghstack-poisoned]
amyreese
added a commit
that referenced
this issue
Mar 12, 2023
Adds a helper function to detect the presence of the `libcst.native` parser module, and enable its use in LibCST appropriately. If the native module is not available, or it does not contain the `parse_module` function that we expect to use, then the native parser is not enabled. Adds support for parsing 3.10 match statements, as well as future syntax that requires use of the PEG parsing features only available in LibCST's native parser. This is currently only enabled in the µsort CLI entrypoint. Programs using the µsort API directly will need to call or enable the native parser separately if desired. Fixes #216 ghstack-source-id: 1cfca9b1e87903e4e4ea8ec0548c5b349c0e7300 Pull Request resolved: #244
amyreese
added a commit
that referenced
this issue
Mar 12, 2023
Adds a helper function to detect the presence of the `libcst.native` parser module, and enable its use in LibCST appropriately. If the native module is not available, or it does not contain the `parse_module` function that we expect to use, then the native parser is not enabled. Adds support for parsing 3.10 match statements, as well as future syntax that requires use of the PEG parsing features only available in LibCST's native parser. This is currently only enabled in the µsort CLI entrypoint. Programs using the µsort API directly will need to call or enable the native parser separately if desired. Fixes #216 [ghstack-poisoned]
amyreese
added a commit
that referenced
this issue
Mar 12, 2023
Adds a helper function to detect the presence of the `libcst.native` parser module, and enable its use in LibCST appropriately. If the native module is not available, or it does not contain the `parse_module` function that we expect to use, then the native parser is not enabled. Adds support for parsing 3.10 match statements, as well as future syntax that requires use of the PEG parsing features only available in LibCST's native parser. This is currently only enabled in the µsort CLI entrypoint. Programs using the µsort API directly will need to call or enable the native parser separately if desired. Fixes #216 ghstack-source-id: 71a1b574178e55e439220644d475b591fb3a6069 Pull Request resolved: #244
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I believe I have valid python 3.10 syntax in nmapsanner.py as my running + unittests pass. Should this code be supported by usort main? If not, here is some sample code to work with to add support.
Error and repro
git clone git@github.com:cooperlees/nmapscanner.git
python3 -m venv /tmp/test_usort
/tmp/test_usort/bin/pip install git+https://github.com/facebook/usort
Cheers
The text was updated successfully, but these errors were encountered: