diff --git a/CHANGES/+api_quirk.removal b/CHANGES/+api_quirk.removal new file mode 100644 index 000000000..8d6cbfe5a --- /dev/null +++ b/CHANGES/+api_quirk.removal @@ -0,0 +1 @@ +Removed deprecated `api_quirk` decorator. Use `api_spec_quirk` instead. diff --git a/pulp-glue/src/pulp_glue/common/context.py b/pulp-glue/src/pulp_glue/common/context.py index ff9a11aa6..d51297d0b 100644 --- a/pulp-glue/src/pulp_glue/common/context.py +++ b/pulp-glue/src/pulp_glue/common/context.py @@ -139,34 +139,9 @@ def preprocess_payload(payload: EntityDefinition) -> EntityDefinition: ) -_REGISTERED_API_QUIRKS: list[tuple[PluginRequirement, t.Callable[[OpenAPI], None]]] = [] _REGISTERED_API_SPEC_QUIRKS: list[tuple[PluginRequirement, t.Callable[[t.Any], t.Any]]] = [] -@deprecated("This decorator is deprecated. Please use api_spec_quirk instead.") -def api_quirk( - req: PluginRequirement, -) -> t.Callable[[t.Callable[[OpenAPI], None]], None]: - """ - A function decorator to allow manipulating API specs based on the availability of plugins. - - Parameters: - req: The plugin specifier to determine when the quirk should be applied. - - Examples: - ``` - @api_quirk(PluginRequirement("catdog", specifier="<1.5.2")) - def patch_barking_filter_type(api: OpenAPI) -> None: - # fixup api.api_spec here - ``` - """ - - def _decorator(patch: t.Callable[[OpenAPI], None]) -> None: - _REGISTERED_API_QUIRKS.append((req, patch)) - - return _decorator - - def api_spec_quirk( req: PluginRequirement, ) -> t.Callable[[t.Callable[[t.Any], t.Any]], None]: @@ -178,8 +153,8 @@ def api_spec_quirk( Examples: ``` - @api_quirk(PluginRequirement("catdog", specifier="<1.5.2")) - def patch_barking_filter_type(api_spec: t.Any) -> None: + @api_spec_quirk(PluginRequirement("catdog", specifier="<1.5.2")) + def patch_barking_filter_type(api_spec: t.Any) -> t.Any: # Fixup api_spec here. # This can be destructive on api_spec. return api_spec @@ -407,14 +382,6 @@ def from_config(cls, config: dict[str, t.Any]) -> "t.Self": api_kwargs=api_kwargs, ) - def _patch_api_spec(self) -> None: - # A place for last minute fixes to the api_spec. - # WARNING: Operations are already indexed at this point. - assert self._api is not None - for req, patch in _REGISTERED_API_QUIRKS: - if self.has_plugin(req): - patch(self._api) - @property def domain_enabled(self) -> bool: return t.cast(bool, self.api.api_spec.get("info", {}).get("x-pulp-domain-enabled", False)) @@ -457,7 +424,6 @@ def api(self) -> OpenAPI: ) except OpenAPIError as e: raise PulpException(str(e)) - self._patch_api_spec() # Rerun scheduled version checks for plugin_requirement in self._needed_plugins: self.needs_plugin(plugin_requirement) @@ -1743,6 +1709,7 @@ def delete(self, non_blocking: bool = False) -> None: assert self.repository_ctx is not None self.repository_ctx.modify(remove_content=[self.pulp_href]) + @deprecated("The create call can handle the upload logic transparently.") def upload( self, file: t.IO[bytes],