microsoft / microsoft/typespec
[http-client-python] delegation pattern does not scale
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
Currently, we allow the delegation pattern. However, if the service team wants to wrap just one operation under this pattern but leave the rest as is, they'll still need to redefine all the methods again in the patch file. This is redundant and inefficient.
Ex.
```py
class CustomClient:
def __init__(...):
self._client = GeneratedClient(...)
def some_method(...):
val = self._client.some_method(...)
# custom behavior
...
def foo(...):
self._client.foo(...)
def bar(...):
self._client.bar(...)
def send_request(...):
self._client.send_request(...)
```
Potential options:
- Add a mixin with all methods that will be inherited by the patched client, separate from the delegated client/operations.
- Don't use the delegation pattern
Contributor guide
Assessment
This issue has not been assessed yet.