Esempio n. 1
0
def bind_or_analyze_type(
        t: MypyType,
        api: SemanticAnalyzer,
        module_name: Optional[str] = None) -> Optional[MypyType]:
    """Analyze a type. If an unbound type, try to look it up in the given module name.

    That should hopefully give a bound type."""
    if isinstance(t, UnboundType) and module_name is not None:
        node = api.lookup_fully_qualified_or_none(module_name + "." + t.name)
        if node is None:
            return None
        return node.type
    else:
        return api.anal_type(t)
Esempio n. 2
0
File: build.py Progetto: silky/mypy
 def __init__(self, data_dir: str,
              lib_path: List[str],
              target: int,
              output_dir: str,
              pyversion: int,
              flags: List[str],
              ignore_prefix: str) -> None:
     self.data_dir = data_dir
     self.errors = Errors()
     self.errors.set_ignore_prefix(ignore_prefix)
     self.lib_path = lib_path
     self.target = target
     self.output_dir = output_dir
     self.pyversion = pyversion
     self.flags = flags
     self.semantic_analyzer = SemanticAnalyzer(lib_path, self.errors)
     self.semantic_analyzer_pass3 = ThirdPass(self.errors)
     self.type_checker = TypeChecker(self.errors,
                                     self.semantic_analyzer.modules,
                                     self.pyversion)
     self.states = List[State]()
     self.module_files = Dict[str, str]()
     self.icode = Dict[str, FuncIcode]()
     self.binary_path = None # type: str
     self.module_deps = Dict[Tuple[str, str], bool]()
Esempio n. 3
0
 def __init__(self, data_dir: str,
              lib_path: List[str],
              target: int,
              pyversion: Tuple[int, int],
              flags: List[str],
              ignore_prefix: str,
              custom_typing_module: str,
              reports: Reports) -> None:
     self.data_dir = data_dir
     self.errors = Errors()
     self.errors.set_ignore_prefix(ignore_prefix)
     self.lib_path = lib_path
     self.target = target
     self.pyversion = pyversion
     self.flags = flags
     self.custom_typing_module = custom_typing_module
     self.reports = reports
     self.semantic_analyzer = SemanticAnalyzer(lib_path, self.errors,
                                               pyversion=pyversion)
     modules = self.semantic_analyzer.modules
     self.semantic_analyzer_pass3 = ThirdPass(modules, self.errors)
     self.type_checker = TypeChecker(self.errors, modules, self.pyversion)
     self.states = []  # type: List[State]
     self.module_files = {}  # type: Dict[str, str]
     self.module_deps = {}  # type: Dict[Tuple[str, str], bool]
     self.missing_modules = set()  # type: Set[str]
Esempio n. 4
0
 def __init__(self, data_dir: str,
              lib_path: List[str],
              target: int,
              output_dir: str,
              pyversion: int,
              flags: List[str],
              ignore_prefix: str,
              custom_typing_module: str,
              html_report_dir: str) -> None:
     self.data_dir = data_dir
     self.errors = Errors()
     self.errors.set_ignore_prefix(ignore_prefix)
     self.lib_path = lib_path
     self.target = target
     self.output_dir = output_dir
     self.pyversion = pyversion
     self.flags = flags
     self.custom_typing_module = custom_typing_module
     self.html_report_dir = html_report_dir
     self.semantic_analyzer = SemanticAnalyzer(lib_path, self.errors,
                                               pyversion=pyversion)
     self.semantic_analyzer_pass3 = ThirdPass(self.errors)
     self.type_checker = TypeChecker(self.errors,
                                     self.semantic_analyzer.modules,
                                     self.pyversion)
     self.states = List[State]()
     self.module_files = Dict[str, str]()
     self.module_deps = Dict[Tuple[str, str], bool]()
     self.missing_modules = Set[str]()