npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ryantam626/jupyterlab_black

v0.2.3

Published

A JupyterLab extension to apply Black formatter to code within codecell.

Downloads

36

Readme

NOTE

If you are using Python3.6+, feel free to use my other less hacky plugin - it supports YAPF and autopep8 as well.

However if you are using Python2 or Python(<3.5), keep going.

jupyterlab_black

npm version npm downloads

A JupyterLab extension to apply Black formatter to code within codecell.

Here is a little demo. Apologies for the horrid quality, I promise to find a better converter...

Prerequisites

  • JupyterLab
  • A Python 3.6+ anywhere on your system with black installed

Installation

From your existing environment with jupyterlab installed do the following:

jupyter labextension install @ryantam626/jupyterlab_black
pip install https://github.com/ryantam626/jupyterlab_black/archive/master.zip
jupyter serverextension enable --py jupyterlab_black

Python3.6+ Kernel Notes

Install black with something like:

conda install -c conda-forge black

OR

pip install black

Find out path of your Python by which python and that would be what to put for blackPythonBin in the Usage section.

Non-Python3.6+ Kernel Notes

If you are using kernel that are not Python3.6+, create another environment with Python3.6+ and black installed, for example (with conda, my perferred environment manager):

conda create --name py36_for_jupyterlab_black -c conda-forge python=3.6 black

Then find out where this lives by:

source activate py36_for_jupyterlab_black
which python

It should be something like /home/ryan/lib/anaconda2/envs/py36_for_jupyterlab_black/bin/python, depending on your distribution of conda, that would be what to put for blackPythonBin in the Usage section.

Usage

Head over to settings editor, and key in the python interpreter path of that Python3.6+ you have with black installed for blackPythonBin.

There is literally one option in the command palette right now:

  • Apply Black Formatter

How about a keyboard shortcut?

Add an extra extry to your keyboard shortcuts settings with something like

{"jupyterlab_black:format":{
    "command": "jupyterlab_black:format",
    "keys": [
        "Ctrl K",
        "Ctrl L"
    ],
    "selector": ".jp-Notebook.jp-mod-editMode"
}}

This basically says "Under edit mode (detected through the selector), using the chord Ctrl K + Ctrl L, invoke the jupyterlab_black:format command". And there you have it :tada:

Development

For a development install (requires npm version 4 or later), do the following in the repository directory:

pip install -e .
jupyter serverextension enable --py jupyterlab_black
npm install
npm run build
jupyter labextension install . --no-build

Get npm and jupyter to watch for changes:

npm run watch  # in terminal 1
jupyter lab --watch  # in terminal 2

Making changes in the Python part of the plugin will require a rerun of jupyter lab --watch sadly.