Debian Codegraph @

tests/indent/python.py

raw symbols SCIP
1 import os
2 from typing import (
3 List,
4 Optional,
5 )
6
7
8 class Example:
9 attribute = 1
10
11 def __init__(self, first, second):
12 self.first = first
13 self.second = second
14 self.values = [
15 1,
16 2,
17 3,
18 ]
19 self.mapping = {
20 "a": 1,
21 "b": 2,
22 }
23
24 def method(self, argument):
25 if argument > 0:
26 for index in range(argument):
27 print(index)
28 return argument
29 elif argument < 0:
30 while argument < 0:
31 argument += 1
32 else:
33 argument = 0
34
35 try:
36 value = self.values[argument]
37 except IndexError:
38 value = None
39 except (KeyError, ValueError):
40 value = -1
41 else:
42 value += 1
43 finally:
44 print("done")
45
46 with open("file") as handle:
47 data = handle.read()
48
49 return value
50
51
52 def aligned_call():
53 result = some_function(first_argument,
54 second_argument,
55 third_argument)
56 return result
57
58
59 def hanging_call():
60 result = other_function(
61 first_argument,
62 second_argument,
63 )
64 return result
65
66
67 def comprehensions():
68 squares = [
69 value * value
70 for value in range(10)
71 if value % 2 == 0
72 ]
73 return squares
74
75
76 def match_example(command):
77 match command:
78 case "start":
79 return 1
80 case "stop":
81 return 0
82 case _:
83 return -1
84
85
86 def docstring_example():
87 text = """
88 first line
89 indented in string
90 back"""
91 return text