GithubHelp home page GithubHelp logo

aeron / black.novaextension Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 2.0 89 KB

Nova extension to use Black, the uncompromising Python code formatter.

License: Apache License 2.0

JavaScript 100.00%
formatter nova-editor nova-extension python python-black

black.novaextension's Introduction

๐Ÿค™ Hey there, the name is Eugene

Iโ€™m a back-end (former full-stack) software engineer โ€” or developer if you like it better โ€” with 15+ years of professional experience behind my back.

Most experienced in building fast APIs, web services, app back-ends, and other microservices. Including infrastructure configuration, architecture building, and development processes management.

Currently, Iโ€™m enjoying working as a team/tech lead. Cherish working with smaller teams and companies which understand the importance of clear communication, proper tools and means, and individual performance.

Yup, Iโ€™m a big advocate for asynchronous remote working. Couldnโ€™t you tell? ๐Ÿ˜†

Sadly, I rarely have the attention or power to contribute to the open-source, yet sometimes I gladly-gladly do.

๐Ÿ›  Things I use

Here is the list of tools I occasionally utilize that could give you an idea of what interests me and what I do.

๐Ÿš€ Daily or often

Python FastAPI Pytest Go MongoDB Git GitHub GitHub Actions Gitlab Gitlab CI SemVer CalVer Docker Podman Kubernetes Helm DigitalOcean Hetzner HAProxy Fish Starship Sublime VSCode macOS

๐Ÿฅฐ Love to tinker with

Rust Zig Swift Raspberry Pi Flipper Zero

๐ŸŽฏ From time to time

HTMX SQLite Postgres EdgeDB MariaDB RethinkDB Redis ZeroMQ CircleCI Firebase Elastic Kibana Grafana AWS Nginx Caddy Bash Debian Alpine

๐Ÿšณ Prefer to avoid

PHP JS Node Django Flask Bitbucket Windows

๐Ÿ“บ Long time no see

jQuery Angular Bootstrap MySQL Mercurial SVN Rackspace

๐Ÿ’โ€โ™‚๏ธ A little bit more

Stoic and ironic, hedonistic and sarcastic.

If you believe in ๐Ÿ’ฉ like socionics, then my type is INTJ. Does it add any detail?

Hobbies and activities

  • ๐ŸŽฎ Video games
  • ๐Ÿ”ซ Practical shooting
  • ๐Ÿ’ผ Leathersmithing
  • ๐ŸŽฒ Tabletop games
  • ๐Ÿ Motorcycling
  • ๐Ÿšตโ€โ™‚๏ธ Bicycling
  • ๐Ÿคฟ Scuba diving
  • ๐Ÿ—บ Traveling and living in the World

Does anyone โ€” in general โ€” hate books, music, movies, good food, and drinks? Then no need to even mention it, I guess.

Communication

Feel free to contact me anyhow (the profile has all the credentials), create an issue, or a PR if you found anything worthy thru my repos. Iโ€™ll respond or get back to it as soon as convenient ๐Ÿ˜‰

black.novaextension's People

Contributors

aeron avatar dcwatson avatar guillaumealgis avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

black.novaextension's Issues

Conflict execution when multiple format on save is triggered

I have both black and isort install, and both of them have "format on save" feature enabled.

Occasionally, when one of the format is triggered, says black, the modification will trigger isort formating, which will then back trigger black, and the loop goes on until I manually disable one of the extension.
Sometimes, this does not happen, but yield an incorrect code. (duplicate lines with wrong indentation or syntax error)

Maybe there should be a callback to coordinate the priority of the trigger. Although IMHO, this probably should be solved on Nova's side.

command to format entire workspace

I'd love a small command to run black on the entire workspace directory. I can submit a PR if you think it's something you'd consider adding. Thanks for the nice extension!

Broken since last update

Sorry for the vague title but I'm not sure how to get more info. I think it broke with the latest version (1.1.0). Nothing happens if I invoke formatting regardless of whether it's manually or when saving files. No visible error. Nothing has changed on my side and I can successfully run black from the command line by using the same binary path that I've provided in the extension's settings. Tried reinstalling the extension and restarting Nova without luck. Nova version has not changed since it was working. Let me know if I can provide any additional information.

Plugin should only reformat Python files

Currently, the extension is only activated when a Python file is opened (which is fine) but once it is activated (and "reformat on save" is enabled) it will try and reformat every file that is saved (regardless of the file content).

This is okay-ish for most files because Black won't know what to do with it, but for (some?) JSON files Black will reformat the content on save, which is unexpected (I wasn't aware Black was able to reformat JSON files, that's probably a side-effect of JSON and Python dict sharing a similar syntax).

I think the extension should check the current buffer syntax (Python vs something else) before reformatting on save.

Format on save causing Nova 6.2 to jump to start of file

In Nova 6.2, saving a Python file with "Format a file on save" checked causes the editor to jump to the top of the file once Black has done formatting.

When working with moderately long files, you then lose your place and need to scroll back down to find your place.

Outside of this, I love having this extension. Thanks so much for providing it!

Stubs files (.pyi) are not formatted correctly

Black uses different rules to format stubs (.pyi) files : https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#typing-stub-files

Because the extension is running black by passing the python code on stdin (instead of passing the file's path as argument), the file extension cannot be picked up by Black, and the format used is not the right one.

Black[15:38:15.277000] Running /Users/guillaume/foo/venv/bin/black --quiet -

For example :

Expected formatting
from concurrent.futures import Future
from typing import Any
from _typeshed import Incomplete
from requests import Session
def wrap(self, sup, background_callback, *args_, **kwargs_): ...
PICKLE_ERROR: str
class FuturesSession(Session):
executor: Incomplete
session: Incomplete
def __init__(
    self,
    executor: Incomplete | None = ...,
    max_workers: int = ...,
    session: Session | None = ...,
    adapter_kwargs: Incomplete | None = ...,
    *args,
    **kwargs,
) -> None: ...
def request(self, *args: Any, **kwargs: Any) -> Future:
    pass
def close(self) -> None: ...
def get(self, url, **kwargs): ...
def options(self, url, **kwargs): ...
def head(self, url, **kwargs): ...
def post(
    self,
    url,
    data: Incomplete | None = ...,
    json: Incomplete | None = ...,
    **kwargs,
): ...
def put(self, url, data: Incomplete | None = ..., **kwargs): ...
def patch(self, url, data: Incomplete | None = ..., **kwargs): ...
def delete(self, url, **kwargs): ...

  
Actual Black.novaextension formatting
from concurrent.futures import Future
from typing import Any
from _typeshed import Incomplete
from requests import Session
def wrap(self, sup, background_callback, *args_, **kwargs_):
...
PICKLE_ERROR: str
class FuturesSession(Session):
executor: Incomplete
session: Incomplete
def __init__(
    self,
    executor: Incomplete | None = ...,
    max_workers: int = ...,
    session: Session | None = ...,
    adapter_kwargs: Incomplete | None = ...,
    *args,
    **kwargs,
) -> None:
    ...

def request(self, *args: Any, **kwargs: Any) -> Future:
    pass

def close(self) -> None:
    ...

def get(self, url, **kwargs):
    ...

def options(self, url, **kwargs):
    ...

def head(self, url, **kwargs):
    ...

def post(
    self,
    url,
    data: Incomplete | None = ...,
    json: Incomplete | None = ...,
    **kwargs,
):
    ...

def put(self, url, data: Incomplete | None = ..., **kwargs):
    ...

def patch(self, url, data: Incomplete | None = ..., **kwargs):
    ...

def delete(self, url, **kwargs):
    ...

  

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.