Skip to main content

A package to include linters in Databricks notebooks: pycodestyle

Project description

Linters magic

Magic function for pycodestyle module in Jupyter-Lab or Databricks notebooks.

Current version: 0.1.0

Versions of dependencies:

  • python: 3.8
  • pycodestyle: 2.8.0
  • ipython: 7.17

Note that we've tested it only on Databricks notebooks

Installation

Make sure you've got the Python package pycodestyle, and this lintersmagic.

Through the Databricks interface

Usage

Enable the magic function by using the lintersmagic module in a cell

%load_ext lintersmagic

To check a cell once:

use the function as first line in your cell to check compliance with pycodestyle as such:

%%pycodestyle

To auto check each cell:

If you want this compliance checking turned on by default for each cell then run this magic line function in an empty cell:

%pycodestyle_on

You only need to call this once (observe the single %).

To turn off the auto-checking for each cell use:

%pycodestyle_off

Config options for %pycodestyle_on (version >= 0.5)

  1. The option --ignore or -i will add the the named error(s) to the ignore list

Example to ignore the errors E225 and E265:

%pycodestyle_on --ignore E225,E265

Remember to avoid spaces between declaring multiple errors.

  1. With the option --max_line_length or -m the max-line-length can be customised.

Example to set the line length to 119 characters instead of the default 79:

%pycodestyle_on --max_line_length 119

The options can be combined as well.

See notebooks in notebook directory for example use cases, as such:

Pycodestyle (notebook)

Notebook examples

Contribution

Dependencies and package

Handled by Poetry (documentation)

To get a new package:

poetry build

To install the dependencies:

poetry install

Tests

poetry run ipython tests/*.py

Useful links

  • This project adds a magic function in Ipython. Here is the documentation: Built-in magic commands

  • This project uses a callback with magic functions. Here is the documentation: IPython Events

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lintersmagic-0.1.1.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

lintersmagic-0.1.1-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page