|
80 | 80 | _ME_ENDPOINT = "/Me" |
81 | 81 |
|
82 | 82 |
|
| 83 | +def _refuse_resource_parameter(operation: str, kwargs: dict[str, Any]) -> None: |
| 84 | + """Refuse the ``resource`` parameter that ``delete`` and ``modify`` took until 0.12. |
| 85 | +
|
| 86 | + It would otherwise be passed to the HTTP library, and the request would lack its target. |
| 87 | + Will be removed in 1.0. |
| 88 | + """ |
| 89 | + if "resource" in kwargs: |
| 90 | + raise TypeError( |
| 91 | + f"{operation}() got an unexpected keyword argument 'resource'. " |
| 92 | + "Pass the resource as target." |
| 93 | + ) |
| 94 | + |
| 95 | + |
83 | 96 | class _Me: |
84 | 97 | """The resource of the authenticated client, reached under ``/Me`` (:rfc:`RFC 7644 §3.11 <7644#section-3.11>`). |
85 | 98 |
|
@@ -1506,6 +1519,7 @@ def _prepare_delete_request( |
1506 | 1519 | expected_status_codes: list[int] | None = None, |
1507 | 1520 | **kwargs: Any, |
1508 | 1521 | ) -> RequestPayload: |
| 1522 | + _refuse_resource_parameter("delete", kwargs) |
1509 | 1523 | url, _, instance = self._locate_resource(target, id, "delete") |
1510 | 1524 | req = RequestPayload( |
1511 | 1525 | expected_status_codes=expected_status_codes, |
@@ -1572,6 +1586,7 @@ def _prepare_patch_request( |
1572 | 1586 | **kwargs: Any, |
1573 | 1587 | ) -> RequestPayload: |
1574 | 1588 | """Prepare a PATCH request payload.""" |
| 1589 | + _refuse_resource_parameter("modify", kwargs) |
1575 | 1590 | # The id is optional, so the patch operation may take its place. |
1576 | 1591 | if not isinstance(id, str | Resource | None): |
1577 | 1592 | if patch_op is not None: |
|
0 commit comments