This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1241 from interval/async-metadata-props
Allow all `io.display.metadata` `data` item props to be async (except `label`)
- Loading branch information
Showing
9 changed files
with
210 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -599,13 +599,33 @@ async def io_display_metadata(io: IO): | |
default_value="list", | ||
) | ||
|
||
def sync_fn(): | ||
return "Called it" | ||
|
||
async def async_fn(): | ||
await asyncio.sleep(1.5) | ||
return "Done!" | ||
|
||
async def another(): | ||
await asyncio.sleep(2) | ||
return "Slept!" | ||
|
||
async def raises_error(): | ||
raise Exception("Oops!") | ||
|
||
await io.display.metadata( | ||
"User info", | ||
layout=layout, | ||
data=[ | ||
{"label": "Name", "value": "Alex"}, | ||
{"label": "Email", "value": "[email protected]"}, | ||
{"label": "Not defined"}, | ||
{"label": "Friends", "value": 24}, | ||
{"label": "None", "value": None}, | ||
{"label": "Function", "value": sync_fn}, | ||
{"label": "Async function", "value": async_fn}, | ||
{"label": "Raises an error", "value": raises_error}, | ||
{"label": "Task", "value": another()}, | ||
], | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.