Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test_function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python3

import zulip

# Pass the path to your zuliprc file here.
client = zulip.Client(config_file="~/zuliprc")

# Get all streams that the user is subscribed to
result = client.list_subscriptions()
print(result)
4 changes: 2 additions & 2 deletions zulip/zulip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ def call_endpoint(self, url: Optional[str] = None, method: str = "POST", request
if v is not None:
marshalled_request[k] = v
versioned_url = API_VERSTRING + (url if url is not None else "")
return self.do_api_query(marshalled_request, versioned_url, method=method,
longpolling=longpolling, files=files, timeout=timeout)
return json.dumps(self.do_api_query(marshalled_request, versioned_url, method=method,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely don't want to do JSON dumps here -- a program accessing this wants the Python dictionary.

What I think we want to do here is sorting in #663 and in all the tools in examples/, so the main PR to do here would be to adjust examples/ appropriately.

Copy link
Member Author

@MSurfer20 MSurfer20 Mar 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timabbott Can we instead change this to

return json.loads(json.dumps(self.do_api_query(marshalled_request, versioned_url, method=method,
                                 longpolling=longpolling, files=files, timeout=timeout), sort_keys=True))

since dictionaries are ordered from Python 3.7(and CPython 3.6)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timabbott Should I instead go with the modifying examples/ approach?

Copy link
Contributor

@LoopThrough-i-j LoopThrough-i-j Mar 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will help if someone is running zulip in an env where python <= 3.6.
The only way is updating examples/.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think after thinking about this more, I'm not sure there's anything we want to do client-side -- the extra code in the examples is unlikely to be worth it.

longpolling=longpolling, files=files, timeout=timeout), sort_keys=True)

def call_on_each_event(
self,
Expand Down