Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
A simple extension for Jupyter Notebook and Jupyter Lab to beautify Python code automatically using Black. Fork of dnanhkhoa/nb_black.
A simple extension for Jupyter Notebook and Jupyter Lab to beautify Python code automatically using Black. Fork of dnanhkhoa/nb_black with a few minor modifications:
Once loaded, automatically format syntactically correct jupyter
cells with
black
once they are run.
Enhancements compared to dnanhkhoa/nb_black:
pyproject.toml
if availableblack.TargetVersion
if
desiredblack.format_cell
to greatly simplify the codebasesetTimeout
and a delay)black
is an extremely popular python formatter. Jupyter is an
awesome way to run python. This extension helps you automatically black
en
your jupyter
.
setup.cfg
python3 -m venv .venv && source ./.venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install jupyter-black jupyter
python3 -m jupyter notebook
From here, there are two ways to load the extension:
import jupyter_black
jupyter_black.load()
To look at configuration options:
jupyter_black.load??
For example:
import black
import jupyter_black
jupyter_black.load(
lab=False,
line_length=79,
verbosity="DEBUG",
target_version=black.TargetVersion.PY310,
)
%load_ext jupyter_black
This will load the extension using your defaults from pyproject.toml
if
available, or use the black
defaults. Please note that this defaults to
lab=True
, since moving to lab instead of standalone notebook installations
seems to be the direction of the jupyter project; this means this method of
loading will only work in JupyterLab, not in a standard notebook. For now,
users running a standalone notebook (instead of lab) need to use the
recommended (configurable) loading approach above.
git clone https://github.com/n8henrie/jupyter-black && cd jupyter-black
python3 -m venv .venv
$ source ./.venv/bin/activate
$ ./.venv/bin/python -m pip install --upgrade pip
$ ./.venv/bin/python -m pip install -e .[test,dev]
Notes:
python -m playwright install --with-deps firefox
tox
will automatically run these installation steps (helpful for CI)--no-headless
flag to pytest
for local debuggingContribution ideas:
black
pyproject.toml
is searched for properlylab
,
but haven't done the work yetPlease see CONTRIBUTING.md
and TODO
.
Many thanks to dnanhkhoa/nb_black for the original version!
And of course many thanks to the black and jupyter teams.
Also, after establishing the repo and reserving the name on PyPI, I noticed
there is another library of the same name:
drillan/jupyter-black. It looks
like there have been no commits in the last 2 years, and it was never put in
PyPI, so I think at this point I'll continue with this name. Sorry if this
causes any trouble or confusion. I'll note that @drillan's library probably
does things the right way by installing as an nbextension
.
lab
and notebook
both work the same way -- a much better way -- reducing the amount of code maintenancenotebook
(<7) will need to pin an older version of jupyter-blackblack.Mode
options from pyproject.toml
that are valid for
black.Mode
. Thanks @rldotai, https://github.com/n8henrie/jupyter-black/issues/7lab=True
lab=True
(including via %load_ext
)0.x
lab=True
; %load_ext jupyter_black
will now
work in jupyterlab and no longer work in a standalone notebookFAQs
A simple extension for Jupyter Notebook and Jupyter Lab to beautify Python code automatically using Black. Fork of dnanhkhoa/nb_black.
We found that jupyter-black demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.