Skip to content

Entry-points for loading rule plugins #69

@abkfenris

Description

@abkfenris

Is your feature request related to a problem? Please describe.

Currently plugins need to be manually loaded before their rules are usable in a configuration. This can limit the discoverability of rules as users need to know where to import each rule plugin from.

Describe the solution you'd like

Entry-points could be used to populate rule plugins from installed packages.

# pyproject.toml
[project.entry-points."xrlint.rules"]
xcube = "xrlint.plugins.xcube"
acdd = "xrlint.plugins.acdd"

Then for most usage, instead of having to specify which plugins are loaded in a config, they can be called directly.

- recommended
- plugins:
    xcube: xrlint.plugins.xcube
- xcube/recommended  

Becomes

- recommended
- xcube/recommended  

It looks like the adaptation would probably happen in

xrlint/xrlint/config.py

Lines 54 to 60 in cbaf81a

def get_core_config_object() -> "ConfigObject":
"""Create a configuration object that includes the core plugin.
Returns:
A new `Config` object
"""
return ConfigObject(plugins={CORE_PLUGIN_NAME: get_core_plugin()})

Describe alternatives you've considered

I also thought about a constant dictionary of plugin names to paths, but that would have to be adapted to each new plugin in a third party package, rather than allowing those packages to register plugins themselves.

Additional context

We use entry points for Xpublish plugins and it works well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions