MCPcopy
hub / github.com/python/mypy / parse_all

Method parse_all

mypy/build.py:1013–1045  ·  view source on GitHub ↗

Parse multiple files in parallel (if possible) and compute dependencies. If post_parse is False, skip the last step (used when parsing unchanged files that need to be re-checked due to stale dependencies).

(self, states: list[State], post_parse: bool = True)

Source from the content-addressed store, hash-verified

1011 print("\n".join(lines) + "\n\n", end="")
1012
1013 def parse_all(self, states: list[State], post_parse: bool = True) -> None:
1014 """Parse multiple files in parallel (if possible) and compute dependencies.
1015
1016 If post_parse is False, skip the last step (used when parsing unchanged files
1017 that need to be re-checked due to stale dependencies).
1018 """
1019 if not self.options.native_parser:
1020 # Old parser cannot be parallelized.
1021 for state in states:
1022 state.parse_file()
1023 if post_parse:
1024 self.post_parse_all(states)
1025 return
1026
1027 sequential_states = []
1028 parallel_states = []
1029 for state in states:
1030 if state.tree is not None:
1031 # The file was already parsed.
1032 continue
1033 if not self.fscache.exists(state.xpath, real_only=True):
1034 # New parser only supports parsing on-disk files.
1035 sequential_states.append(state)
1036 continue
1037 parallel_states.append(state)
1038 if len(parallel_states) > 1:
1039 self.parse_parallel(sequential_states, parallel_states)
1040 else:
1041 # Avoid using executor when there is no parallelism.
1042 for state in states:
1043 state.parse_file()
1044 if post_parse:
1045 self.post_parse_all(states)
1046
1047 def parse_parallel(self, sequential_states: list[State], parallel_states: list[State]) -> None:
1048 """Perform parallel parsing of states.

Callers 5

load_graphFunction · 0.80
process_stale_sccFunction · 0.80
test_order_asccMethod · 0.80
load_statesFunction · 0.80

Calls 6

post_parse_allMethod · 0.95
parse_parallelMethod · 0.95
lenFunction · 0.85
existsMethod · 0.80
appendMethod · 0.80
parse_fileMethod · 0.45

Tested by 2

test_order_asccMethod · 0.64