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

Use up-to-date namespace package setup for plugins #5505

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

snejus
Copy link
Member

@snejus snejus commented Nov 15, 2024

Description

Refactor beetsplug to use native namespace packages by removing __init__.py. Update documentation and setup.cfg to support namespace packages.

Changes

  • Deleted beetsplug/__init__.py.
  • Updated docs/dev/plugins.rst to reflect namespace package structure.
  • Updated mypy configuration in setup.cfg

Motivation

Adopt PEP 420 native namespace packages to simplify plugin management and eliminate the need for __init__.py.

See https://realpython.com/python-namespace-package.

This setup is backwards-compatible, so plugins using the old pkgutil-based setup will continue working fine.

The advantage with this setup is that external plugins will now be able to import modules from 'beetsplug' package for typing purposes. Previously, mypy could not resolve these modules due to presence of __init__.py.

@snejus snejus self-assigned this Nov 15, 2024
@snejus snejus requested a review from bal-e November 15, 2024 07:01
See https://realpython.com/python-namespace-package.

This setup is backwards-compatible, so plugins using the old
pkgutil-based setup will continue working fine.

This setup has an advantage where external plugins will now be able to
import modules from 'beetsplug' package for typing purposes. Previously,
mypy could not resolve these modules due to presence of `__init__.py`.
@snejus snejus force-pushed the remove-outdated-pkgutil-namespace-package branch from 2acfa64 to fd4e599 Compare November 15, 2024 07:04
@snejus snejus requested a review from Serene-Arc November 22, 2024 06:55
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

Successfully merging this pull request may close these issues.

1 participant