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/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/not_checker.py
pylint/checkers/refactoring/not_checker.py
66
node_type
ref
function
for _type in (utils.node_type(left), utils.node_type(right)):
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/not_checker.py
pylint/checkers/refactoring/not_checker.py
66
node_type
ref
function
for _type in (utils.node_type(left), utils.node_type(right)):
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/not_checker.py
pylint/checkers/refactoring/not_checker.py
73
qname
ref
class
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/not_checker.py
pylint/checkers/refactoring/not_checker.py
77
as_string
ref
function
f"{left.as_string()} {self.reverse_op[operator]} {right.as_string()}"
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/not_checker.py
pylint/checkers/refactoring/not_checker.py
77
as_string
ref
function
f"{left.as_string()} {self.reverse_op[operator]} {right.as_string()}"
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/not_checker.py
pylint/checkers/refactoring/not_checker.py
79
add_message
ref
function
self.add_message(
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/not_checker.py
pylint/checkers/refactoring/not_checker.py
80
as_string
ref
function
"unneeded-not", node=node, args=(node.as_string(), suggestion)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
13
RecommendationChecker
def
class
open _is_builtin visit_call _check_consider_iterating_dictionary _check_use_maxsplit_arg visit_for _check_consider_using_enumerate _check_consider_using_dict_items visit_comprehension _check_consider_using_dict_items_comprehension _check_use_sequence_for_iteration visit_const _detect_replacable_format_call
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
69
_is_builtin
def
function
def _is_builtin(node, function): inferred = utils.safe_infer(node) if not inferred: return _False return utils.is_builtin_object(inferred) and inferred.name == function @utils.only_required_for_messages( "consider-iterating-dictionary", "use-maxsplit-arg" ) d...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
70
safe_infer
ref
function
inferred = utils.safe_infer(node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
73
is_builtin_object
ref
function
return utils.is_builtin_object(inferred) and inferred.name == function
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
75
only_required_for_messages
ref
function
@utils.only_required_for_messages(
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
78
visit_call
def
function
def visit_call(self, node: nodes.Call) -> None: self._check_consider_iterating_dictionary(node) self._check_use_maxsplit_arg(node) def _check_consider_iterating_dictionary(self, node: nodes.Call) -> None: if not isinstance(node.func, nodes.Attribute): return if node....
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
79
_check_consider_iterating_dictionary
ref
function
self._check_consider_iterating_dictionary(node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
80
_check_use_maxsplit_arg
ref
function
self._check_use_maxsplit_arg(node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
82
_check_consider_iterating_dictionary
def
function
def _check_consider_iterating_dictionary(self, node: nodes.Call) -> None: if not isinstance(node.func, nodes.Attribute): return if node.func.attrname != "keys": return comp_ancestor = utils.get_node_first_ancestor_of_type(node, nodes.Compare) if ( ...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
87
get_node_first_ancestor_of_type
ref
function
comp_ancestor = utils.get_node_first_ancestor_of_type(node, nodes.Compare)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
95
node_ancestors
ref
function
and (comparator in node.node_ancestors() or comparator is node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
98
safe_infer
ref
function
inferred = utils.safe_infer(node.func)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
103
add_message
ref
function
self.add_message("consider-iterating-dictionary", node=node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
105
_check_use_maxsplit_arg
def
function
def _check_use_maxsplit_arg(self, node: nodes.Call) -> None: """Add message when accessing first or last elements of a str.split() or str.rsplit().""" # Check if call is split() or rsplit() if not ( isinstance(node.func, nodes.Attribute) and node.func.attrname in {"s...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
112
safe_infer
ref
function
and isinstance(utils.safe_infer(node.func), astroid.BoundMethod)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
117
get_argument_from_call
ref
function
sep = utils.get_argument_from_call(node, 0, "sep")
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
123
get_argument_from_call
ref
function
utils.get_argument_from_call(node, 1, "maxsplit")
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
130
get_subscript_const_value
ref
function
subscript_value = utils.get_subscript_const_value(node.parent).value
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
137
scope
ref
function
scope = node.scope()
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
138
nodes_of_class
ref
class
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
139
parent_of
ref
function
if not loop_node.parent_of(node):
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
143
nodes_of_class
ref
class
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
146
nodes_of_class
ref
class
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
156
as_string
ref
function
node.func.as_string().rsplit(fn_name, maxsplit=1)[0]
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
158
as_string
ref
function
+ f"({sep.as_string()}, maxsplit=1)[{subscript_value}]"
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
160
add_message
ref
function
self.add_message("use-maxsplit-arg", node=node, args=(new_name,))
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
162
only_required_for_messages
ref
function
@utils.only_required_for_messages(
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
167
visit_for
def
function
def visit_for(self, node: nodes.For) -> None: self._check_consider_using_enumerate(node) self._check_consider_using_dict_items(node) self._check_use_sequence_for_iteration(node) def _check_consider_using_enumerate(self, node: nodes.For) -> None: """Emit a convention whenever ran...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
168
_check_consider_using_enumerate
ref
function
self._check_consider_using_enumerate(node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
169
_check_consider_using_dict_items
ref
function
self._check_consider_using_dict_items(node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
170
_check_use_sequence_for_iteration
ref
function
self._check_use_sequence_for_iteration(node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
172
_check_consider_using_enumerate
def
function
def _check_consider_using_enumerate(self, node: nodes.For) -> None: """Emit a convention whenever range and len are used for indexing.""" # Verify that we have a `range([start], len(...), [stop])` call and # that the object which is iterated is used as a subscript in the # body of th...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
181
_is_builtin
ref
function
if not self._is_builtin(node.iter.func, "range"):
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
197
_is_builtin
ref
function
if not self._is_builtin(second_func, "len"):
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
210
scope
ref
function
scope = node.scope()
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
223
nodes_of_class
ref
class
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
230
scope
ref
function
if subscript.value.scope() != node.scope():
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
230
scope
ref
function
if subscript.value.scope() != node.scope():
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
242
add_message
ref
function
self.add_message("consider-using-enumerate", node=node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
245
_check_consider_using_dict_items
def
function
def _check_consider_using_dict_items(self, node: nodes.For) -> None: """Add message when accessing dict values by index lookup.""" # Verify that we have a .keys() call and # that the object which is iterated is used as a subscript in the # body of the for. iterating_object_n...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
251
get_iterating_dictionary_name
ref
function
iterating_object_name = utils.get_iterating_dictionary_name(node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
260
nodes_of_class
ref
class
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
268
as_string
ref
function
or iterating_object_name != subscript.value.as_string()
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
271
lookup
ref
function
last_definition_lineno = value.lookup(value.name)[1][-1].lineno
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
288
add_message
ref
function
self.add_message("consider-using-dict-items", node=node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
291
only_required_for_messages
ref
function
@utils.only_required_for_messages(
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
295
visit_comprehension
def
function
def visit_comprehension(self, node: nodes.Comprehension) -> None: self._check_consider_using_dict_items_comprehension(node) self._check_use_sequence_for_iteration(node) def _check_consider_using_dict_items_comprehension( self, node: nodes.Comprehension ) -> None: """Add mess...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
296
_check_consider_using_dict_items_comprehension
ref
function
self._check_consider_using_dict_items_comprehension(node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
297
_check_use_sequence_for_iteration
ref
function
self._check_use_sequence_for_iteration(node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
299
_check_consider_using_dict_items_comprehension
def
function
def _check_consider_using_dict_items_comprehension( self, node: nodes.Comprehension ) -> None: """Add message when accessing dict values by index lookup.""" iterating_object_name = utils.get_iterating_dictionary_name(node) if iterating_object_name is None: return ...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
303
get_iterating_dictionary_name
ref
function
iterating_object_name = utils.get_iterating_dictionary_name(node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
307
get_children
ref
function
for child in node.parent.get_children():
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
308
nodes_of_class
ref
class
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
316
as_string
ref
function
or iterating_object_name != subscript.value.as_string()
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
320
add_message
ref
function
self.add_message("consider-using-dict-items", node=node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
323
_check_use_sequence_for_iteration
def
function
def _check_use_sequence_for_iteration( self, node: nodes.For | nodes.Comprehension ) -> None: """Check if code iterates over an in-place defined set.""" if isinstance(node.iter, nodes.Set): self.add_message("use-sequence-for-iteration", node=node.iter) @utils.only_requir...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
328
add_message
ref
function
self.add_message("use-sequence-for-iteration", node=node.iter)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
330
only_required_for_messages
ref
function
@utils.only_required_for_messages("consider-using-f-string")
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
331
visit_const
def
function
def visit_const(self, node: nodes.Const) -> None: if self._py36_plus: # f-strings require Python 3.6 if node.pytype() == "builtins.str" and not isinstance( node.parent, nodes.JoinedStr ): self._detect_replacable_format_call(node) def _...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
334
pytype
ref
function
if node.pytype() == "builtins.str" and not isinstance(
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
337
_detect_replacable_format_call
ref
function
self._detect_replacable_format_call(node)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
339
_detect_replacable_format_call
def
function
def _detect_replacable_format_call(self, node: nodes.Const) -> None: """Check whether a string is used in a call to format() or '%' and whether it can be replaced by an f-string. """ if ( isinstance(node.parent, nodes.Attribute) and node.parent.attrname == "fo...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
355
safe_infer
ref
function
inferred = utils.safe_infer(arg.value)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
362
as_string
ref
function
if "\\" in arg.as_string():
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
367
parse_format_method_string
ref
function
i[0] for i in utils.parse_format_method_string(node.value)[0]
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
374
safe_infer
ref
function
keyword = utils.safe_infer(keyword.value)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
382
add_message
ref
function
self.add_message(
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
391
as_string
ref
function
if "\\" in node.parent.right.as_string():
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
394
safe_infer
ref
function
inferred_right = utils.safe_infer(node.parent.right)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/recommendation_checker.py
pylint/checkers/refactoring/recommendation_checker.py
405
add_message
ref
function
self.add_message(
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
61
_if_statement_is_always_returning
def
class
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
65
_is_trailing_comma
def
function
def _is_trailing_comma(tokens: list[tokenize.TokenInfo], index: int) -> bool: """Check if the given token is a trailing comma. :param tokens: Sequence of modules tokens :type tokens: list[tokenize.TokenInfo] :param int index: Index of token under check in tokens :returns: _True if the token is a co...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
92
get_curline_index_start
def
function
def get_curline_index_start(): """Get the index denoting the start of the current line.""" for subindex, token in enumerate(reversed(tokens[:index])): # See Lib/tokenize.py and Lib/token.py in cpython for more info if token.type == tokenize.NEWLINE: return ind...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
100
get_curline_index_start
ref
function
curline_start = get_curline_index_start()
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
108
_is_inside_context_manager
def
function
def _is_inside_context_manager(node: nodes.Call) -> bool: frame = node.frame(future=_True) if not isinstance( frame, (nodes.FunctionDef, astroid.BoundMethod, astroid.UnboundMethod) ): return _False return frame.name == "__enter__" or utils.decorated_with( frame, "contextlib.conte...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
109
frame
ref
function
frame = node.frame(future=True)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
114
decorated_with
ref
function
return frame.name == "__enter__" or utils.decorated_with(
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
119
_is_a_return_statement
def
function
def _is_a_return_statement(node: nodes.Call) -> bool: frame = node.frame(future=_True) for parent in node.node_ancestors(): if parent is frame: break if isinstance(parent, nodes.Return): return _True return _False
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
120
frame
ref
function
frame = node.frame(future=True)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
121
node_ancestors
ref
function
for parent in node.node_ancestors():
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
129
_is_part_of_with_items
def
function
def _is_part_of_with_items(node: nodes.Call) -> bool: """Checks if one of the node's parents is a ``nodes.With`` node and that the node itself is located somewhere under its ``items``. """ frame = node.frame(future=_True) current = node while current != frame: if isinstance(current, node...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
133
frame
ref
function
frame = node.frame(future=True)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
144
_will_be_released_automatically
def
function
def _will_be_released_automatically(node: nodes.Call) -> bool: """Checks if a call that could be used in a ``with`` statement is used in an alternative construct which would ensure that its __exit__ method is called. """ callables_taking_care_of_exit = frozenset( ( "contextlib._BaseE...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
156
safe_infer
ref
function
func = utils.safe_infer(node.parent.func)
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
159
qname
ref
function
return func.qname() in callables_taking_care_of_exit
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
162
ConsiderUsingWithStack
def
class
__iter__ get_stack_for_frame clear_all
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
174
get_stack_for_frame
def
function
def get_stack_for_frame( self, frame: nodes.FunctionDef | nodes.ClassDef | nodes.Module ): """Get the stack corresponding to the scope of the given frame.""" if isinstance(frame, nodes.FunctionDef): return self.function_scope if isinstance(frame, nodes.ClassDef): ...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
184
clear_all
def
function
def clear_all(self) -> None: """Convenience method to clear all stacks.""" for stack in self: stack.clear()
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
190
RefactoringChecker
def
class
__init__ _init open _dummy_rgx _is_bool_const _is_actual_elif _check_simplifiable_if process_tokens leave_module visit_tryexcept _check_redefined_argument_from_local visit_for visit_excepthandler visit_with _check_superfluous_else _check_superfluous_else_return _check_superfluous_else_raise _check_superfluous_else_brea...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
475
ConsiderUsingWithStack
ref
function
self._consider_using_with_stack = ConsiderUsingWithStack()
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
476
_init
ref
function
self._init()
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
479
_init
def
function
def _init(self): self._nested_blocks = [] self._elifs = [] self._nested_blocks_msg = None self._reported_swap_nodes = set() self._can_simplify_bool_op = _False self._consider_using_with_stack.clear_all() def open(self): # do this in open since config not ...
playground/2af25c45-9624-42e9-b1b3-5ecb19e13cc8/pylint/pylint/checkers/refactoring/refactoring_checker.py
pylint/checkers/refactoring/refactoring_checker.py
485
clear_all
ref
function
self._consider_using_with_stack.clear_all()