-
Notifications
You must be signed in to change notification settings - Fork 141
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
Handle IPython line magics and shell assignments #3
Comments
The current workaround of replacing line magics with "pass" (for Python) and skipping cell magics works but has a drawback: the imported cell/line magics are not included in the virtual document, thus there are false-positive linter messages like "X is imported but unused". A more robust workaround would add a function call for the magic, reflecting what IPython would do (after initial parsing to determine the magic to be used) - thus the magic would be used in the code. Ideally, we would allow the user to define custom regular expressions, for example parsing R-magic: %%R -i input_variable -o output_variable
some R code into # noqa
output_variable = R(input_variable) while this would not work if executed, this is not the goal here - what we want is that the linter registers the that
An initial set of rules (sensible defaults), per language, could be defined in the settings, allowing the user to disable any or all of them and add their own regular expression based rules. Notes:
Update: actually, using noqa is not needed as we can simply ignore the result of inspection for these lines. For simplicity, the regular expressions should return a single line as otherwise, the mapping between the virtual document and notebook gets more tricky. |
Current implementation demonstrated and explained in examples/Magics_and_rpy2.ipynb. |
When line magics are detected in the notebook (lines starting with '%') a non-intrusive message should be shown to the user, like that:
with options "Ignore" and "Let the server lint lines starting with '%'". This way the few languages in which this could be a false positive would not be affected. Also, we could have a blacklist of languages for which the message would not appear in the first place.
The text was updated successfully, but these errors were encountered: