-
Notifications
You must be signed in to change notification settings - Fork 110
How to match variable length indents? #97
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
Comments
I have been using the http://svn.python.org/projects/sandbox/trunk/2to3/scripts/find_pattern.py script to help with generating patterns based on existing source code, as suggested in http://python3porting.com/fixers.html It's quite easy to modify this script to give output like i.e. basically replacing all the string literal tokens using the but this is not recognised in bowler |
my option at the moment seems to be to manually enumerate all the indents up to some max size e.g.
this then allows me to select top-level and nested functions with the same selector (with caveat that in the modify callbacks |
Yeah, I hear you. The 2to3 grammar only supports a few names, see https://github.com/python/cpython/blob/master/Lib/lib2to3/patcomp.py#L178 ( |
I am trying to perform a select like:
This indent which I have labelled
firstnode
will have the mypy Python 2 type annotation comment attached to it as.prefix
if the funcdef has oneMy problem is that for more deeply nested functions the indent string I need to match may be 8 spaces, or 12.
It seems like it'd be really nice to be able to use an abstract
INDENT
token in the pattern rather than the specific string of space chars.I am assuming there is nothing in the pattern grammar which will help here? I assume if I do like
' '+
(four spaces, repeated - not even sure if that is valid) it won't match' '
(eight spaces)?The text was updated successfully, but these errors were encountered: