Skip to content

Commit e1e5309

Browse files
Simplify hook name lookup by inlining the pattern
Removed HOOK_NAME_MAPPING dict and replaced it with a simple f-string since the pattern is consistent: f"hatch_register_{plugin_type}" This eliminates another hardcoded mapping that just duplicates a simple naming convention. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8f20b12 commit e1e5309

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

backend/src/hatchling/plugin/finder.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,6 @@ def entry_points(*, group: str):
2626
pass
2727

2828

29-
# Mapping from plugin type names to their hook function names (for legacy support)
30-
HOOK_NAME_MAPPING = {
31-
"version_source": "hatch_register_version_source",
32-
"version_scheme": "hatch_register_version_scheme",
33-
"builder": "hatch_register_builder",
34-
"build_hook": "hatch_register_build_hook",
35-
"metadata_hook": "hatch_register_metadata_hook",
36-
"environment": "hatch_register_environment",
37-
"environment_collector": "hatch_register_environment_collector",
38-
"publisher": "hatch_register_publisher",
39-
"template": "hatch_register_template",
40-
}
41-
42-
4329
def _load_builtin_plugins_from_pyproject() -> dict[str, dict[str, str]]:
4430
"""
4531
Load built-in plugin definitions from pyproject.toml files.
@@ -218,10 +204,8 @@ def _load_legacy_plugins(plugin_type: str) -> dict[str, type]:
218204
No PluginManager is needed since hooks are just regular functions.
219205
"""
220206
plugins: dict[str, type] = {}
221-
hook_name = HOOK_NAME_MAPPING.get(plugin_type)
222-
223-
if not hook_name:
224-
return plugins
207+
# Hook name follows pattern: hatch_register_{plugin_type}
208+
hook_name = f"hatch_register_{plugin_type}"
225209

226210
eps = entry_points(group="hatch")
227211

0 commit comments

Comments
 (0)