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/unsupported_version.py
pylint/checkers/unsupported_version.py
58
visit_joinedstr
def
function
def visit_joinedstr(self, node: nodes.JoinedStr) -> None: """Check f-strings.""" if not self._py36_plus: self.add_message("using-f-string-in-unsupported-version", node=node) @check_messages("using-final-decorator-in-unsupported-version") def visit_decorators(self, node: nodes.Decorators) -> None: """Check decorators.""" self._check_typing_final(node) def _check_typing_final(self, node: nodes.Decorators) -> None: """Add a message when the `typing.final` decorator is used and the py-version is lower than 3.8 """ if self._py38_plus: return decorators = [] for decorator in node.get_children(): inferred = safe_infer(decorator) if inferred and inferred.qname() == "typing.final": decorators.append(decorator) for decorator in decorators or uninferable_final_decorators(node): self.add_message( "using-final-decorator-in-unsupported-version", node=decorator )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/unsupported_version.py
pylint/checkers/unsupported_version.py
61
add_message
ref
function
self.add_message("using-f-string-in-unsupported-version", node=node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/unsupported_version.py
pylint/checkers/unsupported_version.py
63
check_messages
ref
function
@check_messages("using-final-decorator-in-unsupported-version")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/unsupported_version.py
pylint/checkers/unsupported_version.py
64
visit_decorators
def
function
def visit_decorators(self, node: nodes.Decorators) -> None: """Check decorators.""" self._check_typing_final(node) def _check_typing_final(self, node: nodes.Decorators) -> None: """Add a message when the `typing.final` decorator is used and the py-version is lower than 3.8 """ if self._py38_plus: return decorators = [] for decorator in node.get_children(): inferred = safe_infer(decorator) if inferred and inferred.qname() == "typing.final": decorators.append(decorator) for decorator in decorators or uninferable_final_decorators(node): self.add_message( "using-final-decorator-in-unsupported-version", node=decorator )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/unsupported_version.py
pylint/checkers/unsupported_version.py
66
_check_typing_final
ref
function
self._check_typing_final(node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/unsupported_version.py
pylint/checkers/unsupported_version.py
68
_check_typing_final
def
function
def _check_typing_final(self, node: nodes.Decorators) -> None: """Add a message when the `typing.final` decorator is used and the py-version is lower than 3.8 """ if self._py38_plus: return decorators = [] for decorator in node.get_children(): inferred = safe_infer(decorator) if inferred and inferred.qname() == "typing.final": decorators.append(decorator) for decorator in decorators or uninferable_final_decorators(node): self.add_message( "using-final-decorator-in-unsupported-version", node=decorator )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/unsupported_version.py
pylint/checkers/unsupported_version.py
76
get_children
ref
function
for decorator in node.get_children():
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/unsupported_version.py
pylint/checkers/unsupported_version.py
77
safe_infer
ref
function
inferred = safe_infer(decorator)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/unsupported_version.py
pylint/checkers/unsupported_version.py
78
qname
ref
function
if inferred and inferred.qname() == "typing.final":
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/unsupported_version.py
pylint/checkers/unsupported_version.py
81
uninferable_final_decorators
ref
function
for decorator in decorators or uninferable_final_decorators(node):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/unsupported_version.py
pylint/checkers/unsupported_version.py
82
add_message
ref
function
self.add_message(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/unsupported_version.py
pylint/checkers/unsupported_version.py
87
register
def
function
def register(linter: "PyLinter") -> None: linter.register_checker(UnsupportedVersionChecker(linter))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/unsupported_version.py
pylint/checkers/unsupported_version.py
88
register_checker
ref
function
linter.register_checker(UnsupportedVersionChecker(linter))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/unsupported_version.py
pylint/checkers/unsupported_version.py
88
UnsupportedVersionChecker
ref
function
linter.register_checker(UnsupportedVersionChecker(linter))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
286
NoSuchArgumentError
def
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
290
InferredTypeError
def
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
294
is_inside_lambda
def
function
def is_inside_lambda(node: nodes.NodeNG) -> bool: """Return whether the given node is inside a lambda.""" warnings.warn( "utils.is_inside_lambda will be removed in favour of calling " "utils.get_node_first_ancestor_of_type(x, nodes.Lambda) in pylint 3.0", DeprecationWarning, ) return any(isinstance(parent, nodes.Lambda) for parent in node.node_ancestors())
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
301
node_ancestors
ref
function
return any(isinstance(parent, nodes.Lambda) for parent in node.node_ancestors())
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
304
get_all_elements
def
function
def get_all_elements( node: nodes.NodeNG,
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
310
get_all_elements
ref
function
yield from get_all_elements(child)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
315
is_super
def
function
def is_super(node: nodes.NodeNG) -> bool: """Return _True if the node is referencing the "super" builtin function.""" if getattr(node, "name", None) == "super" and node.root().name == "builtins": return _True return _False
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
317
root
ref
function
if getattr(node, "name", None) == "super" and node.root().name == "builtins":
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
322
is_error
def
function
def is_error(node: nodes.FunctionDef) -> bool: """Return true if the given function node only raises an exception.""" return len(node.body) == 1 and isinstance(node.body[0], nodes.Raise)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
331
is_builtin_object
def
function
def is_builtin_object(node: nodes.NodeNG) -> bool: """Returns _True if the given node is an object from the __builtin__ module.""" return node and node.root().name == "builtins"
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
333
root
ref
function
return node and node.root().name == "builtins"
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
336
is_builtin
def
function
def is_builtin(name: str) -> bool: """Return true if <name> could be considered as a builtin defined by python.""" return name in builtins or name in SPECIAL_BUILTINS # type: ignore[attr-defined]
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
341
is_defined_in_scope
def
function
def is_defined_in_scope( var_node: nodes.NodeNG, varname: str, scope: nodes.NodeNG,
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
357
nodes_of_class
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
362
parent_of
ref
function
if expr.parent_of(var_node):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
367
is_argument
ref
function
if scope.args.is_argument(varname):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
371
parent_of
ref
function
if scope.args.parent_of(var_node):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
373
default_value
ref
function
scope.args.default_value(varname)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
375
is_defined_in_scope
ref
function
is_defined_in_scope(var_node, varname, scope)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
389
is_defined_before
def
function
def is_defined_before(var_node: nodes.Name) -> bool: """Check if the given variable node is defined before. Verify that the variable node is defined by a parent node (list, set, dict, or generator comprehension, lambda) or in a previous sibling node on the same line (statement_defining ; statement_using). """ varname = var_node.name for parent in var_node.node_ancestors(): if is_defined_in_scope(var_node, varname, parent): return _True # possibly multiple statements on the same line using semicolon separator stmt = var_node.statement(future=_True) _node = stmt.previous_sibling() lineno = stmt.fromlineno while _node and _node.fromlineno == lineno: for assign_node in _node.nodes_of_class(nodes.AssignName): if assign_node.name == varname: return _True for imp_node in _node.nodes_of_class((nodes.ImportFrom, nodes.Import)): if varname in [name[1] or name[0] for name in imp_node.names]: return _True _node = _node.previous_sibling() return _False
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
398
node_ancestors
ref
function
for parent in var_node.node_ancestors():
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
399
is_defined_in_scope
ref
function
if is_defined_in_scope(var_node, varname, parent):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
402
statement
ref
function
stmt = var_node.statement(future=True)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
403
previous_sibling
ref
function
_node = stmt.previous_sibling()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
406
nodes_of_class
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
409
nodes_of_class
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
412
previous_sibling
ref
function
_node = _node.previous_sibling()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
416
is_default_argument
def
function
def is_default_argument( node: nodes.NodeNG, scope: Optional[nodes.NodeNG] = None
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
423
scope
ref
function
scope = node.scope()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
431
nodes_of_class
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
437
is_func_decorator
def
function
def is_func_decorator(node: nodes.NodeNG) -> bool: """Return true if the name is used in function decorator.""" for parent in node.node_ancestors(): if isinstance(parent, nodes.Decorators): return _True if parent.is_statement or isinstance( parent, ( nodes.Lambda, nodes.ComprehensionScope, nodes.ListComp, ), ): break return _False
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
439
node_ancestors
ref
function
for parent in node.node_ancestors():
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
454
is_ancestor_name
def
function
def is_ancestor_name(frame: nodes.ClassDef, node: nodes.NodeNG) -> bool: """Return whether `frame` is an astroid.Class node with `node` in the subtree of its bases attribute """ if not isinstance(frame, nodes.ClassDef): return _False return any(node in base.nodes_of_class(nodes.Name) for base in frame.bases)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
460
nodes_of_class
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
463
is_being_called
def
function
def is_being_called(node: nodes.NodeNG) -> bool: """Return _True if node is the function being called in a Call node.""" return isinstance(node.parent, nodes.Call) and node.parent.func is node
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
468
assign_parent
def
function
def assign_parent(node: nodes.NodeNG) -> nodes.NodeNG: """Return the higher parent which is not an AssignName, Tuple or List node.""" while node and isinstance(node, (nodes.AssignName, nodes.Tuple, nodes.List)): node = node.parent return node
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
475
overrides_a_method
def
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
479
ancestors
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
487
check_messages
def
function
def check_messages(*messages: str) -> Callable: """Decorator to store messages that are handled by a checker method.""" def store_messages(func): func.checks_msgs = messages return func return store_messages
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
490
store_messages
def
function
def store_messages(func): func.checks_msgs = messages return func return store_messages
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
497
IncompleteFormatString
def
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
501
UnsupportedFormatCharacter
def
class
__init__
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
511
parse_format_string
def
function
def parse_format_string( format_string: str,
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
524
next_char
def
function
def next_char(i): i += 1 if i == len(format_string): raise IncompleteFormatString return (i, format_string[i]) i = 0 while i < len(format_string): char = format_string[i] if char == "%": i, char = next_char(i) # Parse the mapping key (optional). key = None if char == "(": depth = 1 i, char = next_char(i) key_start = i while depth != 0: if char == "(": depth += 1 elif char == ")": depth -= 1 i, char = next_char(i) key_end = i - 1 key = format_string[key_start:key_end] # Parse the conversion flags (optional). while char in "#0- +": i, char = next_char(i) # Parse the minimum field width (optional). if char == "*": num_args += 1 i, char = next_char(i) else: while char in string.digits: i, char = next_char(i) # Parse the precision (optional). if char == ".": i, char = next_char(i) if char == "*": num_args += 1 i, char = next_char(i) else: while char in string.digits: i, char = next_char(i) # Parse the length modifier (optional). if char in "hlL": i, char = next_char(i) # Parse the conversion type (mandatory). flags = "diouxXeEfFgGcrs%a" if char not in flags: raise UnsupportedFormatCharacter(i) if key: keys.add(key) key_types[key] = char elif char != "%": num_args += 1 pos_types.append(char) i += 1 return keys, num_args, key_types, pos_types
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
534
next_char
ref
function
i, char = next_char(i)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
539
next_char
ref
function
i, char = next_char(i)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
546
next_char
ref
function
i, char = next_char(i)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
552
next_char
ref
function
i, char = next_char(i)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
556
next_char
ref
function
i, char = next_char(i)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
559
next_char
ref
function
i, char = next_char(i)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
562
next_char
ref
function
i, char = next_char(i)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
565
next_char
ref
function
i, char = next_char(i)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
568
next_char
ref
function
i, char = next_char(i)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
571
next_char
ref
function
i, char = next_char(i)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
575
UnsupportedFormatCharacter
ref
function
raise UnsupportedFormatCharacter(i)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
586
split_format_field_names
def
function
def split_format_field_names(format_string) -> Tuple[str, Iterable[Tuple[bool, str]]]: try: return _string.formatter_field_name_split(format_string) except ValueError as e: raise IncompleteFormatString() from e
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
590
IncompleteFormatString
ref
function
raise IncompleteFormatString() from e
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
593
collect_string_fields
def
function
def collect_string_fields(format_string) -> Iterable[Optional[str]]: """Given a format string, return an iterator of all the valid format fields. It handles nested fields as well. """ formatter = string.Formatter() try: parseiterator = formatter.parse(format_string) for result in parseiterator: if all(item is None for item in result[1:]): # not a replacement format continue name = result[1] nested = result[2] yield name if nested: yield from collect_string_fields(nested) except ValueError as exc: # Probably the format string is invalid. if exc.args[0].startswith("cannot switch from manual"): # On Jython, parsing a string with both manual # and automatic positions will fail with a ValueError, # while on CPython it will simply return the fields, # the validation being done in the interpreter (?). # We're just returning two mixed fields in order # to trigger the format-combined-specification check. yield "" yield "1" return raise IncompleteFormatString(format_string) from exc
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
600
parse
ref
function
parseiterator = formatter.parse(format_string)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
609
collect_string_fields
ref
function
yield from collect_string_fields(nested)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
622
IncompleteFormatString
ref
function
raise IncompleteFormatString(format_string) from exc
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
625
parse_format_method_string
def
function
def parse_format_method_string( format_string: str,
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
637
collect_string_fields
ref
function
for name in collect_string_fields(format_string):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
641
split_format_field_names
ref
function
keyname, fielditerator = split_format_field_names(name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
647
IncompleteFormatString
ref
function
raise IncompleteFormatString() from e
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
653
is_attr_protected
def
function
def is_attr_protected(attrname: str) -> bool: """Return _True if attribute name is protected (start with _ and some other details), _False otherwise. """ return ( attrname[0] == "_" and attrname != "_" and not (attrname.startswith("__") and attrname.endswith("__")) )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
664
node_frame_class
def
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
670
frame
ref
function
klass = node.frame(future=True)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
684
frame
ref
function
klass = klass.parent.frame(future=True)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
689
get_outer_class
def
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
691
frame
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
696
is_attr_private
def
function
def is_attr_private(attrname: str) -> Optional[Match[str]]: """Check that attribute name is private (at least two leading underscores, at most one trailing underscore) """ regex = re.compile("^_{2,}.*[^_]+_?$") return regex.match(attrname)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
704
get_argument_from_call
def
function
def get_argument_from_call( call_node: nodes.Call, position: Optional[int] = None, keyword: Optional[str] = None
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
734
inherit_from_std_ex
def
function
def inherit_from_std_ex(node: nodes.NodeNG) -> bool: """Return whether the given class node is subclass of exceptions.Exception. """ ancestors = node.ancestors() if hasattr(node, "ancestors") else [] return any( ancestor.name in {"Exception", "BaseException"} and ancestor.root().name == EXCEPTIONS_MODULE for ancestor in itertools.chain([node], ancestors) )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
738
ancestors
ref
function
ancestors = node.ancestors() if hasattr(node, "ancestors") else []
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
741
root
ref
function
and ancestor.root().name == EXCEPTIONS_MODULE
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
746
error_of_type
def
function
def error_of_type(handler: nodes.ExceptHandler, error_type) -> bool: """Check if the given exception handler catches the given error_type. The *handler* parameter is a node, representing an ExceptHandler node. The *error_type* can be an exception, such as AttributeError, the name of an exception, or it can be a tuple of errors. The function will return _True if the handler catches any of the given errors. """ def stringify_error(error): if not isinstance(error, str): return error.__name__ return error if not isinstance(error_type, tuple): error_type = (error_type,) expected_errors = {stringify_error(error) for error in error_type} if not handler.type: return _False return handler.catch(expected_errors)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
757
stringify_error
def
function
def stringify_error(error): if not isinstance(error, str): return error.__name__ return error if not isinstance(error_type, tuple): error_type = (error_type,) expected_errors = {stringify_error(error) for error in error_type} if not handler.type: return _False return handler.catch(expected_errors)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
764
stringify_error
ref
function
expected_errors = {stringify_error(error) for error in error_type}
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
767
catch
ref
function
return handler.catch(expected_errors)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
770
decorated_with_property
def
function
def decorated_with_property(node: nodes.FunctionDef) -> bool: """Detect if the given function node is decorated with a property.""" if not node.decorators: return _False for decorator in node.decorators.nodes: try: if _is_property_decorator(decorator): return _True except astroid.InferenceError: pass return _False
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
776
_is_property_decorator
ref
function
if _is_property_decorator(decorator):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
783
_is_property_kind
def
function
def _is_property_kind(node, *kinds): if not isinstance(node, (astroid.UnboundMethod, nodes.FunctionDef)): return _False if node.decorators: for decorator in node.decorators.nodes: if isinstance(decorator, nodes.Attribute) and decorator.attrname in kinds: return _True return _False
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
793
is_property_setter
def
function
def is_property_setter(node: nodes.FunctionDef) -> bool: """Check if the given node is a property setter.""" return _is_property_kind(node, "setter")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
795
_is_property_kind
ref
function
return _is_property_kind(node, "setter")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/utils.py
pylint/checkers/utils.py
798
is_property_deleter
def
function
def is_property_deleter(node: nodes.FunctionDef) -> bool: """Check if the given node is a property deleter.""" return _is_property_kind(node, "deleter")