GithubHelp home page GithubHelp logo

flother / blake.novaextension Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 2.0 81 KB

A Nova extension to lint your Python source code with Flake8, and format it with Black

Home Page: https://extensions.panic.com/extensions/is.flother/is.flother.Blake/

License: MIT License

JavaScript 100.00%
nova-editor nova-extension linter python flake8

blake.novaextension's Introduction

Blake: a Nova extension for linting your Python source code with Flake8, and formatting your code with Black.

Blake runs Flake8 when you save a Python file, and reports any warnings and errors in Nova's issues sidebar. You can also choose to format your code with Black every time you save, or just using the EditorFormat Source Code with Black menu item whenever you wish (shortcut: ⌘⇧B).

Prerequisites

Before using Blake you need to install Flake8 and Black. The recommended method is to use Homebrew and Pipx.

  1. Install Homebrew
  2. Install Pipx
  3. Install Flake8: pipx install flake8
  4. Install Black: pipx install black

If everything goes to plan, the flake8 and black CLIs will be available globally.

If you do use Pipx to install Flake8 you can later install your favourite Flake8 plugins by injecting them into the virtual environment. For example, to install the flake8-docstrings plugin: pipx inject flake8 flake8-docstrings. The extra warnings and violations provided by the plugin will be immediately and automatically available to both Blake and the flake8 CLI.

Installation

You can install Blake from Nova's online extension library, or you can install it from within Nova itself (select Extension Library... from the Extensions menu and search for "blake").

If you want to install a version for development, clone the GitHub repo, open the code in Nova, and select Activate Project as Extension from the Extensions menu. Any changes you make to the code will be reflected in the extension for the duration of your Nova session.

Preferences

By default Flake8 will be run using /usr/bin/env flake8, and Black using /usr/bin/env black. However you can configure this either for one particular project or for all Python projects within Nova.

  • To configure an individual project: select Project Settings... from the Project menu, and look for the Blake environment
  • To configure all Python projects: select Extension Library... from the Extensions menu, look for Blake under Installed Extensions in the sidebar, and click Settings

An individual project's settings will override the global preferences. Blake's preferences also allow you to:

  • Format your source files every time you save (off by default)
  • Set preferred maximum line length (default unset, meaning Black decides)
  • Use Black's preview style (off by default)

For further configuration, you can configure Flake8 and set your Black preferences using the standard config files.

blake.novaextension's People

Contributors

edwardloveall avatar flother avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

blake.novaextension's Issues

Black edits being deferred by Nova during save operations

Blake process is asynchronous, and acts on the editor's buffer, but nova will save the file before Blake's actions.
You see the file after Blake's edit, but the file saved is the previous version.
This led to strange flake reports on formatting issues, as flake8 will read the saved file, but report it on the version corrected by Blake, which is correct.

I didn't find any way to tell nova to wait for the end of edit before saving, so I don't know if it can work correctly with the current nova API.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.