当前位置: 首页>>代码示例>>Python>>正文


Python MypyFile.fullname方法代码示例

本文整理汇总了Python中mypy.nodes.MypyFile.fullname方法的典型用法代码示例。如果您正苦于以下问题:Python MypyFile.fullname方法的具体用法?Python MypyFile.fullname怎么用?Python MypyFile.fullname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mypy.nodes.MypyFile的用法示例。


在下文中一共展示了MypyFile.fullname方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: merge_asts

# 需要导入模块: from mypy.nodes import MypyFile [as 别名]
# 或者: from mypy.nodes.MypyFile import fullname [as 别名]
def merge_asts(old: MypyFile, old_symbols: SymbolTable,
               new: MypyFile, new_symbols: SymbolTable) -> None:
    """Merge a new version of a module AST to a previous version.

    The main idea is to preserve the identities of externally visible
    nodes in the old AST (that have a corresponding node in the new AST).
    All old node state (outside identity) will come from the new AST.

    When this returns, 'old' will refer to the merged AST, but 'new_symbols'
    will be the new symbol table. 'new' and 'old_symbols' will no longer be
    valid.
    """
    assert new.fullname() == old.fullname()
    # Find the mapping from new to old node identities for all nodes
    # whose identities should be preserved.
    replacement_map = replacement_map_from_symbol_table(
        old_symbols, new_symbols, prefix=old.fullname())
    # Also replace references to the new MypyFile node.
    replacement_map[new] = old
    # Perform replacements to everywhere within the new AST (not including symbol
    # tables).
    node = replace_nodes_in_ast(new, replacement_map)
    assert node is old
    # Also replace AST node references in the *new* symbol table (we'll
    # continue to use the new symbol table since it has all the new definitions
    # that have no correspondence in the old AST).
    replace_nodes_in_symbol_table(new_symbols, replacement_map)
开发者ID:python,项目名称:mypy,代码行数:29,代码来源:astmerge.py

示例2: get_python_out_path

# 需要导入模块: from mypy.nodes import MypyFile [as 别名]
# 或者: from mypy.nodes.MypyFile import fullname [as 别名]
 def get_python_out_path(self, f: MypyFile) -> str:
     if f.fullname() == '__main__':
         return os.path.join(self.output_dir, basename(f.path))
     else:
         components = f.fullname().split('.')
         if os.path.basename(f.path) == '__init__.py':
             components.append('__init__.py')
         else:
             components[-1] += '.py'
         return os.path.join(self.output_dir, *components)
开发者ID:adamhaney,项目名称:mypy,代码行数:12,代码来源:build.py

示例3: visit_file

# 需要导入模块: from mypy.nodes import MypyFile [as 别名]
# 或者: from mypy.nodes.MypyFile import fullname [as 别名]
 def visit_file(self, file_node: MypyFile, fnam: str, options: Options,
                patches: List[Callable[[], None]]) -> None:
     self.recurse_into_functions = True
     self.errors.set_file(fnam, file_node.fullname())
     self.options = options
     self.sem.options = options
     self.patches = patches
     self.is_typeshed_file = self.errors.is_typeshed_file(fnam)
     self.sem.cur_mod_id = file_node.fullname()
     self.sem.globals = file_node.names
     with experiments.strict_optional_set(options.strict_optional):
         self.accept(file_node)
开发者ID:greatmazinger,项目名称:mypy,代码行数:14,代码来源:semanal_pass3.py

示例4: on_file

# 需要导入模块: from mypy.nodes import MypyFile [as 别名]
# 或者: from mypy.nodes.MypyFile import fullname [as 别名]
 def on_file(self,
             tree: MypyFile,
             type_map: Dict[Expression, Type],
             options: Options) -> None:
     visitor = stats.StatisticsVisitor(inferred=True, filename=tree.fullname(),
                                       typemap=type_map, all_nodes=True,
                                       visit_untyped_defs=False)
     tree.accept(visitor)
     self.any_types_counter[tree.fullname()] = visitor.type_of_any_counter
     num_unanalyzed_lines = list(visitor.line_map.values()).count(stats.TYPE_UNANALYZED)
     # count each line of dead code as one expression of type "Any"
     num_any = visitor.num_any_exprs + num_unanalyzed_lines
     num_total = visitor.num_imprecise_exprs + visitor.num_precise_exprs + num_any
     if num_total > 0:
         self.counts[tree.fullname()] = (num_any, num_total)
开发者ID:chadrik,项目名称:mypy,代码行数:17,代码来源:report.py

示例5: visit_mypy_file

# 需要导入模块: from mypy.nodes import MypyFile [as 别名]
# 或者: from mypy.nodes.MypyFile import fullname [as 别名]
 def visit_mypy_file(self, mfile: MypyFile) -> int:
     if mfile.fullname() in ('typing', 'abc'):
         # These module are special; their contents are currently all
         # built-in primitives.
         return -1
     
     self.enter()
     
     # Initialize non-int global variables.
     for name in sorted(mfile.names):
         node = mfile.names[name].node
         if (isinstance(node, Var) and
                 name not in nodes.implicit_module_attrs):
             v = cast(Var, node)
             if (not is_named_instance(v.type, 'builtins.int')
                     and v.fullname() != 'typing.Undefined'):
                 tmp = self.alloc_register()
                 self.add(SetRNone(tmp))
                 self.add(SetGR(v.fullname(), tmp))
     
     for d in mfile.defs:
         d.accept(self)
     self.add_implicit_return()
     self.generated['__init'] = FuncIcode(0, self.blocks,
                                          self.register_types)
     # TODO leave?
     return -1
开发者ID:FlorianLudwig,项目名称:mypy,代码行数:29,代码来源:icode.py

示例6: visit_mypy_file

# 需要导入模块: from mypy.nodes import MypyFile [as 别名]
# 或者: from mypy.nodes.MypyFile import fullname [as 别名]
 def visit_mypy_file(self, o: MypyFile) -> None:
     self.scope.enter_file(o.fullname())
     self.is_package_init_file = o.is_package_init_file()
     self.add_type_alias_deps(self.scope.current_target())
     for trigger, targets in o.plugin_deps.items():
         self.map.setdefault(trigger, set()).update(targets)
     super().visit_mypy_file(o)
     self.scope.leave()
开发者ID:Michael0x2a,项目名称:mypy,代码行数:10,代码来源:deps.py

示例7: visit_file

# 需要导入模块: from mypy.nodes import MypyFile [as 别名]
# 或者: from mypy.nodes.MypyFile import fullname [as 别名]
 def visit_file(self, file_node: MypyFile, fnam: str, options: Options,
                patches: List[Tuple[int, Callable[[], None]]]) -> None:
     self.recurse_into_functions = True
     self.errors.set_file(fnam, file_node.fullname(), scope=self.scope)
     self.options = options
     self.sem.options = options
     self.patches = patches
     self.is_typeshed_file = self.errors.is_typeshed_file(fnam)
     self.sem.cur_mod_id = file_node.fullname()
     self.cur_mod_node = file_node
     self.sem.globals = file_node.names
     with experiments.strict_optional_set(options.strict_optional):
         self.scope.enter_file(file_node.fullname())
         self.accept(file_node)
         self.analyze_symbol_table(file_node.names)
         self.scope.leave()
     del self.cur_mod_node
     self.patches = []
开发者ID:sixolet,项目名称:mypy,代码行数:20,代码来源:semanal_pass3.py

示例8: visit_file

# 需要导入模块: from mypy.nodes import MypyFile [as 别名]
# 或者: from mypy.nodes.MypyFile import fullname [as 别名]
 def visit_file(self, file_node: MypyFile, fnam: str, options: Options,
                patches: List[Tuple[int, Callable[[], None]]]) -> None:
     self.recurse_into_functions = True
     self.options = options
     self.sem.options = options
     self.patches = patches
     self.is_typeshed_file = self.errors.is_typeshed_file(fnam)
     self.sem.cur_mod_id = file_node.fullname()
     self.cur_mod_node = file_node
     self.sem.globals = file_node.names
开发者ID:mananpal1997,项目名称:mypy,代码行数:12,代码来源:semanal_pass3.py

示例9: create_indirect_imported_name

# 需要导入模块: from mypy.nodes import MypyFile [as 别名]
# 或者: from mypy.nodes.MypyFile import fullname [as 别名]
def create_indirect_imported_name(file_node: MypyFile,
                                  module: str,
                                  relative: int,
                                  imported_name: str) -> Optional[SymbolTableNode]:
    """Create symbol table entry for a name imported from another module.

    These entries act as indirect references.
    """
    target_module, ok = correct_relative_import(
        file_node.fullname(),
        relative,
        module,
        file_node.is_package_init_file())
    if not ok:
        return None
    target_name = '%s.%s' % (target_module, imported_name)
    link = ImportedName(target_name)
    # Use GDEF since this refers to a module-level definition.
    return SymbolTableNode(GDEF, link)
开发者ID:python,项目名称:mypy,代码行数:21,代码来源:semanal_shared.py

示例10: dump_type_stats

# 需要导入模块: from mypy.nodes import MypyFile [as 别名]
# 或者: from mypy.nodes.MypyFile import fullname [as 别名]
def dump_type_stats(tree: MypyFile, path: str, inferred: bool = False,
                    typemap: Optional[Dict[Expression, Type]] = None) -> None:
    if is_special_module(path):
        return
    print(path)
    visitor = StatisticsVisitor(inferred, filename=tree.fullname(), typemap=typemap)
    tree.accept(visitor)
    for line in visitor.output:
        print(line)
    print('  ** precision **')
    print('  precise  ', visitor.num_precise_exprs)
    print('  imprecise', visitor.num_imprecise_exprs)
    print('  any      ', visitor.num_any_exprs)
    print('  ** kinds **')
    print('  simple   ', visitor.num_simple_types)
    print('  generic  ', visitor.num_generic_types)
    print('  function ', visitor.num_function_types)
    print('  tuple    ', visitor.num_tuple_types)
    print('  TypeVar  ', visitor.num_typevar_types)
    print('  complex  ', visitor.num_complex_types)
    print('  any      ', visitor.num_any_types)
开发者ID:python,项目名称:mypy,代码行数:23,代码来源:stats.py

示例11: visit_mypy_file

# 需要导入模块: from mypy.nodes import MypyFile [as 别名]
# 或者: from mypy.nodes.MypyFile import fullname [as 别名]
 def visit_mypy_file(self, f: MypyFile) -> None:
     self.is_typing = f.fullname() == 'typing' or f.fullname() == 'builtins'
     super().visit_mypy_file(f)
开发者ID:Michael0x2a,项目名称:mypy,代码行数:5,代码来源:visitors.py

示例12: get_additional_deps

# 需要导入模块: from mypy.nodes import MypyFile [as 别名]
# 或者: from mypy.nodes.MypyFile import fullname [as 别名]
 def get_additional_deps(self, file: MypyFile) -> List[Tuple[int, str, int]]:
     if file.fullname() == '__main__':
         return [(10, 'err', -1)]
     return []
开发者ID:Michael0x2a,项目名称:mypy,代码行数:6,代码来源:depshook.py

示例13: visit_mypy_file

# 需要导入模块: from mypy.nodes import MypyFile [as 别名]
# 或者: from mypy.nodes.MypyFile import fullname [as 别名]
 def visit_mypy_file(self, o: MypyFile) -> None:
     self.errors.set_file(o.path, o.fullname(), scope=self.scope)
     self.scope.enter_file(o.fullname())
     super().visit_mypy_file(o)
     self.scope.leave()
开发者ID:mananpal1997,项目名称:mypy,代码行数:7,代码来源:semanal_typeargs.py

示例14: visit_mypy_file

# 需要导入模块: from mypy.nodes import MypyFile [as 别名]
# 或者: from mypy.nodes.MypyFile import fullname [as 别名]
 def visit_mypy_file(self, o: MypyFile) -> None:
     self.scope.enter_file(o.fullname())
     self.is_package_init_file = o.is_package_init_file()
     self.add_type_alias_deps(self.scope.current_target())
     super().visit_mypy_file(o)
     self.scope.leave()
开发者ID:sixolet,项目名称:mypy,代码行数:8,代码来源:deps.py

示例15: visit_mypy_file

# 需要导入模块: from mypy.nodes import MypyFile [as 别名]
# 或者: from mypy.nodes.MypyFile import fullname [as 别名]
 def visit_mypy_file(self, o: MypyFile) -> None:
     self.enter_file_scope(o.fullname())
     super().visit_mypy_file(o)
     self.leave_scope()
开发者ID:greatmazinger,项目名称:mypy,代码行数:6,代码来源:deps.py


注:本文中的mypy.nodes.MypyFile.fullname方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。