|
1 | 1 | """Base clients."""
|
2 | 2 |
|
3 | 3 | import abc
|
| 4 | +import warnings |
4 | 5 | from typing import Any, Dict, List, Optional, Union
|
5 | 6 | from urllib.parse import urljoin
|
6 | 7 |
|
@@ -341,7 +342,20 @@ class BaseCoreClient(LandingPageMixin, abc.ABC):
|
341 | 342 | factory=lambda: BASE_CONFORMANCE_CLASSES
|
342 | 343 | )
|
343 | 344 | extensions: List[ApiExtension] = attr.ib(default=attr.Factory(list))
|
344 |
| - post_request_model = attr.ib(default=BaseSearchPostRequest) |
| 345 | + post_request_model = attr.ib(default=None) |
| 346 | + |
| 347 | + @post_request_model.validator |
| 348 | + def _deprecate_post_model(self, attribute, value): |
| 349 | + """Check and raise warning if `post_request_model` is set.""" |
| 350 | + if value is not None: |
| 351 | + warnings.warn( |
| 352 | + "`post_request_model` attribute is deprecated and will be removed in 3.1", |
| 353 | + DeprecationWarning, |
| 354 | + ) |
| 355 | + |
| 356 | + def __attrs_post_init__(self): |
| 357 | + """Set default value for post_request_model.""" |
| 358 | + self.post_request_model = self.post_request_model or BaseSearchPostRequest |
345 | 359 |
|
346 | 360 | def conformance_classes(self) -> List[str]:
|
347 | 361 | """Generate conformance classes by adding extension conformance to base
|
@@ -573,7 +587,20 @@ class AsyncBaseCoreClient(LandingPageMixin, abc.ABC):
|
573 | 587 | factory=lambda: BASE_CONFORMANCE_CLASSES
|
574 | 588 | )
|
575 | 589 | extensions: List[ApiExtension] = attr.ib(default=attr.Factory(list))
|
576 |
| - post_request_model = attr.ib(default=BaseSearchPostRequest) |
| 590 | + post_request_model = attr.ib(default=None) |
| 591 | + |
| 592 | + @post_request_model.validator |
| 593 | + def _deprecate_post_model(self, attribute, value): |
| 594 | + """Check and raise warning if `post_request_model` is set.""" |
| 595 | + if value is not None: |
| 596 | + warnings.warn( |
| 597 | + "`post_request_model` attribute is deprecated and will be removed in 3.1", |
| 598 | + DeprecationWarning, |
| 599 | + ) |
| 600 | + |
| 601 | + def __attrs_post_init__(self): |
| 602 | + """Set default value for post_request_model.""" |
| 603 | + self.post_request_model = self.post_request_model or BaseSearchPostRequest |
577 | 604 |
|
578 | 605 | def conformance_classes(self) -> List[str]:
|
579 | 606 | """Generate conformance classes by adding extension conformance to base
|
|
0 commit comments