MCPcopy Index your code
hub / github.com/python/mypy / read_block

Function read_block

mypy/nativeparse.py:1189–1209  ·  view source on GitHub ↗
(state: State, data: ReadBuffer)

Source from the content-addressed store, hash-verified

1187
1188
1189def read_block(state: State, data: ReadBuffer) -> Block:
1190 expect_tag(data, nodes.BLOCK)
1191 expect_tag(data, LIST_GEN)
1192 n = read_int_bare(data)
1193 is_unreachable = read_bool(data)
1194 if n == 0:
1195 # Empty block - read explicit location
1196 b = Block([], is_unreachable=is_unreachable)
1197 read_loc(data, b)
1198 expect_end_tag(data)
1199 return b
1200 else:
1201 # Non-empty block - read statements and set location from them
1202 a = read_statements(state, data, n)
1203 expect_end_tag(data)
1204 b = Block(a, is_unreachable=is_unreachable)
1205 b.line = a[0].line
1206 b.column = a[0].column
1207 b.end_line = a[-1].end_line
1208 b.end_column = a[-1].end_column
1209 return b
1210
1211
1212def read_optional_block(state: State, data: ReadBuffer) -> Block | None:

Callers 5

read_statementFunction · 0.85
read_func_defFunction · 0.85
read_class_defFunction · 0.85
read_try_stmtFunction · 0.85
read_expressionFunction · 0.85

Calls 5

BlockClass · 0.90
expect_tagFunction · 0.85
read_locFunction · 0.85
expect_end_tagFunction · 0.85
read_statementsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…