Debian Codegraph @

tests/data/line_ranges_formatted/basic.py

raw
1 """Module doc."""
2
3 from typing import (
4 Callable,
5 Literal,
6 )
7
8 # fmt: off
9 class Unformatted:
10 def should_also_work(self):
11 pass
12 # fmt: on
13
14
15 a = [1, 2] # fmt: skip
16
17
18 # This should cover as many syntaxes as possible.
19 class Foo:
20 """Class doc."""
21
22 def __init__(self) -> None:
23 pass
24
25 @add_logging
26 @memoize.memoize(max_items=2)
27 def plus_one(
28 self,
29 number: int,
30 ) -> int:
31 return number + 1
32
33 async def async_plus_one(self, number: int) -> int:
34 await asyncio.sleep(1)
35 async with some_context():
36 return number + 1
37
38
39 try:
40 for i in range(10):
41 while condition:
42 if something:
43 then_something()
44 elif something_else:
45 then_something_else()
46 except ValueError as e:
47 handle(e)
48 finally:
49 done()