]> git.madduck.net Git - etc/vim.git/blob - tests/data/preview_py_310/pep604_union_types_line_breaks.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Drop support for parsing Python 2 (#3933)
[etc/vim.git] / tests / data / preview_py_310 / pep604_union_types_line_breaks.py
1 # This has always worked
2 z= Loooooooooooooooooooooooong | Loooooooooooooooooooooooong | Loooooooooooooooooooooooong | Loooooooooooooooooooooooong
3
4 # "AnnAssign"s now also work
5 z: Loooooooooooooooooooooooong | Loooooooooooooooooooooooong | Loooooooooooooooooooooooong | Loooooooooooooooooooooooong
6 z: (Short
7     | Short2
8     | Short3
9     | Short4)
10 z: (int)
11 z: ((int))
12
13
14 z: Loooooooooooooooooooooooong | Loooooooooooooooooooooooong | Loooooooooooooooooooooooong | Loooooooooooooooooooooooong = 7
15 z: (Short
16     | Short2
17     | Short3
18     | Short4) = 8
19 z: (int) = 2.3
20 z: ((int)) = foo()
21
22 # In case I go for not enforcing parantheses, this might get improved at the same time
23 x = (
24     z
25     == 9999999999999999999999999999999999999999
26     | 9999999999999999999999999999999999999999
27     | 9999999999999999999999999999999999999999
28     | 9999999999999999999999999999999999999999,
29     y
30     == 9999999999999999999999999999999999999999
31     + 9999999999999999999999999999999999999999
32     + 9999999999999999999999999999999999999999
33     + 9999999999999999999999999999999999999999,
34 )
35
36 x = (
37     z == (9999999999999999999999999999999999999999
38     | 9999999999999999999999999999999999999999
39     | 9999999999999999999999999999999999999999
40     | 9999999999999999999999999999999999999999),
41     y == (9999999999999999999999999999999999999999
42     + 9999999999999999999999999999999999999999
43     + 9999999999999999999999999999999999999999
44     + 9999999999999999999999999999999999999999),
45 )
46
47 # handle formatting of "tname"s in parameter list
48
49 # remove unnecessary paren
50 def foo(i: (int)) -> None: ...
51
52
53 # this is a syntax error in the type annotation according to mypy, but it's not invalid *python* code, so make sure we don't mess with it and make it so.
54 def foo(i: (int,)) -> None: ...
55
56 def foo(
57     i: int,
58     x: Loooooooooooooooooooooooong
59     | Looooooooooooooooong
60     | Looooooooooooooooooooong
61     | Looooooong,
62     *,
63     s: str,
64 ) -> None:
65     pass
66
67
68 @app.get("/path/")
69 async def foo(
70     q: str
71     | None = Query(None, title="Some long title", description="Some long description")
72 ):
73     pass
74
75
76 def f(
77     max_jobs: int
78     | None = Option(
79         None, help="Maximum number of jobs to launch. And some additional text."
80         ),
81     another_option: bool = False
82     ):
83     ...
84
85
86 # output
87 # This has always worked
88 z = (
89     Loooooooooooooooooooooooong
90     | Loooooooooooooooooooooooong
91     | Loooooooooooooooooooooooong
92     | Loooooooooooooooooooooooong
93 )
94
95 # "AnnAssign"s now also work
96 z: (
97     Loooooooooooooooooooooooong
98     | Loooooooooooooooooooooooong
99     | Loooooooooooooooooooooooong
100     | Loooooooooooooooooooooooong
101 )
102 z: Short | Short2 | Short3 | Short4
103 z: int
104 z: int
105
106
107 z: (
108     Loooooooooooooooooooooooong
109     | Loooooooooooooooooooooooong
110     | Loooooooooooooooooooooooong
111     | Loooooooooooooooooooooooong
112 ) = 7
113 z: Short | Short2 | Short3 | Short4 = 8
114 z: int = 2.3
115 z: int = foo()
116
117 # In case I go for not enforcing parantheses, this might get improved at the same time
118 x = (
119     z
120     == 9999999999999999999999999999999999999999
121     | 9999999999999999999999999999999999999999
122     | 9999999999999999999999999999999999999999
123     | 9999999999999999999999999999999999999999,
124     y
125     == 9999999999999999999999999999999999999999
126     + 9999999999999999999999999999999999999999
127     + 9999999999999999999999999999999999999999
128     + 9999999999999999999999999999999999999999,
129 )
130
131 x = (
132     z
133     == (
134         9999999999999999999999999999999999999999
135         | 9999999999999999999999999999999999999999
136         | 9999999999999999999999999999999999999999
137         | 9999999999999999999999999999999999999999
138     ),
139     y
140     == (
141         9999999999999999999999999999999999999999
142         + 9999999999999999999999999999999999999999
143         + 9999999999999999999999999999999999999999
144         + 9999999999999999999999999999999999999999
145     ),
146 )
147
148 # handle formatting of "tname"s in parameter list
149
150
151 # remove unnecessary paren
152 def foo(i: int) -> None: ...
153
154
155 # this is a syntax error in the type annotation according to mypy, but it's not invalid *python* code, so make sure we don't mess with it and make it so.
156 def foo(i: (int,)) -> None: ...
157
158
159 def foo(
160     i: int,
161     x: (
162         Loooooooooooooooooooooooong
163         | Looooooooooooooooong
164         | Looooooooooooooooooooong
165         | Looooooong
166     ),
167     *,
168     s: str,
169 ) -> None:
170     pass
171
172
173 @app.get("/path/")
174 async def foo(
175     q: str | None = Query(
176         None, title="Some long title", description="Some long description"
177     )
178 ):
179     pass
180
181
182 def f(
183     max_jobs: int | None = Option(
184         None, help="Maximum number of jobs to launch. And some additional text."
185     ),
186     another_option: bool = False,
187 ): ...