本文整理汇总了Python中mypy.nodes.Var.is_property方法的典型用法代码示例。如果您正苦于以下问题:Python Var.is_property方法的具体用法?Python Var.is_property怎么用?Python Var.is_property使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mypy.nodes.Var
的用法示例。
在下文中一共展示了Var.is_property方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_field
# 需要导入模块: from mypy.nodes import Var [as 别名]
# 或者: from mypy.nodes.Var import is_property [as 别名]
def add_field(var: Var, is_initialized_in_class: bool = False,
is_property: bool = False) -> None:
var.info = info
var.is_initialized_in_class = is_initialized_in_class
var.is_property = is_property
var._fullname = '%s.%s' % (info.fullname(), var.name())
info.names[var.name()] = SymbolTableNode(MDEF, var)
示例2: build_enum_call_typeinfo
# 需要导入模块: from mypy.nodes import Var [as 别名]
# 或者: from mypy.nodes.Var import is_property [as 别名]
def build_enum_call_typeinfo(self, name: str, items: List[str], fullname: str) -> TypeInfo:
base = self.api.named_type_or_none(fullname)
assert base is not None
info = self.api.basic_new_typeinfo(name, base)
info.metaclass_type = info.calculate_metaclass_type()
info.is_enum = True
for item in items:
var = Var(item)
var.info = info
var.is_property = True
var._fullname = '{}.{}'.format(self.api.qualified_name(name), item)
info.names[item] = SymbolTableNode(MDEF, var)
return info
示例3: _make_frozen
# 需要导入模块: from mypy.nodes import Var [as 别名]
# 或者: from mypy.nodes.Var import is_property [as 别名]
def _make_frozen(ctx: 'mypy.plugin.ClassDefContext', attributes: List[Attribute]) -> None:
"""Turn all the attributes into properties to simulate frozen classes."""
for attribute in attributes:
if attribute.name in ctx.cls.info.names:
# This variable belongs to this class so we can modify it.
node = ctx.cls.info.names[attribute.name].node
assert isinstance(node, Var)
node.is_property = True
else:
# This variable belongs to a super class so create new Var so we
# can modify it.
var = Var(attribute.name, ctx.cls.info[attribute.name].type)
var.info = ctx.cls.info
var._fullname = '%s.%s' % (ctx.cls.info.fullname(), var.name())
ctx.cls.info.names[var.name()] = SymbolTableNode(MDEF, var)
var.is_property = True
示例4: visit_var
# 需要导入模块: from mypy.nodes import Var [as 别名]
# 或者: from mypy.nodes.Var import is_property [as 别名]
def visit_var(self, node: Var) -> Var:
# Note that a Var must be transformed to a Var.
if node in self.var_map:
return self.var_map[node]
new = Var(node.name(), self.optional_type(node.type))
new.line = node.line
new._fullname = node._fullname
new.info = node.info
new.is_self = node.is_self
new.is_ready = node.is_ready
new.is_initialized_in_class = node.is_initialized_in_class
new.is_staticmethod = node.is_staticmethod
new.is_property = node.is_property
new.set_line(node.line)
self.var_map[node] = new
return new