Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: use entrypoints to extend to other formatters #231

Open
agoose77 opened this issue Jan 4, 2022 · 3 comments
Open

Feat: use entrypoints to extend to other formatters #231

agoose77 opened this issue Jan 4, 2022 · 3 comments

Comments

@agoose77
Copy link

agoose77 commented Jan 4, 2022

This would:

  • Allow independent releases of the various formatter integrations
  • Allow for new formatter integrations by other developers
@ryantam626
Copy link
Owner

Sorry for the late reply, was extremely burnt out and just switched off.

I am not quite sure what you mean here, could you please elaborate?

@leihao-git
Copy link

like SQL?

@agoose77
Copy link
Author

agoose77 commented Oct 28, 2022

Oh, I missed this! Sorry to hear that you've been burnt out Ryan, hope you've been able to take a break of some kind :/

Let's say that I wanted to use clang-format (or some other tool). If this plugin supported entry-points, it would be able to discover additional third-party formatters that provided these entry-points. This would mean that you'd end up maintaining the entry-point interface, rather than N plugin implementations. Effectively, this package just becomes a way of launching a formatted and applying the result.

E.g.

pyproject.toml

[project.entry-points.jupyterlab-code-formatter]
isort = "isort-formatter:plugin"

jupyterlab_code_formatter/plugins.py

import importlib.metadata

def load_formatters():
    entry_points = importlib.metadata.entry_points(group="jupyterlab-code-formatter")
    return {
        ep.name: ep.load() for ep in entry_points
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants