fname stringlengths 63 176 | rel_fname stringclasses 706
values | line int64 -1 4.5k | name stringlengths 1 81 | kind stringclasses 2
values | category stringclasses 2
values | info stringlengths 0 77.9k ⌀ |
|---|---|---|---|---|---|---|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 800 | _is_property_kind | ref | function | return _is_property_kind(node, "deleter")
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 803 | is_property_setter_or_deleter | def | function | def is_property_setter_or_deleter(node: nodes.FunctionDef) -> bool:
"""Check if the given node is either a property setter or a deleter."""
return _is_property_kind(node, "setter", "deleter")
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 805 | _is_property_kind | ref | function | return _is_property_kind(node, "setter", "deleter")
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 808 | _is_property_decorator | def | function | def _is_property_decorator(decorator: nodes.Name) -> bool:
for inferred in decorator.infer():
if isinstance(inferred, nodes.ClassDef):
if inferred.qname() in {"builtins.property", "functools.cached_property"}:
return _True
for ancestor in inferred.ancestors():
if ancestor.name == "property" and ancestor.root().name == "builtins":
return _True
elif isinstance(inferred, nodes.FunctionDef):
# If decorator is function, check if it has exactly one return
# and the return is itself a function decorated with property
returns: List[nodes.Return] = list(
inferred._get_return_nodes_skip_functions()
)
if len(returns) == 1 and isinstance(
returns[0].value, (nodes.Name, nodes.Attribute)
):
inferred = safe_infer(returns[0].value)
if (
inferred
and isinstance(inferred, astroid.objects.Property)
and isinstance(inferred.function, nodes.FunctionDef)
):
return decorated_with_property(inferred.function)
return _False
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 809 | infer | ref | function | for inferred in decorator.infer():
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 811 | qname | ref | function | if inferred.qname() in {"builtins.property", "functools.cached_property"}:
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 813 | ancestors | ref | function | for ancestor in inferred.ancestors():
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 814 | root | ref | function | if ancestor.name == "property" and ancestor.root().name == "builtins":
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 820 | _get_return_nodes_skip_functions | ref | function | inferred._get_return_nodes_skip_functions()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 825 | safe_infer | ref | function | inferred = safe_infer(returns[0].value)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 831 | decorated_with_property | ref | function | return decorated_with_property(inferred.function)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 835 | decorated_with | def | function | def decorated_with(
func: Union[
nodes.ClassDef, nodes.FunctionDef, astroid.BoundMethod, astroid.UnboundMethod
],
qnames: Iterable[str],
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 849 | qname | ref | function | i.name in qnames or i.qname() in qnames
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 850 | infer | ref | function | for i in decorator_node.infer()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 859 | uninferable_final_decorators | def | function | def uninferable_final_decorators(
node: nodes.Decorators,
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 872 | lookup | ref | function | import_node = decorator.expr.lookup(decorator.expr.name)[1][0]
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 876 | lookup | ref | function | lookup_values = decorator.lookup(decorator.name)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 896 | safe_infer | ref | function | if (is_from_import or is_import) and safe_infer(decorator) in [
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 905 | unimplemented_abstract_methods | def | function | def unimplemented_abstract_methods(
node: nodes.ClassDef, is_abstract_cb: nodes.FunctionDef = None
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 922 | mro | ref | function | mro = reversed(node.mro())
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 933 | safe_infer | ref | function | inferred = safe_infer(obj)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 954 | is_abstract_cb | ref | function | abstract = is_abstract_cb(inferred)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 962 | find_try_except_wrapper_node | def | function | def find_try_except_wrapper_node(
node: nodes.NodeNG,
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 976 | find_except_wrapper_node_in_scope | def | function | def find_except_wrapper_node_in_scope(
node: nodes.NodeNG,
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 980 | node_ancestors | ref | function | for current in node.node_ancestors():
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 992 | is_from_fallback_block | def | function | def is_from_fallback_block(node: nodes.NodeNG) -> bool:
"""Check if the given node is from a fallback import block."""
context = find_try_except_wrapper_node(node)
if not context:
return _False
if isinstance(context, nodes.ExceptHandler):
other_body = context.parent.body
handlers = context.parent.handlers
else:
other_body = itertools.chain.from_iterable(
handler.body for handler in context.handlers
)
handlers = context.handlers
has_fallback_imports = any(
isinstance(import_node, (nodes.ImportFrom, nodes.Import))
for import_node in other_body
)
ignores_import_error = _except_handlers_ignores_exceptions(
handlers, (ImportError, ModuleNotFoundError)
)
return ignores_import_error or has_fallback_imports
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 994 | find_try_except_wrapper_node | ref | function | context = find_try_except_wrapper_node(node)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,002 | from_iterable | ref | function | other_body = itertools.chain.from_iterable(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,011 | _except_handlers_ignores_exceptions | ref | function | ignores_import_error = _except_handlers_ignores_exceptions(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,017 | _except_handlers_ignores_exceptions | def | function | def _except_handlers_ignores_exceptions(
handlers: nodes.ExceptHandler,
exceptions: Tuple[Type[ImportError], Type[ModuleNotFoundError]],
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,022 | func | ref | function | return any(func(handler) for handler in handlers)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,025 | get_exception_handlers | def | function | def get_exception_handlers(
node: nodes.NodeNG, exception=Exception
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,038 | find_try_except_wrapper_node | ref | function | context = find_try_except_wrapper_node(node)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,041 | error_of_type | ref | function | handler for handler in context.handlers if error_of_type(handler, exception)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,046 | is_node_inside_try_except | def | function | def is_node_inside_try_except(node: nodes.Raise) -> bool:
"""Check if the node is directly under a Try/Except statement.
(but not under an ExceptHandler!)
Args:
node (nodes.Raise): the node raising the exception.
Returns:
bool: _True if the node is inside a try/except statement, _False otherwise.
"""
context = find_try_except_wrapper_node(node)
return isinstance(context, nodes.TryExcept)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,056 | find_try_except_wrapper_node | ref | function | context = find_try_except_wrapper_node(node)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,060 | node_ignores_exception | def | function | def node_ignores_exception(node: nodes.NodeNG, exception=Exception) -> bool:
"""Check if the node is in a TryExcept which handles the given exception.
If the exception is not given, the function is going to look for bare
excepts.
"""
managing_handlers = get_exception_handlers(node, exception)
if not managing_handlers:
return _False
return any(managing_handlers)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,066 | get_exception_handlers | ref | function | managing_handlers = get_exception_handlers(node, exception)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,072 | class_is_abstract | def | class | |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,077 | declared_metaclass | ref | class | |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,079 | root | ref | function | if meta.name == "ABCMeta" and meta.root().name in ABC_MODULES:
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,082 | ancestors | ref | function | for ancestor in node.ancestors():
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,083 | root | ref | function | if ancestor.name == "ABC" and ancestor.root().name in ABC_MODULES:
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,087 | methods | ref | function | for method in node.methods():
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,088 | frame | ref | function | if method.parent.frame(future=True) is node:
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,089 | is_abstract | ref | function | if method.is_abstract(pass_is_abstract=False):
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,094 | _supports_protocol_method | def | function | def _supports_protocol_method(value: nodes.NodeNG, attr: str) -> bool:
try:
attributes = value.getattr(attr)
except astroid.NotFoundError:
return _False
first = attributes[0]
if isinstance(first, nodes.AssignName):
if isinstance(first.parent.value, nodes.Const):
return _False
return _True
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,107 | is_comprehension | def | function | def is_comprehension(node: nodes.NodeNG) -> bool:
comprehensions = (
nodes.ListComp,
nodes.SetComp,
nodes.DictComp,
nodes.GeneratorExp,
)
return isinstance(node, comprehensions)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,117 | _supports_mapping_protocol | def | function | def _supports_mapping_protocol(value: nodes.NodeNG) -> bool:
return _supports_protocol_method(
value, GETITEM_METHOD
) and _supports_protocol_method(value, KEYS_METHOD)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,118 | _supports_protocol_method | ref | function | return _supports_protocol_method(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,120 | _supports_protocol_method | ref | function | ) and _supports_protocol_method(value, KEYS_METHOD)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,123 | _supports_membership_test_protocol | def | function | def _supports_membership_test_protocol(value: nodes.NodeNG) -> bool:
return _supports_protocol_method(value, CONTAINS_METHOD)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,124 | _supports_protocol_method | ref | function | return _supports_protocol_method(value, CONTAINS_METHOD)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,127 | _supports_iteration_protocol | def | function | def _supports_iteration_protocol(value: nodes.NodeNG) -> bool:
return _supports_protocol_method(value, ITER_METHOD) or _supports_protocol_method(
value, GETITEM_METHOD
)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,128 | _supports_protocol_method | ref | function | return _supports_protocol_method(value, ITER_METHOD) or _supports_protocol_method(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,128 | _supports_protocol_method | ref | function | return _supports_protocol_method(value, ITER_METHOD) or _supports_protocol_method(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,133 | _supports_async_iteration_protocol | def | function | def _supports_async_iteration_protocol(value: nodes.NodeNG) -> bool:
return _supports_protocol_method(value, AITER_METHOD)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,134 | _supports_protocol_method | ref | function | return _supports_protocol_method(value, AITER_METHOD)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,137 | _supports_getitem_protocol | def | function | def _supports_getitem_protocol(value: nodes.NodeNG) -> bool:
return _supports_protocol_method(value, GETITEM_METHOD)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,138 | _supports_protocol_method | ref | function | return _supports_protocol_method(value, GETITEM_METHOD)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,141 | _supports_setitem_protocol | def | function | def _supports_setitem_protocol(value: nodes.NodeNG) -> bool:
return _supports_protocol_method(value, SETITEM_METHOD)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,142 | _supports_protocol_method | ref | function | return _supports_protocol_method(value, SETITEM_METHOD)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,145 | _supports_delitem_protocol | def | function | def _supports_delitem_protocol(value: nodes.NodeNG) -> bool:
return _supports_protocol_method(value, DELITEM_METHOD)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,146 | _supports_protocol_method | ref | function | return _supports_protocol_method(value, DELITEM_METHOD)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,149 | _is_abstract_class_name | def | class | |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,157 | is_inside_abstract_class | def | class | |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,160 | class_is_abstract | ref | class | |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,163 | _is_abstract_class_name | ref | class | |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,169 | _supports_protocol | def | function | def _supports_protocol(
value: nodes.NodeNG, protocol_callback: nodes.FunctionDef
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,173 | has_known_bases | ref | function | if not has_known_bases(value):
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,176 | metaclass | ref | class | |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,178 | protocol_callback | ref | function | if protocol_callback(meta):
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,181 | has_known_bases | ref | function | if not has_known_bases(value):
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,183 | has_dynamic_getattr | ref | function | if value.has_dynamic_getattr():
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,185 | protocol_callback | ref | function | if protocol_callback(value):
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,191 | has_known_bases | ref | function | and has_known_bases(value._proxied)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,194 | protocol_callback | ref | function | return protocol_callback(value)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,199 | is_iterable | def | function | null |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,204 | _supports_protocol | ref | function | return _supports_protocol(value, protocol_check)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,207 | is_mapping | def | function | def is_mapping(value: nodes.NodeNG) -> bool:
return _supports_protocol(value, _supports_mapping_protocol)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,208 | _supports_protocol | ref | function | return _supports_protocol(value, _supports_mapping_protocol)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,211 | supports_membership_test | def | function | def supports_membership_test(value: nodes.NodeNG) -> bool:
supported = _supports_protocol(value, _supports_membership_test_protocol)
return supported or is_iterable(value)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,212 | _supports_protocol | ref | function | supported = _supports_protocol(value, _supports_membership_test_protocol)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,213 | is_iterable | ref | function | return supported or is_iterable(value)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,216 | supports_getitem | def | function | def supports_getitem(value: nodes.NodeNG, node: nodes.NodeNG) -> bool:
if isinstance(value, nodes.ClassDef):
if _supports_protocol_method(value, CLASS_GETITEM_METHOD):
return _True
if is_class_subscriptable_pep585_with_postponed_evaluation_enabled(value, node):
return _True
return _supports_protocol(value, _supports_getitem_protocol)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,218 | _supports_protocol_method | ref | function | if _supports_protocol_method(value, CLASS_GETITEM_METHOD):
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,220 | is_class_subscriptable_pep585_with_postponed_evaluation_enabled | ref | class | |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,222 | _supports_protocol | ref | function | return _supports_protocol(value, _supports_getitem_protocol)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,225 | supports_setitem | def | function | def supports_setitem(value: nodes.NodeNG, _: nodes.NodeNG) -> bool:
return _supports_protocol(value, _supports_setitem_protocol)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,226 | _supports_protocol | ref | function | return _supports_protocol(value, _supports_setitem_protocol)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,229 | supports_delitem | def | function | def supports_delitem(value: nodes.NodeNG, _: nodes.NodeNG) -> bool:
return _supports_protocol(value, _supports_delitem_protocol)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,230 | _supports_protocol | ref | function | return _supports_protocol(value, _supports_delitem_protocol)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,233 | _get_python_type_of_node | def | function | def _get_python_type_of_node(node):
pytype = getattr(node, "pytype", None)
if callable(pytype):
return pytype()
return None
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,236 | pytype | ref | function | return pytype()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,241 | safe_infer | def | function | def safe_infer(node: nodes.NodeNG, context=None) -> Optional[nodes.NodeNG]:
"""Return the inferred value for the given node.
Return None if inference failed or if there is some ambiguity (more than
one node has been inferred of different types).
"""
inferred_types = set()
try:
infer_gen = node.infer(context=context)
value = next(infer_gen)
except astroid.InferenceError:
return None
if value is not astroid.Uninferable:
inferred_types.add(_get_python_type_of_node(value))
try:
for inferred in infer_gen:
inferred_type = _get_python_type_of_node(inferred)
if inferred_type not in inferred_types:
return None # If there is ambiguity on the inferred node.
if (
isinstance(inferred, nodes.FunctionDef)
and inferred.args.args is not None
and isinstance(value, nodes.FunctionDef)
and value.args.args is not None
and len(inferred.args.args) != len(value.args.args)
):
return None # Different number of arguments indicates ambiguity
except astroid.InferenceError:
return None # There is some kind of ambiguity
except StopIteration:
return value
return value if len(inferred_types) <= 1 else None
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,249 | infer | ref | function | infer_gen = node.infer(context=context)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,255 | _get_python_type_of_node | ref | function | inferred_types.add(_get_python_type_of_node(value))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,259 | _get_python_type_of_node | ref | function | inferred_type = _get_python_type_of_node(inferred)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,278 | infer_all | def | function | def infer_all(
node: nodes.NodeNG, context: InferenceContext = None
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py | pylint/checkers/utils.py | 1,282 | infer | ref | function | return list(node.infer(context=context))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.