csurfer / blackcellmagic Goto Github PK
View Code? Open in Web Editor NEWIPython magic command to format python code in cell using black.
License: MIT License
IPython magic command to format python code in cell using black.
License: MIT License
Any interest to uploading this to conda-forge?
believe it can be done farily easy with grayskull https://pypi.org/project/grayskull/
Any thoughts on enabling the option to format multiple (all...?) cells at once with %%black
?
Hello!
I would love if
I'm using VS Code. When I'm working on .py
files, VS Code automatically does black formatting (and import sorting!) when I save. I wish I had that in my notebooks in VS Code as well. ๐ฅฒ
If I have time I may dig into how I add that.
Is it possible to avoid having to type out the magic and execute for every cell?
Thanks for your work on this project. I certainly found it useful. I recently learnt about https://jupyterlab-code-formatter.readthedocs.io/en/latest/index.html and I will likely use that now.
It seems a little weird to have a new line at the end of the cell. As far as I understand, the purpose for the new line at the end of the file is for versioning, but in jupyder notebooks, the code of each cell is already contained just a single line. Should the default behavior be to not end each cell with a new line?
Running with 19.3b0 gives the following error:
[blah-blah]python3.6/site-packages/blackcellmagic.py in black(self, line, cell)
39 if cell:
40 self.shell.set_next_input(
---> 41 format_str(src_contents=cell, line_length=line_length),
42 replace=True,
43 )
TypeError: format_str() got an unexpected keyword argument 'line_length'
It seems like this is a result of some changes to how format_str
works. I believe line_length
is determined by mode
now.
Downgrading black by pip install black==18.9b0
fixes this issue.
Thank you for the extension. Do you know -- is there a way that I can set the --line_length=79
by default (so I don't have to write that out each time)?
Thanks again.
blackcellmagic
is incompatible with the latest black version because of the pin in pyproject.toml
. Created this PR #15 to relax the dependencies.
When formatting cells with magic in it, like
[...]
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
%matplotlib inline
the %%black magic returns the error
cannot parse: 12:0 %matplotlib inline
This happens with any line that has a % sign to indicate magic.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.