-
Notifications
You must be signed in to change notification settings - Fork 196
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
_INDENT_RE
is too narrow - '\x0c '
is strange but valid indent whitespace
#446
Comments
uhhhh... thanks? :) 🥇 |
You're, uh, welcome. I really am sorry 😅 FWIW I've worked around this, so if you want to just close it as out-of-scope I will be perfectly fine with that. |
If anyone is curious... Documentation about the formfeed character is here: https://docs.python.org/3.9/reference/lexical_analysis.html#indentation It gets handled here in It looks like it was originally added to accommodate this emacs usecase, but the exact details about how it's handled are a bit weird (it resets the column counter). |
Ultracrepidarian comment here: The character here is a good repro... def foo():
class A:
pass
return A as shown in: ~/code/libcst >>> ./venv/bin/hatch run ipython ±[●][main]
Python 3.10.10 (main, Mar 5 2023, 22:26:53) [GCC 12.2.1 20230201]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.13.2 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import libcst as cst
In [2]: MOD = 'def foo():\n \x0c class A:\n\x0c pass\n return A'
In [3]: c = compile(MOD, "__main__", "exec")
In [4]: exec(c)
In [5]: foo()
Out[5]: __main__.foo.<locals>.A now passing MOD through parse_module
I think this is a good start to look at this |
While working on my
shed
autoformatter, which includes some libcst-based passes, Hypothesmith uncovered a bug:LibCST/libcst/_parser/types/config.py
Line 20 in c22ed6a
For example,
'class A:\n\x0c pass\n'
is a valid class-declaration. It can even be parsed bylibcst.parse_module()
, but the refactoring tooling chokes on it.(this is a terrible bug to report and I hope it never happens in the wild, but there you go!)
The text was updated successfully, but these errors were encountered: