Skip to content
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

Generate annotated notebook with embedded flake8 reports #127

Open
psychemedia opened this issue May 8, 2021 · 2 comments
Open

Generate annotated notebook with embedded flake8 reports #127

psychemedia opened this issue May 8, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@psychemedia
Copy link

To make it easier to check notebooks, it would be useful to generate notebooks annotated with flake8 reports at the cell level, either as a tagged report cell immediately after each code cell, or by clearing the notebook of all code cell outputs and then injecting the flake8 report into appropriate code cell outputs.

If reports are added to code cell outputs, it would be useful if they were styled with pink warning style such as used in the stale/deprecated pycodestyle_magic:

image

@psychemedia psychemedia added the enhancement New feature or request label May 8, 2021
@psychemedia psychemedia changed the title Generate annotated notebook with flake8 reports Generate annotated notebook with embedded flake8 reports May 8, 2021
@s-weigand
Copy link
Owner

I'm not too sure about this feature 🤔
While I see the usefulness, I also see the problems in having a CLI linting tool manipulate a notebook (at least for now).

  1. Running a CLI tool on a notebook that changes it on disk, can leave you in limbo (true for all CLI tools). For example, imagine the following scenario:
  • You have unsaved changes, so the CLI tool does only knows about the saved changes.
  • Based on that knowledge it changes the notebook, which might lead to data loss.
  • You get prompted the "File changed do you want to 'Reload', 'Overwrite' or 'cancel' "
    The only clean way to prevent a scenario like this would be via an editor plugin that uses the following steps:
  • Save the notebook
  • Run the CLI tool
  • Reload the notebook from disk
    If you know a plugin that allows running an arbitrary CLI tool in that way please tell me 😄
  1. There already is jupyterlab-flake8 which directly gives you feedback in your notebook.

So at least until there is an editor plugin that could prevent such a scenario (e.g. for jupyterlab) I would put this on halt (if you really want this, PR's are welcome 😉 ).

@psychemedia
Copy link
Author

Re: overwriting - I generally get my cli tools to have an option to write to a new file, or even to a new default output file (out.py, ORIGINAL_FILENAME-revised.py etc).

If I get anywhere with a PR, I'll let you know...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants