本文整理汇总了Python中pylint.checkers.utils.decorated_with_property函数的典型用法代码示例。如果您正苦于以下问题:Python decorated_with_property函数的具体用法?Python decorated_with_property怎么用?Python decorated_with_property使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decorated_with_property函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: visit_return
def visit_return(self, node):
if not utils.returns_something(node):
return
func_node = node.frame()
if not isinstance(func_node, astroid.FunctionDef):
return
doc = utils.docstringify(
func_node.doc, self.config.default_docstring_type,
)
if not doc.is_valid() and self.config.accept_no_return_doc:
return
is_property = checker_utils.decorated_with_property(func_node)
if not (doc.has_returns() or
(doc.has_property_returns() and is_property)):
self.add_message(
'missing-return-doc',
node=func_node
)
if func_node.returns:
return
if not (doc.has_rtype() or
(doc.has_property_type() and is_property)):
self.add_message(
'missing-return-type-doc',
node=func_node
)
开发者ID:Marslo,项目名称:VimConfig,代码行数:32,代码来源:docparams.py
示例2: _is_attribute_property
def _is_attribute_property(name, klass):
""" Check if the given attribute *name* is a property
in the given *klass*.
It will look for `property` calls or for functions
with the given name, decorated by `property` or `property`
subclasses.
Returns ``True`` if the name is a property in the given klass,
``False`` otherwise.
"""
try:
attributes = klass.getattr(name)
except astroid.NotFoundError:
return False
property_name = "{0}.property".format(BUILTINS)
for attr in attributes:
try:
infered = next(attr.infer())
except astroid.InferenceError:
continue
if (isinstance(infered, astroid.Function) and
decorated_with_property(infered)):
return True
if infered.pytype() == property_name:
return True
return False
开发者ID:willemneal,项目名称:Docky,代码行数:27,代码来源:classes.py
示例3: get_methods
def get_methods(self, node):
"""return visible methods"""
methods = [
m for m in node.values()
if isinstance(m, astroid.FunctionDef)
and not decorated_with_property(m)
and self.show_attr(m.name)
]
return sorted(methods, key=lambda n: n.name)
开发者ID:aRkadeFR,项目名称:dotVim,代码行数:9,代码来源:diagrams.py
示例4: get_attrs
def get_attrs(self, node):
"""return visible attributes, possibly with class name"""
attrs = []
properties = [
(n, m) for n, m in node.items()
if isinstance(m, astroid.FunctionDef)
and decorated_with_property(m)
]
for node_name, ass_nodes in list(node.instance_attrs_type.items()) + \
list(node.locals_type.items()) + properties:
if not self.show_attr(node_name):
continue
names = self.class_names(ass_nodes)
if names:
node_name = "%s : %s" % (node_name, ", ".join(names))
attrs.append(node_name)
return sorted(attrs)
开发者ID:aRkadeFR,项目名称:dotVim,代码行数:17,代码来源:diagrams.py
示例5: leave_functiondef
def leave_functiondef(self, node):
"""on method node, check if this method couldn't be a function
ignore class, static and abstract methods, initializer,
methods overridden from a parent class.
"""
if node.is_method():
if node.args.args is not None:
self._first_attrs.pop()
if not self.linter.is_message_enabled('no-self-use'):
return
class_node = node.parent.frame()
if (self._meth_could_be_func and node.type == 'method'
and node.name not in PYMETHODS
and not (node.is_abstract() or
overrides_a_method(class_node, node.name) or
decorated_with_property(node) or
(six.PY3 and _has_bare_super_call(node)))):
self.add_message('no-self-use', node=node)
开发者ID:danbaehr,项目名称:project2,代码行数:19,代码来源:classes.py
示例6: _check_uninferable_callfunc
def _check_uninferable_callfunc(self, node):
"""
Check that the given uninferable CallFunc node does not
call an actual function.
"""
if not isinstance(node.func, astroid.Attribute):
return
# Look for properties. First, obtain
# the lhs of the Getattr node and search the attribute
# there. If that attribute is a property or a subclass of properties,
# then most likely it's not callable.
# TODO: since astroid doesn't understand descriptors very well
# we will not handle them here, right now.
expr = node.func.expr
klass = safe_infer(expr)
if (klass is None or klass is astroid.YES or
not isinstance(klass, astroid.Instance)):
return
try:
attrs = klass._proxied.getattr(node.func.attrname)
except exceptions.NotFoundError:
return
for attr in attrs:
if attr is astroid.YES:
continue
if not isinstance(attr, astroid.FunctionDef):
continue
# Decorated, see if it is decorated with a property.
# Also, check the returns and see if they are callable.
if decorated_with_property(attr):
if all(return_node.callable()
for return_node in attr.infer_call_result(node)):
continue
else:
self.add_message('not-callable', node=node,
args=node.func.as_string())
break
开发者ID:CharlesFerguson,项目名称:pylint,代码行数:43,代码来源:typecheck.py
示例7: get_setters_property
def get_setters_property(node):
"""Get the property node for the given setter node.
:param node: The node to get the property for.
:type node: astroid.FunctionDef
:rtype: astroid.FunctionDef or None
:returns: The node relating to the property of the given setter node,
or None if one could not be found.
"""
property_ = None
property_name = get_setters_property_name(node)
class_node = utils.node_frame_class(node)
if property_name and class_node:
class_attrs = class_node.getattr(node.name)
for attr in class_attrs:
if utils.decorated_with_property(attr):
property_ = attr
break
return property_
开发者ID:bluesheeptoken,项目名称:pylint,代码行数:22,代码来源:_check_docs_utils.py
注:本文中的pylint.checkers.utils.decorated_with_property函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论