-
Notifications
You must be signed in to change notification settings - Fork 148
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
Pyflakes (pyls) fails when '%' is present in notebook code #281
Comments
Dunno... something in the document rewriting? What ends up in your |
Yerp, just ran into this: it's definitely some missing |
ah, i guess perhaps just demanding |
We can also access the CodeMirror token which is used for highlighting (string/comment/variable etc), but then we are going for a solution which would only work in some frontends. I like the proposed regex but However, parentheses, brackets and +/-/*/\ are not supported: This definitely needs some more unit tests. |
Yeah, magics are gross. A heavyweight approach might be to cache the actual
token names that come back from the kernel completer for %. Since the
underlying plumbing is regex based, I don't think they can be truly dynamic.
Another thing: even if it is hacked to work, other features (hover) get
broken... get_ipython is not defined. So in addition to rewriting the line,
a replacer may need to be able to add a set of valid header lines, e.g
"from IPython import get_ipython, display" to deal with autoimports, etc.
Some of these could just always be done, I suppose, which would be less
complex.
|
Did some short digging and on the IPython side they do not have a regular expression for that now - they use tokens (not sure which tokenizer, but will definitely differ from CodeMirror) and have a special case for assignments. I think we can go with the improved regexpr for now (for a release ETA this weekend), and think about a better way of transforming documents afterwards. |
Obviously, even with the improved regex, it will be still possible to break things: |
Alleviate too aggressive line magics substitution #281
Description
A weird one. Pyflakes does not work if '%' is present in code (but it is ok in comments).
I would say this is an upstream issue (of pyflakes or pyls) but it does work in plain python files - only not in notebooks.
Reproduce
Context
The text was updated successfully, but these errors were encountered: