Show More
@@ -12,6 +12,8 b' import sys' | |||
|
12 | 12 | from IPython.core.magic_arguments import (argument, argument_group, kwds, |
|
13 | 13 | magic_arguments, parse_argstring, real_name) |
|
14 | 14 | |
|
15 | LEADING_SPACE = "" if sys.version_info > (3, 13) else " " | |
|
16 | ||
|
15 | 17 | |
|
16 | 18 | @magic_arguments() |
|
17 | 19 | @argument('-f', '--foo', help="an argument") |
@@ -81,14 +83,14 b' def test_magic_arguments():' | |||
|
81 | 83 | |
|
82 | 84 | assert ( |
|
83 | 85 | magic_foo1.__doc__ |
|
84 |
== f"::\n\n %foo1 [-f FOO]\n\n |
|
|
86 | == f"::\n\n %foo1 [-f FOO]\n\n{LEADING_SPACE}A docstring.\n\n{options}:\n -f FOO, --foo FOO an argument\n" | |
|
85 | 87 | ) |
|
86 | 88 | assert getattr(magic_foo1, "argcmd_name", None) == None |
|
87 | 89 | assert real_name(magic_foo1) == "foo1" |
|
88 | 90 | assert magic_foo1(None, "") == argparse.Namespace(foo=None) |
|
89 | 91 | assert hasattr(magic_foo1, "has_arguments") |
|
90 | 92 | |
|
91 |
assert magic_foo2.__doc__ == "::\n\n %foo2\n\n |
|
|
93 | assert magic_foo2.__doc__ == f"::\n\n %foo2\n\n{LEADING_SPACE}A docstring.\n" | |
|
92 | 94 | assert getattr(magic_foo2, "argcmd_name", None) == None |
|
93 | 95 | assert real_name(magic_foo2) == "foo2" |
|
94 | 96 | assert magic_foo2(None, "") == argparse.Namespace() |
@@ -96,7 +98,7 b' def test_magic_arguments():' | |||
|
96 | 98 | |
|
97 | 99 | assert ( |
|
98 | 100 | magic_foo3.__doc__ |
|
99 |
== f"::\n\n %foo3 [-f FOO] [-b BAR] [-z BAZ]\n\n |
|
|
101 | == f"::\n\n %foo3 [-f FOO] [-b BAR] [-z BAZ]\n\n{LEADING_SPACE}A docstring.\n\n{options}:\n -f FOO, --foo FOO an argument\n\nGroup:\n -b BAR, --bar BAR a grouped argument\n\nSecond Group:\n -z BAZ, --baz BAZ another grouped argument\n" | |
|
100 | 102 | ) |
|
101 | 103 | assert getattr(magic_foo3, "argcmd_name", None) == None |
|
102 | 104 | assert real_name(magic_foo3) == "foo3" |
@@ -105,7 +107,7 b' def test_magic_arguments():' | |||
|
105 | 107 | |
|
106 | 108 | assert ( |
|
107 | 109 | magic_foo4.__doc__ |
|
108 |
== f"::\n\n %foo4 [-f FOO]\n\n |
|
|
110 | == f"::\n\n %foo4 [-f FOO]\n\n{LEADING_SPACE}A docstring.\n\n{options}:\n -f FOO, --foo FOO an argument\n" | |
|
109 | 111 | ) |
|
110 | 112 | assert getattr(magic_foo4, "argcmd_name", None) == None |
|
111 | 113 | assert real_name(magic_foo4) == "foo4" |
@@ -114,7 +116,7 b' def test_magic_arguments():' | |||
|
114 | 116 | |
|
115 | 117 | assert ( |
|
116 | 118 | magic_foo5.__doc__ |
|
117 |
== f"::\n\n %frobnicate [-f FOO]\n\n |
|
|
119 | == f"::\n\n %frobnicate [-f FOO]\n\n{LEADING_SPACE}A docstring.\n\n{options}:\n -f FOO, --foo FOO an argument\n" | |
|
118 | 120 | ) |
|
119 | 121 | assert getattr(magic_foo5, "argcmd_name", None) == "frobnicate" |
|
120 | 122 | assert real_name(magic_foo5) == "frobnicate" |
@@ -123,7 +125,7 b' def test_magic_arguments():' | |||
|
123 | 125 | |
|
124 | 126 | assert ( |
|
125 | 127 | magic_magic_foo.__doc__ |
|
126 |
== f"::\n\n %magic_foo [-f FOO]\n\n |
|
|
128 | == f"::\n\n %magic_foo [-f FOO]\n\n{LEADING_SPACE}A docstring.\n\n{options}:\n -f FOO, --foo FOO an argument\n" | |
|
127 | 129 | ) |
|
128 | 130 | assert getattr(magic_magic_foo, "argcmd_name", None) == None |
|
129 | 131 | assert real_name(magic_magic_foo) == "magic_foo" |
@@ -132,7 +134,7 b' def test_magic_arguments():' | |||
|
132 | 134 | |
|
133 | 135 | assert ( |
|
134 | 136 | foo.__doc__ |
|
135 |
== f"::\n\n %foo [-f FOO]\n\n |
|
|
137 | == f"::\n\n %foo [-f FOO]\n\n{LEADING_SPACE}A docstring.\n\n{options}:\n -f FOO, --foo FOO an argument\n" | |
|
136 | 138 | ) |
|
137 | 139 | assert getattr(foo, "argcmd_name", None) == None |
|
138 | 140 | assert real_name(foo) == "foo" |
@@ -17,7 +17,7 b' import warnings' | |||
|
17 | 17 | from string import Formatter |
|
18 | 18 | from pathlib import Path |
|
19 | 19 | |
|
20 |
from typing import List, |
|
|
20 | from typing import List, Dict, Tuple | |
|
21 | 21 | |
|
22 | 22 | |
|
23 | 23 | class LSString(str): |
@@ -357,7 +357,7 b' def format_screen(strng):' | |||
|
357 | 357 | return strng |
|
358 | 358 | |
|
359 | 359 | |
|
360 | def dedent(text): | |
|
360 | def dedent(text: str) -> str: | |
|
361 | 361 | """Equivalent of textwrap.dedent that ignores unindented first line. |
|
362 | 362 | |
|
363 | 363 | This means it will still dedent strings like: |
General Comments 0
You need to be logged in to leave comments.
Login now