Added --surround-invalid-expressions-with-single-quotes#315
Open
leanderbuerkin wants to merge 1 commit into
Open
Added --surround-invalid-expressions-with-single-quotes#315leanderbuerkin wants to merge 1 commit into
leanderbuerkin wants to merge 1 commit into
Conversation
…s the invalid expressions with ast.parse()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hellau,
Thanks for this nice repository to create stubs!
I had an issue: Using '--print-invalid-expressions-as-is' I could not use ast.parse() to postprocess these invalid expression. If Not setting this flag replaces them with ellipses - so also not good.
My suggestion is, to surround the invalid expressions found in type annotations with single quotes.
This way they are represented as ast.Constant() by ast.parse().
I did test it on my own project creating stub files for casadi and it worked flawlessly.
I did not write any tests since I wanted your feedback first. E.g. if Printer.invalid_expr_as_ellipses should be removed, since there is a better option or if surrounding by quotes should even become the default from now on.
Greetings
Leander