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

Method new_state

mypy/build.py:2677–2848  ·  view source on GitHub ↗
(
        id: str | None,
        path: str | None,
        source: str | None,
        manager: BuildManager,
        caller_state: State | None = None,
        caller_line: int = 0,
        ancestor_for: State | None = None,
        root_source: bool = False,
        # If `temporary` is True, this State is being created to just
        # quickly parse/load the tree, without an intention to further
        # process it. With this flag, any changes to external state as well
        # as error reporting should be avoided.
        temporary: bool = False,
    )

Source from the content-addressed store, hash-verified

2675
2676 @staticmethod
2677 def new_state(
2678 id: str | None,
2679 path: str | None,
2680 source: str | None,
2681 manager: BuildManager,
2682 caller_state: State | None = None,
2683 caller_line: int = 0,
2684 ancestor_for: State | None = None,
2685 root_source: bool = False,
2686 # If `temporary` is True, this State is being created to just
2687 # quickly parse/load the tree, without an intention to further
2688 # process it. With this flag, any changes to external state as well
2689 # as error reporting should be avoided.
2690 temporary: bool = False,
2691 ) -> State:
2692 if not temporary:
2693 assert id or path or source is not None, "Neither id, path nor source given"
2694 State.order_counter += 1
2695 if caller_state:
2696 import_context = caller_state.import_context.copy()
2697 import_context.append((caller_state.xpath, caller_line))
2698 else:
2699 import_context = []
2700 id = id or "__main__"
2701 options = manager.options.clone_for_module(id)
2702 manager.import_options[id] = options.dep_import_options()
2703
2704 ignore_all = False
2705 if not path and source is None:
2706 assert id is not None
2707 try:
2708 path, follow_imports = find_module_and_diagnose(
2709 manager,
2710 id,
2711 options,
2712 caller_state,
2713 caller_line,
2714 ancestor_for,
2715 root_source,
2716 skip_diagnose=temporary,
2717 )
2718 except ModuleNotFound as exc:
2719 if not temporary:
2720 manager.missing_modules[id] = exc.reason
2721 raise
2722 if follow_imports == "silent":
2723 ignore_all = True
2724 elif path and is_silent_import_module(manager, path) and not root_source:
2725 ignore_all = True
2726
2727 meta = None
2728 meta_ex = None
2729 interface_hash = b""
2730 meta_source_hash = None
2731 if path and source is None and manager.cache_enabled:
2732 meta_pair = find_cache_meta(id, path, manager)
2733 # TODO: Get mtime if not cached.
2734 if meta_pair is not None:

Callers 4

in_partial_packageFunction · 0.80
load_graphFunction · 0.80
test_order_asccMethod · 0.80

Calls 15

load_treeMethod · 0.95
parse_fileMethod · 0.95
compute_dependenciesMethod · 0.95
find_module_and_diagnoseFunction · 0.85
is_silent_import_moduleFunction · 0.85
find_cache_metaFunction · 0.85
validate_metaFunction · 0.85
listClass · 0.85
lenFunction · 0.85
zipFunction · 0.85
exist_added_packagesFunction · 0.85
exist_removed_submodulesFunction · 0.85

Tested by 2

test_order_asccMethod · 0.64