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
-
Retrieve the dist:
-
Install it in the libraries of your Databricks cluster
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)
- 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.
- 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)
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
Built Distribution
Hashes for lintersmagic-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d88c00ec9ff1d6668b6c7c673416f96ad43fdd5cd1da8df38c28a5113139c780 |
|
MD5 | 4c5fad6dac6d5ebe0fcb9a3b24b9abf8 |
|
BLAKE2b-256 | e1c370e360995bbd10c30139ebceeb00c4892ba85dc1e5a2be65cb386383ec50 |