-
-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api : Encoded certain endpoint parameters. #634
base: main
Are you sure you want to change the base?
Conversation
Deprecating is not the same as removing—we still want to support the old syntax with a warning for some deprecation period. Also, this is not the only function affected by this issue. |
228488e
to
78a8dcb
Compare
Hey @andersk , upon /integrations/jabber/jabber_mirror_backend.py:278: stream_infos = get_stream_infos("subscriptions", zulipToJabber.client.list_subscriptions) ./integrations/bridge_with_irc/irc_mirror_backend.py:39: resp = self.zulip_client.list_subscriptions() ./build/lib/integrations/jabber/jabber_mirror_backend.py:278: stream_infos = get_stream_infos("subscriptions", zulipToJabber.client.list_subscriptions) ./build/lib/integrations/bridge_with_irc/irc_mirror_backend.py:39: resp = self.zulip_client.list_subscriptions() ./build/lib/zulip/examples/list-subscriptions:21:print(client.list_subscriptions()) ./build/lib/zulip/__init__.py:1281: def list_subscriptions(self, request: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Dict[str, Any]: ./zulip/examples/list-subscriptions:21:print(client.list_subscriptions()) ./zulip/__init__.py:1281: def list_subscriptions(self, request: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Dict[str, Any]: But none of them have a parameter of |
These all share the same antipattern: def get_profile(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
def update_presence(self, request: Dict[str, Any]) -> Dict[str, Any]:
def get_users(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
def get_members(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
def list_subscriptions(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
def mute_topic(self, request: Dict[str, Any]) -> Dict[str, Any]:
def render_message(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
def create_user(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
def update_storage(self, request: Dict[str, Any]) -> Dict[str, Any]:
def get_storage(self, request: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
def set_typing_status(self, request: Dict[str, Any]) -> Dict[str, Any]: |
78a8dcb
to
f1a8470
Compare
Is there any changes to be made @andersk ? Or should I go ahead to fix failing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aryanshridhar I left some feedback on what you have so far.
@andersk Would a decorator to handle the migration work here, do you think? |
A decorator might have the disadvantage of making the pydoc confusing and the mypy types poor (all mypy can guarantee about a decorator is basically “congratulations, you have a function!”). A helper function pattern like this would be fine: def deprecated_request(request: Optional[Dict[str, Any]]) -> Dict[str, Any]:
if request is not None:
logger.warning(…)
return request
return {}
def list_subscriptions(self, request: Optional[Dict[str, Any]] = None, **kwargs: Any) -> Dict[str, Any]:
return self.call_endpoint(…, request={**deprecated_request(request), **kwargs}) |
@andersk I agree that this approach is simple - and almost suggested something similar, ie. putting all of the deprecation-migration code together. Re decorators, I did think mypy could handle them - since we have them annotated in the main repo - though I suppose it's one thing to annotate and another to know what is actually validated via them being present. I'd also have thought |
f1a8470
to
1cf3724
Compare
I think this change makes sense to me -- @aryanshridhar can you rebase this? I'm a bit reluctant to merge this while we're unable to update (Or did we resolve that issue and I just didn't notice?) |
1cf3724
to
9eca925
Compare
9eca925
to
7370a8e
Compare
940cd5d
to
5abce43
Compare
Rectified the parameters in certain api endpoints to , take up default parameters rather than a dictionary. Affected endpoints: GET get_profile POST update_presence GET get_users GET get_members GET get_subscriptions PATCH mute_topic POST render_message POST create_user PUT update_storage GET get_storage POST set_typing_status As discussed within zulip/zulip#16698.
5abce43
to
20d2e59
Compare
In zulip/python-zulip-api#634, certain endpoint parameters were encoded to make the function callable by passing the arguements, rather than passing them as a dictionary. Following api endpoints are affected within the docs: POST update_presence GET get_members PATCH mute_topic POST render_message POST create_user POST set_typing_status
Rebased it @timabbott, As far as I remember, there was no further work done related to this pr in zulip/zulip. |
I'm going to hold off on this until after #692; let's chat about it next week. |
@aryanshridhar can you rebase this? |
Heads up @aryanshridhar, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
Rectified parameters in certain api endpoints to deprecate dictionary parameters .
Affected Endpoints :
As discussed within zulip/zulip#16698