]> git.madduck.net Git - etc/vim.git/commit

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Jupyter notebook support (#2357)
authorMarco Edward Gorelli <marcogorelli@protonmail.com>
Fri, 6 Aug 2021 20:57:46 +0000 (21:57 +0100)
committerGitHub <noreply@github.com>
Fri, 6 Aug 2021 20:57:46 +0000 (16:57 -0400)
commitb1d060101626aa1c332f52e4bdf0ae5e4cc07990
treec5dbb32baf8924a47b54df5822c5c679690f4eec
parente76adbecb8c3b62631868332c3b632363c7c16b4
Jupyter notebook support (#2357)

To summarise, based on what was discussed in that issue:

due to not being able to parse automagics (e.g. pip install black)
without a running IPython kernel, cells with syntax which is parseable
by neither ast.parse nor IPython will be skipped cells with multiline
magics will be skipped trailing semicolons will be preserved, as they
are often put there intentionally in Jupyter Notebooks to suppress
unnecessary output

Commit history before merge (excluding merge commits):

* wip
* fixup tests
* skip tests if no IPython
* install test requirements in ipynb tests
* if --ipynb format all as ipynb
* wip
* add some whole-notebook tests
* docstrings
* skip multiline magics
* add test for nested cell magic
* remove ipynb_test.yml, put ipynb tests in tox.ini
* add changelog entry
* typo
* make token same length as magic it replaces
* only include .ipynb by default if jupyter dependencies are found
* remove logic from const
* fixup
* fixup
* re.compile
* noop
* clear up
* new_src -> dst
* early exit for non-python notebooks
* add non-python test notebook
* add repo with many notebooks to black-primer
* install extra dependencies for black-primer
* fix planetary computer examples url
* dont run on ipynb files by default
* add scikit-lego (Expected to change) to black-primer
* add ipynb-specific diff
* fixup
* run on all (including ipynb) by default
* remove --include .ipynb from scikit-lego black-primer
* use tokenize so as to mirror the exact logic in IPython.core.displayhooks quiet
* fixup
* :art:
* clarify docstring
* add test for when comment is after trailing semicolon
* enumerate(reversed) instead of [::-1]
* clarify docstrings
* wip
* use jupyter and no_jupyter marks
* use THIS_DIR
* windows fixup
* perform safe check cell-by-cell for ipynb
* only perform safe check in ipynb if not fast
* remove redundant Optional
* :art:
* use typeguard
* dont process cell containing transformed magic
* require typing extensions before 3.10 so as to have TypeGuard
* use dataclasses
* mention black[jupyter] in docs as well as in README
* add faq
* add message to assertion error
* add test for indented quieted cell
* use tokenize_rt else we cant roundtrip
* fmake fronzet set for tokens to ignore when looking for trailing semicolon
* remove planetary code examples as recent commits result in changes
* use dataclasses which inherit from ast.NodeVisitor
* bump typing-extensions so that TypeGuard is available
* bump typing-extensions in Pipfile
* add test with notebook with empty metadata
* pipenv lock
* deprivative validate_cell
* Update README.md
* Update docs/getting_started.md
* dont cache notebooks if jupyter dependencies arent found
* dont write to cache if jupyter deps are not installed
* add notebook which cant be parsed
* use clirunner
* remove other subprocess calls
* add docstring
* make verbose and quiet keyword only
* :art:
* run second many test on directory, not on file
* test for warning message when running on directory
* early return from non-python cell magics
* move NothingChanged to report to avoid circular import
* remove circular import
* reinstate --ipynb flag

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
28 files changed:
.github/workflows/primer.yml
.gitignore
.pre-commit-hooks.yaml
CHANGES.md
Pipfile
README.md
docs/faq.md
docs/getting_started.md
pyproject.toml
setup.py
src/black/__init__.py
src/black/const.py
src/black/files.py
src/black/handle_ipynb_magics.py [new file with mode: 0644]
src/black/mode.py
src/black/output.py
src/black/report.py
src/black_primer/primer.json
tests/data/non_python_notebook.ipynb [new file with mode: 0644]
tests/data/notebook_empty_metadata.ipynb [new file with mode: 0644]
tests/data/notebook_no_trailing_newline.ipynb [new file with mode: 0644]
tests/data/notebook_trailing_newline.ipynb [new file with mode: 0644]
tests/data/notebook_which_cant_be_parsed.ipynb [new file with mode: 0644]
tests/data/notebook_without_changes.ipynb [new file with mode: 0644]
tests/test_black.py
tests/test_ipynb.py [new file with mode: 0644]
tests/test_no_ipynb.py [new file with mode: 0644]
tox.ini