A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
docs: update docstrings to Google Style format (#3219)
devin-ai-integration[bot]5219514bb75e
diff --git a/marimo/_output/data/data.py b/marimo/_output/data/data.pyindex b9f3a91822..2217363919 100644--- a/marimo/_output/data/data.py+++ b/marimo/_output/data/data.py@@ -16,13 +16,11 @@ from marimo._runtime.virtual_file import (def pdf(data: bytes) -> VirtualFile:"""Create a virtual file from a PDF.- **Args.**+ Args:+ data: PDF data in bytes- - data: PDF data in bytes-- **Returns.**-- A `VirtualFile` object.+ Returns:+ A `VirtualFile` object."""item = VirtualFileLifecycleItem(ext="pdf", buffer=data)item.add_to_cell_lifecycle_registry()@@ -32,13 +30,11 @@ def pdf(data: bytes) -> VirtualFile:def image(data: bytes, ext: str = "png") -> VirtualFile:"""Create a virtual file from an image.- **Args.**-- - data: Image data in bytes-- **Returns.**+ Args:+ data: Image data in bytes- A `VirtualFile` object.+ Returns:+ A `VirtualFile` object."""item = VirtualFileLifecycleItem(ext=ext, buffer=data)item.add_to_cell_lifecycle_registry()@@ -48,13 +44,11 @@ def image(data: bytes, ext: str = "png") -> VirtualFile:def audio(data: bytes, ext: str = "wav") -> VirtualFile:"""Create a virtual file from audio.- **Args.**+ Args:+ data: Audio data in bytes- - data: Audio data in bytes-- **Returns.**-- A `VirtualFile` object.+ Returns:+ A `VirtualFile` object."""item = VirtualFileLifecycleItem(ext=ext, buffer=data)item.add_to_cell_lifecycle_registry()@@ -64,14 +58,12 @@ def audio(data: bytes, ext: str = "wav") -> VirtualFile:def csv(data: Union[str, bytes, io.BytesIO]) -> VirtualFile:"""Create a virtual file for CSV data.- **Args.**-- - data: CSV data in bytes, or string representing a data URL, external URL- or a Pandas DataFrame-- **Returns.**+ Args:+ data: CSV data in bytes, or string representing a data URL, external URL+ or a Pandas DataFrame- A `VirtualFile` object.+ Returns:+ A `VirtualFile` object."""return any_data(data, ext="csv") # type: ignore@@ -79,14 +71,12 @@ def csv(data: Union[str, bytes, io.BytesIO]) -> VirtualFile:def json(data: Union[str, bytes, io.BytesIO]) -> VirtualFile:"""Create a virtual file for JSON data.- **Args.**+ Args:+ data: JSON data in bytes, or string representing a data URL, external URL+ or a Pandas DataFrame- - data: JSON data in bytes, or string representing a data URL, external URL- or a Pandas DataFrame-- **Returns.**-- A `VirtualFile` object.+ Returns:+ A `VirtualFile` object."""return any_data(data, ext="json") # type: ignore@@ -94,13 +84,11 @@ def json(data: Union[str, bytes, io.BytesIO]) -> VirtualFile:def js(data: str) -> VirtualFile:"""Create a virtual file for JavaScript data.- **Args.**-- - data: JavaScript data as a string-- **Returns.**+ Args:+ data: JavaScript data as a string- A `VirtualFile` object.+ Returns:+ A `VirtualFile` object."""return any_data(data, ext="js")@@ -108,13 +96,11 @@ def js(data: str) -> VirtualFile:def html(data: str) -> VirtualFile:"""Create a virtual file for HTML data.- **Args.**+ Args:+ data: HTML data as a string- - data: HTML data as a string-- **Returns.**-- A `VirtualFile` object.+ Returns:+ A `VirtualFile` object."""return any_data(data, ext="html")@@ -125,14 +111,12 @@ def any_data(data: Union[str, bytes, io.BytesIO], ext: str) -> VirtualFile:It can be a string, bytes, or a file-like object.For external URLs, these are passed through as-is.- **Args.**-- - data: Data in bytes, or string representing a data URL or external URL- - ext: File extension-- **Returns.**+ Args:+ data: Data in bytes, or string representing a data URL or external URL+ ext: File extension- A `VirtualFile` object.+ Returns:+ A `VirtualFile` object."""if data is None:return EMPTY_VIRTUAL_FILEdiff --git a/marimo/_output/hypertext.py b/marimo/_output/hypertext.pyindex 032b347b46..515f56e8fb 100644--- a/marimo/_output/hypertext.py+++ b/marimo/_output/hypertext.py@@ -54,20 +54,17 @@ class Html(MIME):)```- **Attributes.**+ Attributes:+ text: a string of HTML- - `text`: a string of HTML+ Args:+ text: a string of HTML- **Initialization Args.**-- - `text`: a string of HTML-- **Methods.**-- - `batch`: convert this HTML element into a batched UI element- - `callout`: wrap this element in a callout- - `center`: center this element in the output area- - `right`: right-justify this element in the output area+ Methods:+ batch: convert this HTML element into a batched UI element+ callout: wrap this element in a callout+ center: center this element in the output area+ right: right-justify this element in the output area"""def __init__(self, text: str) -> None:@@ -145,24 +142,22 @@ class Html(MIME):This method lets you create custom UI elements that are representedby arbitrary HTML.- **Example.**-- ```python3- user_info = mo.md(- '''- - What's your name?: {name}- - When were you born?: {birthday}- '''- ).batch(name=mo.ui.text(), birthday=mo.ui.date())- ```-- In this example, `user_info` is a UI Element whose output is markdown- and whose value is a dict with keys `'name'` and '`birthday`'- (and values equal to the values of their corresponding elements).-- **Args.**-- - elements: the UI elements to interpolate into the HTML template.+ Example:+ ```python3+ user_info = mo.md(+ '''+ - What's your name?: {name}+ - When were you born?: {birthday}+ '''+ ).batch(name=mo.ui.text(), birthday=mo.ui.date())+ ```++ In this example, `user_info` is a UI Element whose output is markdown+ and whose value is a dict with keys `'name'` and '`birthday`'+ (and values equal to the values of their corresponding elements).++ Args:+ elements: the UI elements to interpolate into the HTML template."""from marimo._plugins.ui._impl.batch import batch as batch_plugin@@ -172,15 +167,13 @@ class Html(MIME):def center(self) -> Html:"""Center an item.- **Example.**-- ```python3- mo.md("# Hello, world").center()- ```+ Example:+ ```python3+ mo.md("# Hello, world").center()+ ```- **Returns.**-- An `Html` object.+ Returns:+ An `Html` object."""from marimo._plugins.stateless import flex@@ -190,15 +183,13 @@ class Html(MIME):def right(self) -> Html:"""Right-justify.- **Example.**-- ```python3- mo.md("# Hello, world").right()- ```+ Example:+ ```python3+ mo.md("# Hello, world").right()+ ```- **Returns.**-- An `Html` object.+ Returns:+ An `Html` object."""from marimo._plugins.stateless import flex@@ -208,15 +199,13 @@ class Html(MIME):def left(self) -> Html:"""Left-justify.- **Example.**-- ```python3- mo.md("# Hello, world").left()- ```+ Example:+ ```python3+ mo.md("# Hello, world").left()+ ```- **Returns.**-- An `Html` object.+ Returns:+ An `Html` object."""from marimo._plugins.stateless import flex@@ -235,15 +224,14 @@ class Html(MIME):importance. You can style the callout for different situations with the`kind` argument.- **Examples.**-- ```python3- mo.md("Hooray, you did it!").callout(kind="success")- ```+ Examples:+ ```python3+ mo.md("Hooray, you did it!").callout(kind="success")+ ```- ```python3- mo.md("It's dangerous to go alone!").callout(kind="warn")- ```+ ```python3+ mo.md("It's dangerous to go alone!").callout(kind="warn")+ ```"""from marimo._plugins.stateless.callout import callout as _callout@@ -256,17 +244,15 @@ class Html(MIME):) -> Html:"""Wrap an object in a styled container.- **Example.**-- ```python- mo.md("...").style({"max-height": "300px", "overflow": "auto"})- mo.md("...").style(max_height="300px", overflow="auto")- ```-- **Args.**+ Example:+ ```python+ mo.md("...").style({"max-height": "300px", "overflow": "auto"})+ mo.md("...").style(max_height="300px", overflow="auto")+ ```- - `style`: an optional dict of CSS styles, keyed by property name- - `**kwargs`: CSS styles as keyword arguments+ Args:+ style: an optional dict of CSS styles, keyed by property name+ **kwargs: CSS styles as keyword arguments"""from marimo._plugins.stateless import style as _stylediff --git a/marimo/_output/justify.py b/marimo/_output/justify.pyindex 9de433b2c2..f56170e59d 100644--- a/marimo/_output/justify.py+++ b/marimo/_output/justify.py@@ -8,9 +8,8 @@ from marimo._output.rich_help import mddocdef center(item: object) -> Html:"""Center an item.- **Returns.**-- A centered `Html` object.+ Returns:+ A centered `Html` object."""return as_html(item).center()@@ -19,9 +18,8 @@ def center(item: object) -> Html:def left(item: object) -> Html:"""Left-justify an item.- **Returns.**-- A left-justified `Html` object.+ Returns:+ A left-justified `Html` object."""return as_html(item).left()@@ -30,8 +28,7 @@ def left(item: object) -> Html:def right(item: object) -> Html:"""Right-justify an item.- **Returns.**-- A right-justified `Html` object.+ Returns:+ A right-justified `Html` object."""return as_html(item).right()diff --git a/marimo/_plugins/stateless/image.py b/marimo/_plugins/stateless/image.pyindex ceaf689dec..3e91a13546 100644--- a/marimo/_plugins/stateless/image.py+++ b/marimo/_plugins/stateless/image.py@@ -21,8 +21,7 @@ ImageLike = Union[Image, Tensor]def _normalize_image(src: ImageLike) -> Image:- """- Normalize an image-like object to a standard format.+ """Normalize an image-like object to a standard format.This function handles a variety of input types, including lists, arrays,and tensors, and converts them to a BytesIO object representing a PNG@@ -36,20 +35,17 @@ def _normalize_image(src: ImageLike) -> Image:`toarray` method, which is general enough that a specific check isperformed here.- **Args.**-- - `src`: An image-like object. This can be a list, array, tensor, or a- file-like object.-- **Returns.**+ Args:+ src: An image-like object. This can be a list, array, tensor, or a+ file-like object.- A BytesIO object or other Image type.+ Returns:+ A BytesIO object or other Image type.- **Raises.**-- - `ModuleNotFoundError`: If the required `PIL` or `numpy` packages are not- available.- - `ValueError`: If the input is not a valid image-like object.+ Raises:+ ModuleNotFoundError: If the required `PIL` or `numpy` packages are not+ available.+ ValueError: If the input is not a valid image-like object."""if (isinstance(src, list)@@ -97,39 +93,36 @@ def image() -> Html:"""Render an image as HTML.- **Examples.**-- ```python3- # Render an image from a local file- mo.image(src="path/to/image.png")- ```-- ```python3- # Render an image from a URL- mo.image(- src="https://marimo.io/logo.png",- alt="Marimo logo",- width=100,- height=100,- rounded=True,- caption="Marimo logo",- )- ```-- **Args.**-- - `src`: a path or URL to an image, a file-like object- (opened in binary mode), or array-like object.- - `alt`: the alt text of the image- - `width`: the width of the image in pixels or a string with units- - `height`: the height of the image in pixels or a string with units- - `rounded`: whether to round the corners of the image- - `style`: a dictionary of CSS styles to apply to the image- - `caption`: the caption of the image-- **Returns.**-- `Html` object+ Examples:+ ```python3+ # Render an image from a local file+ mo.image(src="path/to/image.png")+ ```++ ```python3+ # Render an image from a URL+ mo.image(+ src="https://marimo.io/logo.png",+ alt="Marimo logo",+ width=100,+ height=100,+ rounded=True,+ caption="Marimo logo",+ )+ ```++ Args:+ src: a path or URL to an image, a file-like object+ (opened in binary mode), or array-like object.+ alt: the alt text of the image+ width: the width of the image in pixels or a string with units+ height: the height of the image in pixels or a string with units+ rounded: whether to round the corners of the image+ style: a dictionary of CSS styles to apply to the image+ caption: the caption of the image++ Returns:+ `Html` object"""# Convert to virtual fileresolved_src: Optional[str]