Package: pynblint
Many professional data scientists use Jupyter Notebook to accomplish their daily tasks, from preliminary data exploration to model prototyping. Notebooks' interactivity is particularly convenient for data-centric programming and their self-documenting nature provides excellent support for the communication of analytical results.Nevertheless, Jupyter Notebook has been often criticized for inducing bad programming habits and scarcely supporting Software Engineering best practices. To really benefit from notebooks, users should be aware of their common pitfalls and learn how to prevent them.In previous work (see"Eliciting Best Practices for Collaboration with Computational Notebooks"[1]), we introduced a catalog of 17 empirically-validated guidelines for the collaborative use of notebooks in a professional context.To foster the adoption of these best practices, we have created Pynblint, a static analysis tool for Jupyter notebooks written in Python. Pynblint reveals potential notebook defects and recommends corrective actions. It can be operated either as a standalone CLI application or as part of a CI/CD pipeline.The core linting rules of Pynblint have been derived as operationalizations of the best practices from our catalog. Nonetheless, the plug-in architecture of Pynblint enables its users to easily extend the core set of checks with their own linting rules.RequirementsPython 3.7+.InstallationPynblint can be installed withpipor another PyPI package manager:pipinstallpynblintAfter installation, we recommend exploring the command-line interface of the tool:pynblint--helpUsagePynblint can be used to analyze:a standalone notebook:pynblintpath/to/the/notebook.ipynba code repository containing notebooks:pynblintpath/to/the/project/dir/(possibly also compressed as a.ziparchive):pynblintpath/to/the/compressed/archive.zipapublicGitHub repository containing notebooks
(support for private repositories is on our roadmap 🙂):pynblint--from-githubhttps://github.com/collab-uniba/pynblintFor further information on the available options, please refer to the projectdocumentation.Catalog of best practicesIn the following, we report the catalog of empirically-validated best practices on which Pynblint is based[1].For each guideline, we specify the current state of implementation within Pynblint::white_check_mark: = "implemented":hourglass_flowing_sand: = "partially implemented / work in progress":x: = "not on our roadmap"StateBest Practice from[1]:white_check_mark:Use version control:white_check_mark:Manage project dependencies:hourglass_flowing_sand:Use self-contained environments:white_check_mark:Put imports at the beginning:white_check_mark:Ensure re-executability (re-run notebooks top to bottom):hourglass_flowing_sand:Modularize your code:hourglass_flowing_sand:Test your code:white_check_mark:Name your notebooks consistently:hourglass_flowing_sand:Stick to coding standards:hourglass_flowing_sand:Use relative paths:white_check_mark:Document your analysis:white_check_mark:Leverage Markdown headings to structure your notebook:white_check_mark:Keep your notebook clean:white_check_mark:Keep your notebook concise:x:Distinguish production and development artifacts:hourglass_flowing_sand:Make your notebooks available:white_check_mark:Make your data availableLicenseThis project is licensed under the terms of the MIT license.References[1] Luigi Quaranta, Fabio Calefato, and Filippo Lanubile. 2022.Eliciting Best Practices for Collaboration with Computational Notebooks.Proc. ACM Hum.-Comput. Interact. 6, CSCW1, Article 87 (April 2022), 41 pages.https://doi.org/10.1145/3512934