|
1 | | -from typing import Optional |
2 | | - |
3 | 1 | from docutils import nodes |
4 | 2 | from docutils.parsers.rst import directives |
5 | 3 | from sphinx.application import Sphinx |
@@ -33,7 +31,7 @@ def setup_grids(app: Sphinx): |
33 | 31 |
|
34 | 32 |
|
35 | 33 | def _media_option( |
36 | | - argument: Optional[str], |
| 34 | + argument: str | None, |
37 | 35 | prefix: str, |
38 | 36 | *, |
39 | 37 | allow_auto: bool = False, |
@@ -66,27 +64,27 @@ def _media_option( |
66 | 64 | raise ValueError(validate_error_msg) |
67 | 65 | return [f"{prefix}{values[0]}"] + [ |
68 | 66 | f"{prefix}{size}-{value}" |
69 | | - for size, value in zip(["xs", "sm", "md", "lg"], values) |
| 67 | + for size, value in zip(["xs", "sm", "md", "lg"], values, strict=False) |
70 | 68 | ] |
71 | 69 |
|
72 | 70 |
|
73 | | -def row_columns_option(argument: Optional[str]) -> list[str]: |
| 71 | +def row_columns_option(argument: str | None) -> list[str]: |
74 | 72 | """Validate the number of columns (out of 12) a grid row will have. |
75 | 73 |
|
76 | 74 | One or four integers (for "xs sm md lg") between 1 and 12 (or 'auto'). |
77 | 75 | """ |
78 | 76 | return _media_option(argument, "sd-row-cols-", allow_auto=True) |
79 | 77 |
|
80 | 78 |
|
81 | | -def item_columns_option(argument: Optional[str]) -> list[str]: |
| 79 | +def item_columns_option(argument: str | None) -> list[str]: |
82 | 80 | """Validate the number of columns (out of 12) a grid-item will take up. |
83 | 81 |
|
84 | 82 | One or four integers (for "xs sm md lg") between 1 and 12 (or 'auto'). |
85 | 83 | """ |
86 | 84 | return _media_option(argument, "sd-col-", allow_auto=True) |
87 | 85 |
|
88 | 86 |
|
89 | | -def gutter_option(argument: Optional[str]) -> list[str]: |
| 87 | +def gutter_option(argument: str | None) -> list[str]: |
90 | 88 | """Validate the gutter size between grid items. |
91 | 89 |
|
92 | 90 | One or four integers (for "xs sm md lg") between 0 and 5. |
@@ -191,7 +189,7 @@ def run_with_defaults(self) -> list[nodes.Node]: |
191 | 189 | + self.options.get("margin", []) |
192 | 190 | + self.options.get("padding", []) |
193 | 191 | + ( |
194 | | - [f'sd-align-major-{self.options["child-align"]}'] |
| 192 | + [f"sd-align-major-{self.options['child-align']}"] |
195 | 193 | if "child-align" in self.options |
196 | 194 | else [] |
197 | 195 | ) |
|
0 commit comments