Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a77fe03

Browse files
authored
docs: final google docs, add lint rules (marimo-team#3226)
Lint rules to enforce google docs: https://www.pydocstyle.org/en/stable/error_codes.html
1 parent 77a655d commit a77fe03

File tree

15 files changed

+172
-204
lines changed

15 files changed

+172
-204
lines changed

marimo/_ast/app.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def cell(
198198
hide_code: bool = False,
199199
**kwargs: Any,
200200
) -> Cell | Callable[[Callable[..., Any]], Cell]:
201-
"""A decorator to add a cell to the app
201+
"""A decorator to add a cell to the app.
202202
203203
This decorator can be called with or without parentheses. Each of the
204204
following is valid:
@@ -218,9 +218,11 @@ def __(mo):
218218
```
219219
220220
Args:
221-
- func: The decorated function
222-
- disabled: Whether to disable the cell
223-
- kwargs: For forward-compatibility with future arguments
221+
func: The decorated function.
222+
column: The column number to place this cell in.
223+
disabled: Whether to disable the cell.
224+
hide_code: Whether to hide the cell's code.
225+
**kwargs: For forward-compatibility with future arguments.
224226
"""
225227
del kwargs
226228

marimo/_ast/cell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ def add(mo, x, y):
512512
```
513513
514514
Args:
515-
**kwargs (Any):
515+
**refs (Any):
516516
You may pass values for any of this cell's references as keyword
517517
arguments. marimo will automatically compute values for any refs
518518
that are not provided by executing the parent cells that compute

marimo/_output/data/data.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def image(data: bytes, ext: str = "png") -> VirtualFile:
3131
"""Create a virtual file from an image.
3232
3333
Args:
34-
data: Image data in bytes
34+
data (bytes): Image data in bytes
35+
ext (str): File extension
3536
3637
Returns:
3738
A `VirtualFile` object.
@@ -45,7 +46,8 @@ def audio(data: bytes, ext: str = "wav") -> VirtualFile:
4546
"""Create a virtual file from audio.
4647
4748
Args:
48-
data: Audio data in bytes
49+
data (bytes): Audio data in bytes
50+
ext (str): File extension
4951
5052
Returns:
5153
A `VirtualFile` object.

marimo/_output/formatting.py

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -310,23 +310,18 @@ def mime_to_html(mimetype: KnownMimeType, data: Any) -> Html:
310310

311311
@mddoc
312312
def plain(value: Any) -> Plain:
313-
"""
314-
Wrap a value to indicate that it should be displayed
315-
without any opinionated formatting.
316-
317-
This is the best way to opt out of marimo's
318-
default dataframe rendering.
319-
320-
**Example.**
313+
"""Wrap a value to indicate that it should be displayed without any opinionated formatting.
321314
322-
```python
323-
df = data.cars()
324-
mo.plain(df)
325-
```
315+
This is the best way to opt out of marimo's default dataframe rendering.
326316
327-
**Args.**
317+
Example:
318+
```python
319+
df = data.cars()
320+
mo.plain(df)
321+
```
328322
329-
- `value`: Any value
323+
Args:
324+
value: Any value
330325
"""
331326
return Plain(value)
332327

@@ -343,8 +338,7 @@ def __init__(self, child: Any):
343338

344339
@mddoc
345340
def iframe(html: str, *, width: str = "100%", height: str = "400px") -> Html:
346-
"""
347-
Embed an HTML string in an iframe.
341+
"""Embed an HTML string in an iframe.
348342
349343
Scripts by default are not executed using `mo.as_html` or `mo.Html`,
350344
so if you have a script tag (written as `<script></script>`),
@@ -354,16 +348,16 @@ def iframe(html: str, *, width: str = "100%", height: str = "400px") -> Html:
354348
that may contain styles that could interfere with the rest of the
355349
page.
356350
357-
**Example.**
358-
359-
```python
360-
html = "<h1>Hello, world!</h1>"
361-
mo.iframe(html)
362-
```
363-
364-
**Args.**
351+
Example:
352+
```python
353+
html = "<h1>Hello, world!</h1>"
354+
mo.iframe(html)
355+
```
365356
366-
- `html`: An HTML string
357+
Args:
358+
html (str): An HTML string
359+
width (str): The width of the iframe
360+
height (str): The height of the iframe
367361
"""
368362

369363
return Html(

marimo/_plugins/stateless/download.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ def download(
2828
Show a download button for a url, bytes, or file-like object.
2929
3030
Args:
31-
data: The data to download. Can be a string (interpreted as
31+
data (Union[str, bytes, io.BytesIO]): The data to download. Can be a string (interpreted as
3232
a URL), bytes, or a file opened in binary mode.
33-
filename: The name of the file to download.
33+
filename (str): The name of the file to download.
3434
If not provided, the name will be guessed from the data.
35-
mimetype: The mimetype of the file to download, for example,
35+
mimetype (str): The mimetype of the file to download, for example,
3636
(e.g. "text/csv", "image/png"). If not provided,
3737
the mimetype will be guessed from the filename.
38+
disabled (bool): Whether to disable the download button.
39+
label (str): The label of the download button.
3840
3941
Returns:
4042
An `Html` object for a download button.

marimo/_plugins/stateless/nav_menu.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def nav_menu(
2626
menu: a dictionary of tab names to tab content;
2727
the content can also be nested dictionaries (one level deep)
2828
strings are interpreted as markdown
29+
orientation (Literal["horizontal", "vertical"]): The orientation of the menu.
2930
3031
Returns:
3132
An `Html` object.

marimo/_plugins/ui/_core/ui_element.py

Lines changed: 45 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -354,61 +354,52 @@ def form(
354354
) -> form_plugin[S, T]:
355355
"""Create a submittable form out of this `UIElement`.
356356
357-
Use this method to create a form that gates the submission
358-
of a `UIElement`s value until a submit button is clicked.
359-
360-
The value of the `form` is the value of the underlying
361-
element the last time the form was submitted.
362-
363-
**Examples.**
364-
365-
Convert any `UIElement` into a form:
366-
367-
```python
368-
prompt = mo.ui.text_area().form()
369-
```
370-
371-
Combine with `HTML.batch` to create a form made out of multiple
372-
`UIElements`:
373-
374-
```python
375-
form = (
376-
mo.ui.md(
377-
'''
378-
**Enter your prompt.**
379-
380-
{prompt}
381-
382-
**Choose a random seed.**
357+
Creates a form that gates submission of a `UIElement`'s value until a submit button is clicked.
358+
The form's value is the value of the underlying element from the last submission.
359+
360+
Examples:
361+
Convert any `UIElement` into a form:
362+
```python
363+
prompt = mo.ui.text_area().form()
364+
```
365+
366+
Combine with `HTML.batch` to create a form made out of multiple `UIElements`:
367+
```python
368+
form = (
369+
mo.ui.md(
370+
'''
371+
**Enter your prompt.**
372+
373+
{prompt}
374+
375+
**Choose a random seed.**
376+
377+
{seed}
378+
'''
379+
)
380+
.batch(
381+
prompt=mo.ui.text_area(),
382+
seed=mo.ui.number(),
383+
)
384+
.form()
385+
)
386+
```
383387
384-
{seed}
385-
'''
386-
)
387-
.batch(
388-
prompt=mo.ui.text_area(),
389-
seed=mo.ui.number(),
390-
)
391-
.form()
392-
)
393-
```
394-
395-
**Args.**
396-
397-
- `label`: A text label for the form.
398-
- `bordered`: whether the form should have a border
399-
- `loading`: whether the form should be in a loading state
400-
- `submit_button_label`: the label of the submit button
401-
- `submit_button_tooltip`: the tooltip of the submit button
402-
- `submit_button_disabled`: whether the submit button should be
403-
disabled
404-
- `clear_on_submit`: whether the form should clear its contents after
405-
submitting
406-
- `show_clear_button`: whether the form should show a clear button
407-
- `clear_button_label`: the label of the clear button
408-
- `clear_button_tooltip`: the tooltip of the clear button
409-
- `validate`: a function that takes the form's value and returns an
410-
error message if the value is invalid,
411-
or `None` if the value is valid
388+
Args:
389+
label: A text label for the form.
390+
bordered: Whether the form should have a border.
391+
loading: Whether the form should be in a loading state.
392+
submit_button_label: The label of the submit button.
393+
submit_button_tooltip: The tooltip of the submit button.
394+
submit_button_disabled: Whether the submit button should be disabled.
395+
clear_on_submit: Whether the form should clear its contents after submitting.
396+
show_clear_button: Whether the form should show a clear button.
397+
clear_button_label: The label of the clear button.
398+
clear_button_tooltip: The tooltip of the clear button.
399+
validate: A function that takes the form's value and returns an error message if invalid,
400+
or `None` if valid.
401+
on_change: A callback that takes the form's value and returns an error message if invalid,
402+
or `None` if valid.
412403
"""
413404
from marimo._plugins.ui._impl.input import form as form_plugin
414405

marimo/_runtime/complete.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -380,18 +380,17 @@ def complete(
380380
and more comprehensive, but can only be carried out when the kernel
381381
isn't executing or otherwise handling a request.
382382
383-
**Args.**
384-
385-
- `request`: the completion request
386-
- `graph`: dataflow graph backing the marimo program
387-
- `glbls`: global namespace
388-
- `glbls_lock`: lock protecting the global namespace, for interpreter-based
389-
completion
390-
- `stream`: Stream through which to communicate completion results
391-
- `docstrings_limit`: limit past which we won't attempt to fetch type hints
392-
and docstrings
393-
- `timeout`: timeout after which we'll stop fetching type hints/docstrings
394-
- `prefer_interpreter_completion`: whether to prefer interpreter completion
383+
Args:
384+
request: The completion request
385+
graph: Dataflow graph backing the marimo program
386+
glbls: Global namespace
387+
glbls_lock: Lock protecting the global namespace, for interpreter-based
388+
completion
389+
stream: Stream through which to communicate completion results
390+
docstrings_limit: Limit past which we won't attempt to fetch type hints
391+
and docstrings
392+
timeout: Timeout after which we'll stop fetching type hints/docstrings
393+
prefer_interpreter_completion: Whether to prefer interpreter completion
395394
"""
396395
if not request.document.strip():
397396
_write_no_completions(stream, request.id)

marimo/_runtime/redirect_streams.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def forward_os_stream(stream_object: Stdout | Stderr, fd: int) -> None:
2424
def dup2newfd(fd: int) -> tuple[int, int, int]:
2525
"""Create a pipe, with `fd` at the write end of it.
2626
27-
Returns
27+
Returns:
2828
- duplicate (os.dup) of `fd`
2929
- read end of pipe
3030
- fd (which now points to the file referenced by the write end of the pipe)

marimo/_runtime/runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ def mutate_graph(
921921
absent-mindedly redefine an existing name when creating a new cell:
922922
such a mistake shouldn't invalidate the program state.
923923
924-
Returns
924+
Returns:
925925
- set of cells that must be run to return kernel to consistent state
926926
"""
927927
LOGGER.debug("Mutating graph.")

0 commit comments

Comments
 (0)