Skip to content

Commit cd57f68

Browse files
authored
Revert type changes for BuildHookInterface (#2440)
1 parent 5c6dc6c commit cd57f68

8 files changed

Lines changed: 22 additions & 26 deletions

File tree

‎backend/src/hatchling/builders/binary.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66

77
from hatchling.builders.config import BuilderConfig
88
from hatchling.builders.plugin.interface import BuilderInterface
9-
from hatchling.plugin.manager import PluginManager
109

1110
if TYPE_CHECKING:
1211
from collections.abc import Callable
1312

1413

15-
class BinaryBuilderConfig(BuilderConfig[PluginManager]):
14+
class BinaryBuilderConfig(BuilderConfig):
1615
SUPPORTED_VERSIONS = ("3.12", "3.11", "3.10", "3.9", "3.8", "3.7")
1716

1817
def __init__(self, *args: Any, **kwargs: Any) -> None:
@@ -83,7 +82,7 @@ def pyapp_version(self) -> str:
8382
return self.__pyapp_version
8483

8584

86-
class BinaryBuilder(BuilderInterface[BinaryBuilderConfig, PluginManager]):
85+
class BinaryBuilder(BuilderInterface):
8786
"""
8887
Build binaries
8988
"""

‎backend/src/hatchling/builders/config.py‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,25 @@
33
import os
44
from contextlib import contextmanager
55
from functools import cached_property
6-
from typing import TYPE_CHECKING, Any, Generic, TypeVar
6+
from typing import TYPE_CHECKING, Any, TypeVar
77

88
import pathspec
99

1010
from hatchling.builders.constants import DEFAULT_BUILD_DIRECTORY, EXCLUDED_DIRECTORIES, BuildEnvVars
1111
from hatchling.builders.utils import normalize_inclusion_map, normalize_relative_directory, normalize_relative_path
1212
from hatchling.metadata.utils import normalize_project_name
13-
from hatchling.plugin.manager import PluginManagerBound
1413
from hatchling.utils.fs import locate_file
1514

1615
if TYPE_CHECKING:
1716
from collections.abc import Generator
1817

19-
from typing_extensions import Self
20-
2118
from hatchling.builders.plugin.interface import BuilderInterface
2219

2320

24-
class BuilderConfig(Generic[PluginManagerBound]):
21+
class BuilderConfig:
2522
def __init__(
2623
self,
27-
builder: BuilderInterface[Self, PluginManagerBound],
24+
builder: BuilderInterface,
2825
root: str,
2926
plugin_name: str,
3027
build_config: dict[str, Any],
@@ -46,7 +43,7 @@ def __init__(
4643
self.build_reserved_paths: set[str] = set()
4744

4845
@property
49-
def builder(self) -> BuilderInterface[Self, PluginManagerBound]:
46+
def builder(self) -> BuilderInterface:
5047
return self.__builder
5148

5249
@property
@@ -864,4 +861,4 @@ def env_var_enabled(env_var: str, *, default: bool = False) -> bool:
864861
return default
865862

866863

867-
BuilderConfigBound = TypeVar("BuilderConfigBound", bound=BuilderConfig[Any])
864+
BuilderConfigBound = TypeVar("BuilderConfigBound", bound=BuilderConfig)

‎backend/src/hatchling/builders/custom.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ def __new__( # type: ignore[misc]
2121
root: str,
2222
plugin_manager: PluginManagerBound | None = None,
2323
config: dict[str, Any] | None = None,
24-
metadata: ProjectMetadata[PluginManagerBound] | None = None,
24+
metadata: ProjectMetadata | None = None,
2525
app: Application | None = None,
26-
) -> BuilderInterface[Any, PluginManagerBound]:
26+
) -> BuilderInterface:
2727
project_metadata = ProjectMetadata(root, plugin_manager, config)
2828

2929
target_config = project_metadata.hatch.build_targets.get(cls.PLUGIN_NAME, {})

‎backend/src/hatchling/builders/hooks/plugin/interface.py‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,23 @@
33
from typing import TYPE_CHECKING, Any, Generic, cast
44

55
from hatchling.builders.config import BuilderConfigBound
6-
from hatchling.plugin.manager import PluginManagerBound
76

87
if TYPE_CHECKING:
98
from hatchling.bridge.app import Application
109
from hatchling.metadata.core import ProjectMetadata
1110

1211

13-
class BuildHookInterface(Generic[BuilderConfigBound, PluginManagerBound]): # no cov
12+
class BuildHookInterface(Generic[BuilderConfigBound]): # no cov
1413
"""
1514
Example usage:
1615
1716
```python tab="plugin.py"
1817
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
19-
from hatchling.plugin.manager import PluginManager
2018
2119
from .builder import SpecialBuilderConfig
2220
2321
24-
class SpecialBuildHook(BuildHookInterface[SpecialBuilderConfig, PluginManager]):
22+
class SpecialBuildHook(BuildHookInterface[SpecialBuilderConfig]):
2523
PLUGIN_NAME = "special"
2624
...
2725
```
@@ -46,7 +44,7 @@ def __init__(
4644
root: str,
4745
config: dict[str, Any],
4846
build_config: BuilderConfigBound,
49-
metadata: ProjectMetadata[PluginManagerBound],
47+
metadata: ProjectMetadata,
5048
directory: str,
5149
target_name: str,
5250
app: Application | None = None,
@@ -91,7 +89,7 @@ def config(self) -> dict[str, Any]:
9189
return self.__config
9290

9391
@property
94-
def metadata(self) -> ProjectMetadata[PluginManagerBound]:
92+
def metadata(self) -> ProjectMetadata:
9593
# Undocumented for now
9694
return self.__metadata
9795

‎backend/src/hatchling/builders/plugin/hooks.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515

1616
@hookimpl
1717
def hatch_register_builder() -> list[type[BuilderInterface]]:
18-
return [AppBuilder, BinaryBuilder, CustomBuilder, SdistBuilder, WheelBuilder]
18+
return [AppBuilder, BinaryBuilder, CustomBuilder, SdistBuilder, WheelBuilder] # type: ignore[list-item]

‎backend/src/hatchling/builders/sdist.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
replace_file,
2222
)
2323
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION, get_core_metadata_constructors
24-
from hatchling.plugin.manager import PluginManager
2524
from hatchling.utils.constants import DEFAULT_BUILD_SCRIPT, DEFAULT_CONFIG_FILE
2625

2726
if TYPE_CHECKING:
@@ -88,7 +87,7 @@ def __exit__(
8887
self.fd.close()
8988

9089

91-
class SdistBuilderConfig(BuilderConfig[PluginManager]):
90+
class SdistBuilderConfig(BuilderConfig):
9291
def __init__(self, *args: Any, **kwargs: Any) -> None:
9392
super().__init__(*args, **kwargs)
9493

@@ -143,7 +142,7 @@ def support_legacy(self) -> bool:
143142
return self.__support_legacy
144143

145144

146-
class SdistBuilder(BuilderInterface[SdistBuilderConfig, PluginManager]):
145+
class SdistBuilder(BuilderInterface):
147146
"""
148147
Build an archive of the source files
149148
"""

‎backend/src/hatchling/builders/wheel.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
set_zip_info_mode,
2828
)
2929
from hatchling.metadata.spec import DEFAULT_METADATA_VERSION, get_core_metadata_constructors
30-
from hatchling.plugin.manager import PluginManager
3130

3231
if TYPE_CHECKING:
3332
from collections.abc import Callable, Iterable, Sequence
@@ -215,7 +214,7 @@ def __exit__(
215214
self.fd.close()
216215

217216

218-
class WheelBuilderConfig(BuilderConfig[PluginManager]):
217+
class WheelBuilderConfig(BuilderConfig):
219218
def __init__(self, *args: Any, **kwargs: Any) -> None:
220219
super().__init__(*args, **kwargs)
221220

@@ -493,7 +492,7 @@ def get_raw_fs_path_name(directory: str, name: str) -> str: # noqa: ARG004
493492
return name
494493

495494

496-
class WheelBuilder(BuilderInterface[WheelBuilderConfig, PluginManager]):
495+
class WheelBuilder(BuilderInterface):
497496
"""
498497
Build a binary distribution (.whl file)
499498
"""

‎docs/history/hatchling.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88

99
## Unreleased
1010

11+
***Fixed:***
12+
13+
- Revert the extra type parameter added to `BuildHookInterface` in 1.32.3, which broke plugins that subscripted the interface with a single argument (e.g. `BuildHookInterface[MyConfig]`) by raising `TypeError` at import time. `BuilderConfig` is likewise no longer generic, restoring the pre-1.32.3 plugin interface.
14+
1115
## [1.32.3](https://github.com/pypa/hatch/releases/tag/hatchling-v1.32.3) - 2026-09-17 ## {: #hatchling-v1.32.3 }
1216

1317

0 commit comments

Comments
 (0)