Skip to content

Commit 70ea87f

Browse files
Scaffold out plugin system using pluggy (#185)
1 parent 7407db7 commit 70ea87f

File tree

7 files changed

+45
-1
lines changed

7 files changed

+45
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ and this project attempts to adhere to [Semantic Versioning](https://semver.org/
1818

1919
## [Unreleased]
2020

21+
### Added
22+
23+
- Added plugin system infrastructure using `pluggy`.
24+
2125
## [0.14.2]
2226

2327
### Changed

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ classifiers = [
5555
"Programming Language :: Python :: 3.13",
5656
"Programming Language :: Python :: Implementation :: CPython"
5757
]
58-
dependencies = ["cachetools>=5.5.0", "django>=4.2"]
58+
dependencies = [
59+
"cachetools>=5.5.0",
60+
"django>=4.2",
61+
"pluggy>=1.5.0"
62+
]
5963
description = "High-flying components for perfectionists with deadlines"
6064
dynamic = ["version"]
6165
keywords = []
@@ -119,6 +123,7 @@ fail_under = 98
119123
[tool.coverage.run]
120124
omit = [
121125
"src/django_bird/migrations/*",
126+
"src/django_bird/plugins/*", # TODO: remove when plugin hooks implemented
122127
"src/django_bird/_typing.py",
123128
"src/django_bird/views.py", # TODO: remove when not empty
124129
"tests/*"

src/django_bird/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
from __future__ import annotations
22

3+
from pluggy import HookimplMarker
4+
35
__version__ = "0.14.2"
6+
7+
hookimpl = HookimplMarker("django_bird")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from __future__ import annotations
2+
3+
from .manager import pm
4+
5+
__all__ = [
6+
"pm",
7+
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from __future__ import annotations
2+
3+
from pluggy import HookspecMarker
4+
5+
hookspec = HookspecMarker("django_bird")

src/django_bird/plugins/manager.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from __future__ import annotations
2+
3+
import importlib
4+
5+
import pluggy
6+
7+
from django_bird.plugins import hookspecs
8+
9+
pm = pluggy.PluginManager("django_bird")
10+
pm.add_hookspecs(hookspecs)
11+
12+
DEFAULT_PLUGINS: list[str] = []
13+
14+
for plugin in DEFAULT_PLUGINS:
15+
mod = importlib.import_module(plugin)
16+
pm.register(mod, plugin)

uv.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)