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/typing.py | pylint/typing.py | -1 | mod | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | str | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | ex | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | Union | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | ImportError | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | SyntaxError | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | MessageLocationTuple | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | NamedTuple | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | abspath | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | str | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | path | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | str | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | module | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | str | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | obj | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | str | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | line | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | int | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | column | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | int | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | end_line | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | Optional | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | int | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | end_column | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | Optional | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | int | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | ManagedMessage | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | NamedTuple | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | name | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | Optional | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | str | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | msgid | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | str | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | symbol | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | str | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | line | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | Optional | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | int | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | is_disabled | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | bool | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | MessageTypesFullName | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/typing.py | pylint/typing.py | -1 | Literal | ref | function | none |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/ast_walker.py | pylint/utils/ast_walker.py | 9 | ASTWalker | def | class | __init__ _is_method_enabled add_checker walk |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/ast_walker.py | pylint/utils/ast_walker.py | 18 | _is_method_enabled | def | function | def _is_method_enabled(self, method):
if not hasattr(method, "checks_msgs"):
return _True
return any(self.linter.is_message_enabled(m) for m in method.checks_msgs)
def add_checker(self, checker):
"""Walk to the checker's dir and collect visit and leave methods."""
vcids = set()
lcids = set()
visits = self.visit_events
leaves = self.leave_events
for member in dir(checker):
cid = member[6:]
if cid == "default":
continue
if member.startswith("visit_"):
v_meth = getattr(checker, member)
# don't use visit_methods with no activated message:
if self._is_method_enabled(v_meth):
visits[cid].append(v_meth)
vcids.add(cid)
elif member.startswith("leave_"):
l_meth = getattr(checker, member)
# don't use leave_methods with no activated message:
if self._is_method_enabled(l_meth):
leaves[cid].append(l_meth)
lcids.add(cid)
visit_default = getattr(checker, "visit_default", None)
if visit_default:
for cls in nodes.ALL_NODE_CLASSES:
cid = cls.__name__.lower()
if cid not in vcids:
visits[cid].append(visit_default)
# For now, we have no "leave_default" method in Pylint
def walk(self, astroid):
"""Call visit events of astroid checkers for the given node, recurse on
its children, then leave events.
"""
cid = astroid.__class__.__name__.lower()
# Detect if the node is a new name for a deprecated alias.
# In this case, favour the methods for the deprecated
# alias if any, in order to maintain backwards
# compatibility.
visit_events = self.visit_events.get(cid, ())
leave_events = self.leave_events.get(cid, ())
try:
if astroid.is_statement:
self.nbstatements += 1
# generate events for this node on each checker
for callback in visit_events or ():
callback(astroid)
# recurse on children
for child in astroid.get_children():
self.walk(child)
for callback in leave_events or ():
callback(astroid)
except Exception:
if self.exception_msg is _False:
file = getattr(astroid.root(), "file", None)
print(f"Exception on node {repr(astroid)} in file '{file}'")
traceback.print_exc()
self.exception_msg = _True
raise
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/ast_walker.py | pylint/utils/ast_walker.py | 21 | is_message_enabled | ref | function | return any(self.linter.is_message_enabled(m) for m in method.checks_msgs)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/ast_walker.py | pylint/utils/ast_walker.py | 23 | add_checker | def | function | def add_checker(self, checker):
"""Walk to the checker's dir and collect visit and leave methods."""
vcids = set()
lcids = set()
visits = self.visit_events
leaves = self.leave_events
for member in dir(checker):
cid = member[6:]
if cid == "default":
continue
if member.startswith("visit_"):
v_meth = getattr(checker, member)
# don't use visit_methods with no activated message:
if self._is_method_enabled(v_meth):
visits[cid].append(v_meth)
vcids.add(cid)
elif member.startswith("leave_"):
l_meth = getattr(checker, member)
# don't use leave_methods with no activated message:
if self._is_method_enabled(l_meth):
leaves[cid].append(l_meth)
lcids.add(cid)
visit_default = getattr(checker, "visit_default", None)
if visit_default:
for cls in nodes.ALL_NODE_CLASSES:
cid = cls.__name__.lower()
if cid not in vcids:
visits[cid].append(visit_default)
# For now, we have no "leave_default" method in Pylint
def walk(self, astroid):
"""Call visit events of astroid checkers for the given node, recurse on
its children, then leave events.
"""
cid = astroid.__class__.__name__.lower()
# Detect if the node is a new name for a deprecated alias.
# In this case, favour the methods for the deprecated
# alias if any, in order to maintain backwards
# compatibility.
visit_events = self.visit_events.get(cid, ())
leave_events = self.leave_events.get(cid, ())
try:
if astroid.is_statement:
self.nbstatements += 1
# generate events for this node on each checker
for callback in visit_events or ():
callback(astroid)
# recurse on children
for child in astroid.get_children():
self.walk(child)
for callback in leave_events or ():
callback(astroid)
except Exception:
if self.exception_msg is _False:
file = getattr(astroid.root(), "file", None)
print(f"Exception on node {repr(astroid)} in file '{file}'")
traceback.print_exc()
self.exception_msg = _True
raise
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/ast_walker.py | pylint/utils/ast_walker.py | 36 | _is_method_enabled | ref | function | if self._is_method_enabled(v_meth):
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/ast_walker.py | pylint/utils/ast_walker.py | 42 | _is_method_enabled | ref | function | if self._is_method_enabled(l_meth):
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/ast_walker.py | pylint/utils/ast_walker.py | 53 | walk | def | function | def walk(self, astroid):
"""Call visit events of astroid checkers for the given node, recurse on
its children, then leave events.
"""
cid = astroid.__class__.__name__.lower()
# Detect if the node is a new name for a deprecated alias.
# In this case, favour the methods for the deprecated
# alias if any, in order to maintain backwards
# compatibility.
visit_events = self.visit_events.get(cid, ())
leave_events = self.leave_events.get(cid, ())
try:
if astroid.is_statement:
self.nbstatements += 1
# generate events for this node on each checker
for callback in visit_events or ():
callback(astroid)
# recurse on children
for child in astroid.get_children():
self.walk(child)
for callback in leave_events or ():
callback(astroid)
except Exception:
if self.exception_msg is _False:
file = getattr(astroid.root(), "file", None)
print(f"Exception on node {repr(astroid)} in file '{file}'")
traceback.print_exc()
self.exception_msg = _True
raise
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/ast_walker.py | pylint/utils/ast_walker.py | 71 | callback | ref | function | callback(astroid)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/ast_walker.py | pylint/utils/ast_walker.py | 73 | get_children | ref | function | for child in astroid.get_children():
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/ast_walker.py | pylint/utils/ast_walker.py | 74 | walk | ref | function | self.walk(child)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/ast_walker.py | pylint/utils/ast_walker.py | 76 | callback | ref | function | callback(astroid)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/ast_walker.py | pylint/utils/ast_walker.py | 79 | root | ref | function | file = getattr(astroid.root(), "file", None)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/docs.py | pylint/utils/docs.py | 14 | _get_checkers_infos | def | function | def _get_checkers_infos(linter: "PyLinter") -> Dict[str, Dict]:
"""Get info from a checker and handle KeyError."""
by_checker: Dict[str, Dict] = {}
for checker in linter.get_checkers():
name = checker.name
if name != "master":
try:
by_checker[name]["checker"] = checker
by_checker[name]["options"] += checker.options_and_values()
by_checker[name]["msgs"].update(checker.msgs)
by_checker[name]["reports"] += checker.reports
except KeyError:
by_checker[name] = {
"checker": checker,
"options": list(checker.options_and_values()),
"msgs": dict(checker.msgs),
"reports": list(checker.reports),
}
return by_checker
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/docs.py | pylint/utils/docs.py | 17 | get_checkers | ref | function | for checker in linter.get_checkers():
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/docs.py | pylint/utils/docs.py | 22 | options_and_values | ref | function | by_checker[name]["options"] += checker.options_and_values()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/docs.py | pylint/utils/docs.py | 28 | options_and_values | ref | function | "options": list(checker.options_and_values()),
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/docs.py | pylint/utils/docs.py | 35 | _get_checkers_documentation | def | function | def _get_checkers_documentation(linter: "PyLinter") -> str:
"""Get documentation for individual checkers."""
result = get_rst_title("Pylint global options and switches", "-")
result += """
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/docs.py | pylint/utils/docs.py | 37 | get_rst_title | ref | function | result = get_rst_title("Pylint global options and switches", "-")
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/docs.py | pylint/utils/docs.py | 42 | get_checkers | ref | function | for checker in linter.get_checkers():
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/docs.py | pylint/utils/docs.py | 46 | options_by_section | ref | function | for section, options in checker.options_by_section():
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/docs.py | pylint/utils/docs.py | 51 | get_rst_title | ref | function | result += get_rst_title(title, "~")
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/docs.py | pylint/utils/docs.py | 52 | get_rst_section | ref | function | result += f"{get_rst_section(None, options)}\n"
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/docs.py | pylint/utils/docs.py | 53 | get_rst_title | ref | function | result += get_rst_title("Pylint checkers' options and switches", "-")
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/docs.py | pylint/utils/docs.py | 65 | _get_checkers_infos | ref | function | by_checker = _get_checkers_infos(linter)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/docs.py | pylint/utils/docs.py | 70 | get_full_documentation | ref | function | result += checker.get_full_documentation(**information)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/docs.py | pylint/utils/docs.py | 74 | print_full_documentation | def | function | def print_full_documentation(linter: "PyLinter", stream: TextIO = sys.stdout) -> None:
"""Output a full documentation in ReST format."""
print(_get_checkers_documentation(linter)[:-1], file=stream)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/docs.py | pylint/utils/docs.py | 76 | _get_checkers_documentation | ref | function | print(_get_checkers_documentation(linter)[:-1], file=stream)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/file_state.py | pylint/utils/file_state.py | 32 | FileState | def | class | __init__ collect_block_lines _collect_block_lines set_msg_status handle_ignored_message iter_spurious_suppression_messages get_effective_max_line_number |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/file_state.py | pylint/utils/file_state.py | 45 | collect_block_lines | def | function | def collect_block_lines(
self, msgs_store: "MessageDefinitionStore", module_node: nodes.Module
) -> None:
"""Walk the AST to collect block level options line numbers."""
for msg, lines in self._module_msgs_state.items():
self._raw_module_msgs_state[msg] = lines.copy()
orig_state = self._module_msgs_state.copy()
self._module_msgs_state = {}
self._suppression_mapping = {}
self._effective_max_line_number = module_node.tolineno
self._collect_block_lines(msgs_store, module_node, orig_state)
def _collect_block_lines(
self,
msgs_store: "MessageDefinitionStore",
node: nodes.NodeNG,
msg_state: MessageStateDict,
) -> None:
"""Recursively walk (depth first) AST to collect block level options
line numbers.
"""
for child in node.get_children():
self._collect_block_lines(msgs_store, child, msg_state)
first = node.fromlineno
last = node.tolineno
# first child line number used to distinguish between disable
# which are the first child of scoped node with those defined later.
# For instance in the code below:
#
# 1. def meth8(self):
# 2. """test late disabling"""
# 3. pylint: disable=not-callable, useless-suppression
# 4. print(self.blip)
# 5. pylint: disable=no-member, useless-suppression
# 6. print(self.bla)
#
# E1102 should be disabled from line 1 to 6 while E1101 from line 5 to 6
#
# this is necessary to disable locally messages applying to class /
# function using their fromlineno
if (
isinstance(node, (nodes.Module, nodes.ClassDef, nodes.FunctionDef))
and node.body
):
firstchildlineno = node.body[0].fromlineno
else:
firstchildlineno = last
for msgid, lines in msg_state.items():
for lineno, state in list(lines.items()):
original_lineno = lineno
if first > lineno or last < lineno:
continue
# Set state for all lines for this block, if the
# warning is applied to nodes.
message_definitions = msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
if message_definition.scope == WarningScope.NODE:
if lineno > firstchildlineno:
state = _True
first_, last_ = node.block_range(lineno)
else:
first_ = lineno
last_ = last
for line in range(first_, last_ + 1):
# do not override existing entries
if line in self._module_msgs_state.get(msgid, ()):
continue
if line in lines: # state change in the same block
state = lines[line]
original_lineno = line
if not state:
self._suppression_mapping[(msgid, line)] = original_lineno
try:
self._module_msgs_state[msgid][line] = state
except KeyError:
self._module_msgs_state[msgid] = {line: state}
del lines[lineno]
def set_msg_status(self, msg: "MessageDefinition", line: int, status: bool) -> None:
"""Set status (enabled/disable) for a given message at a given line."""
assert line > 0
try:
self._module_msgs_state[msg.msgid][line] = status
except KeyError:
self._module_msgs_state[msg.msgid] = {line: status}
def handle_ignored_message(
self, state_scope: Optional[Literal[0, 1, 2]], msgid: str, line: Optional[int]
) -> None:
"""Report an ignored message.
state_scope is either MSG_STATE_SCOPE_MODULE or MSG_STATE_SCOPE_CONFIG,
depending on whether the message was disabled locally in the module,
or globally.
"""
if state_scope == MSG_STATE_SCOPE_MODULE:
assert isinstance(line, int) # should always be int inside module scope
try:
orig_line = self._suppression_mapping[(msgid, line)]
self._ignored_msgs[(msgid, orig_line)].add(line)
except KeyError:
pass
def iter_spurious_suppression_messages(
self,
msgs_store: "MessageDefinitionStore",
) -> Iterator[
Tuple[
Literal["useless-suppression", "suppressed-message"],
int,
Union[Tuple[str], Tuple[str, int]],
]
]:
for warning, lines in self._raw_module_msgs_state.items():
for line, enable in lines.items():
if not enable and (warning, line) not in self._ignored_msgs:
# ignore cyclic-import check which can show false positives
# here due to incomplete context
if warning != "R0401":
yield "useless-suppression", line, (
msgs_store.get_msg_display_string(warning),
)
# don't use iteritems here, _ignored_msgs may be modified by add_message
for (warning, from_), ignored_lines in list(self._ignored_msgs.items()):
for line in ignored_lines:
yield "suppressed-message", line, (
msgs_store.get_msg_display_string(warning),
from_,
)
def get_effective_max_line_number(self) -> Optional[int]:
return self._effective_max_line_number
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/file_state.py | pylint/utils/file_state.py | 55 | _collect_block_lines | ref | function | self._collect_block_lines(msgs_store, module_node, orig_state)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/file_state.py | pylint/utils/file_state.py | 57 | _collect_block_lines | def | function | def _collect_block_lines(
self,
msgs_store: "MessageDefinitionStore",
node: nodes.NodeNG,
msg_state: MessageStateDict,
) -> None:
"""Recursively walk (depth first) AST to collect block level options
line numbers.
"""
for child in node.get_children():
self._collect_block_lines(msgs_store, child, msg_state)
first = node.fromlineno
last = node.tolineno
# first child line number used to distinguish between disable
# which are the first child of scoped node with those defined later.
# For instance in the code below:
#
# 1. def meth8(self):
# 2. """test late disabling"""
# 3. pylint: disable=not-callable, useless-suppression
# 4. print(self.blip)
# 5. pylint: disable=no-member, useless-suppression
# 6. print(self.bla)
#
# E1102 should be disabled from line 1 to 6 while E1101 from line 5 to 6
#
# this is necessary to disable locally messages applying to class /
# function using their fromlineno
if (
isinstance(node, (nodes.Module, nodes.ClassDef, nodes.FunctionDef))
and node.body
):
firstchildlineno = node.body[0].fromlineno
else:
firstchildlineno = last
for msgid, lines in msg_state.items():
for lineno, state in list(lines.items()):
original_lineno = lineno
if first > lineno or last < lineno:
continue
# Set state for all lines for this block, if the
# warning is applied to nodes.
message_definitions = msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
if message_definition.scope == WarningScope.NODE:
if lineno > firstchildlineno:
state = _True
first_, last_ = node.block_range(lineno)
else:
first_ = lineno
last_ = last
for line in range(first_, last_ + 1):
# do not override existing entries
if line in self._module_msgs_state.get(msgid, ()):
continue
if line in lines: # state change in the same block
state = lines[line]
original_lineno = line
if not state:
self._suppression_mapping[(msgid, line)] = original_lineno
try:
self._module_msgs_state[msgid][line] = state
except KeyError:
self._module_msgs_state[msgid] = {line: state}
del lines[lineno]
def set_msg_status(self, msg: "MessageDefinition", line: int, status: bool) -> None:
"""Set status (enabled/disable) for a given message at a given line."""
assert line > 0
try:
self._module_msgs_state[msg.msgid][line] = status
except KeyError:
self._module_msgs_state[msg.msgid] = {line: status}
def handle_ignored_message(
self, state_scope: Optional[Literal[0, 1, 2]], msgid: str, line: Optional[int]
) -> None:
"""Report an ignored message.
state_scope is either MSG_STATE_SCOPE_MODULE or MSG_STATE_SCOPE_CONFIG,
depending on whether the message was disabled locally in the module,
or globally.
"""
if state_scope == MSG_STATE_SCOPE_MODULE:
assert isinstance(line, int) # should always be int inside module scope
try:
orig_line = self._suppression_mapping[(msgid, line)]
self._ignored_msgs[(msgid, orig_line)].add(line)
except KeyError:
pass
def iter_spurious_suppression_messages(
self,
msgs_store: "MessageDefinitionStore",
) -> Iterator[
Tuple[
Literal["useless-suppression", "suppressed-message"],
int,
Union[Tuple[str], Tuple[str, int]],
]
]:
for warning, lines in self._raw_module_msgs_state.items():
for line, enable in lines.items():
if not enable and (warning, line) not in self._ignored_msgs:
# ignore cyclic-import check which can show false positives
# here due to incomplete context
if warning != "R0401":
yield "useless-suppression", line, (
msgs_store.get_msg_display_string(warning),
)
# don't use iteritems here, _ignored_msgs may be modified by add_message
for (warning, from_), ignored_lines in list(self._ignored_msgs.items()):
for line in ignored_lines:
yield "suppressed-message", line, (
msgs_store.get_msg_display_string(warning),
from_,
)
def get_effective_max_line_number(self) -> Optional[int]:
return self._effective_max_line_number
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/file_state.py | pylint/utils/file_state.py | 66 | get_children | ref | function | for child in node.get_children():
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/file_state.py | pylint/utils/file_state.py | 67 | _collect_block_lines | ref | function | self._collect_block_lines(msgs_store, child, msg_state)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/file_state.py | pylint/utils/file_state.py | 99 | get_message_definitions | ref | function | message_definitions = msgs_store.get_message_definitions(msgid)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/file_state.py | pylint/utils/file_state.py | 104 | block_range | ref | function | first_, last_ = node.block_range(lineno)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/file_state.py | pylint/utils/file_state.py | 123 | set_msg_status | def | function | def set_msg_status(self, msg: "MessageDefinition", line: int, status: bool) -> None:
"""Set status (enabled/disable) for a given message at a given line."""
assert line > 0
try:
self._module_msgs_state[msg.msgid][line] = status
except KeyError:
self._module_msgs_state[msg.msgid] = {line: status}
def handle_ignored_message(
self, state_scope: Optional[Literal[0, 1, 2]], msgid: str, line: Optional[int]
) -> None:
"""Report an ignored message.
state_scope is either MSG_STATE_SCOPE_MODULE or MSG_STATE_SCOPE_CONFIG,
depending on whether the message was disabled locally in the module,
or globally.
"""
if state_scope == MSG_STATE_SCOPE_MODULE:
assert isinstance(line, int) # should always be int inside module scope
try:
orig_line = self._suppression_mapping[(msgid, line)]
self._ignored_msgs[(msgid, orig_line)].add(line)
except KeyError:
pass
def iter_spurious_suppression_messages(
self,
msgs_store: "MessageDefinitionStore",
) -> Iterator[
Tuple[
Literal["useless-suppression", "suppressed-message"],
int,
Union[Tuple[str], Tuple[str, int]],
]
]:
for warning, lines in self._raw_module_msgs_state.items():
for line, enable in lines.items():
if not enable and (warning, line) not in self._ignored_msgs:
# ignore cyclic-import check which can show false positives
# here due to incomplete context
if warning != "R0401":
yield "useless-suppression", line, (
msgs_store.get_msg_display_string(warning),
)
# don't use iteritems here, _ignored_msgs may be modified by add_message
for (warning, from_), ignored_lines in list(self._ignored_msgs.items()):
for line in ignored_lines:
yield "suppressed-message", line, (
msgs_store.get_msg_display_string(warning),
from_,
)
def get_effective_max_line_number(self) -> Optional[int]:
return self._effective_max_line_number
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/file_state.py | pylint/utils/file_state.py | 131 | handle_ignored_message | def | function | def handle_ignored_message(
self, state_scope: Optional[Literal[0, 1, 2]], msgid: str, line: Optional[int]
) -> None:
"""Report an ignored message.
state_scope is either MSG_STATE_SCOPE_MODULE or MSG_STATE_SCOPE_CONFIG,
depending on whether the message was disabled locally in the module,
or globally.
"""
if state_scope == MSG_STATE_SCOPE_MODULE:
assert isinstance(line, int) # should always be int inside module scope
try:
orig_line = self._suppression_mapping[(msgid, line)]
self._ignored_msgs[(msgid, orig_line)].add(line)
except KeyError:
pass
def iter_spurious_suppression_messages(
self,
msgs_store: "MessageDefinitionStore",
) -> Iterator[
Tuple[
Literal["useless-suppression", "suppressed-message"],
int,
Union[Tuple[str], Tuple[str, int]],
]
]:
for warning, lines in self._raw_module_msgs_state.items():
for line, enable in lines.items():
if not enable and (warning, line) not in self._ignored_msgs:
# ignore cyclic-import check which can show false positives
# here due to incomplete context
if warning != "R0401":
yield "useless-suppression", line, (
msgs_store.get_msg_display_string(warning),
)
# don't use iteritems here, _ignored_msgs may be modified by add_message
for (warning, from_), ignored_lines in list(self._ignored_msgs.items()):
for line in ignored_lines:
yield "suppressed-message", line, (
msgs_store.get_msg_display_string(warning),
from_,
)
def get_effective_max_line_number(self) -> Optional[int]:
return self._effective_max_line_number
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/file_state.py | pylint/utils/file_state.py | 149 | iter_spurious_suppression_messages | def | function | def iter_spurious_suppression_messages(
self,
msgs_store: "MessageDefinitionStore",
) -> Iterator[
Tuple[
Literal["useless-suppression", "suppressed-message"],
int,
Union[Tuple[str], Tuple[str, int]],
]
]:
for warning, lines in self._raw_module_msgs_state.items():
for line, enable in lines.items():
if not enable and (warning, line) not in self._ignored_msgs:
# ignore cyclic-import check which can show false positives
# here due to incomplete context
if warning != "R0401":
yield "useless-suppression", line, (
msgs_store.get_msg_display_string(warning),
)
# don't use iteritems here, _ignored_msgs may be modified by add_message
for (warning, from_), ignored_lines in list(self._ignored_msgs.items()):
for line in ignored_lines:
yield "suppressed-message", line, (
msgs_store.get_msg_display_string(warning),
from_,
)
def get_effective_max_line_number(self) -> Optional[int]:
return self._effective_max_line_number
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/file_state.py | pylint/utils/file_state.py | 166 | get_msg_display_string | ref | function | msgs_store.get_msg_display_string(warning),
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/file_state.py | pylint/utils/file_state.py | 172 | get_msg_display_string | ref | function | msgs_store.get_msg_display_string(warning),
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/file_state.py | pylint/utils/file_state.py | 176 | get_effective_max_line_number | def | function | def get_effective_max_line_number(self) -> Optional[int]:
return self._effective_max_line_number
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 14 | BadNames | def | class | |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 30 | CodeTypeCount | def | class | |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 40 | DuplicatedLines | def | class | |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 47 | NodeCount | def | class | |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 56 | UndocumentedNodes | def | class | |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 65 | ModuleStats | def | class | |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 78 | LinterStats | def | class | __init__ __str__ init_single_module get_bad_names increase_bad_name reset_bad_names get_code_count reset_code_count reset_duplicated_lines get_node_count reset_node_count get_undocumented reset_undocumented get_global_message_count get_module_message_count increase_single_message_count increase_single_module_message_count reset_message_count |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 92 | BadNames | ref | function | self.bad_names = bad_names or BadNames(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 107 | CodeTypeCount | ref | function | self.code_type_count = code_type_count or CodeTypeCount(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 112 | DuplicatedLines | ref | function | self.duplicated_lines = duplicated_lines or DuplicatedLines(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 115 | NodeCount | ref | function | self.node_count = node_count or NodeCount(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 118 | UndocumentedNodes | ref | function | self.undocumented = undocumented or UndocumentedNodes(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 153 | init_single_module | def | function | def init_single_module(self, module_name: str) -> None:
"""Use through PyLinter.set_current_module so PyLinter.current_name is consistent."""
self.by_module[module_name] = ModuleStats(
convention=0, error=0, fatal=0, info=0, refactor=0, statement=0, warning=0
)
def get_bad_names(
self,
node_name: Literal[
"argument",
"attr",
"class",
"class_attribute",
"class_const",
"const",
"inlinevar",
"function",
"method",
"module",
"variable",
],
) -> int:
"""Get a bad names node count."""
if node_name == "class":
return self.bad_names.get("klass", 0)
return self.bad_names.get(node_name, 0)
def increase_bad_name(self, node_name: str, increase: int) -> None:
"""Increase a bad names node count."""
if node_name not in {
"argument",
"attr",
"class",
"class_attribute",
"class_const",
"const",
"inlinevar",
"function",
"method",
"module",
"variable",
}:
raise ValueError("Node type not part of the bad_names stat")
node_name = cast(
Literal[
"argument",
"attr",
"class",
"class_attribute",
"class_const",
"const",
"inlinevar",
"function",
"method",
"module",
"variable",
],
node_name,
)
if node_name == "class":
self.bad_names["klass"] += increase
else:
self.bad_names[node_name] += increase
def reset_bad_names(self) -> None:
"""Resets the bad_names attribute."""
self.bad_names = BadNames(
argument=0,
attr=0,
klass=0,
class_attribute=0,
class_const=0,
const=0,
inlinevar=0,
function=0,
method=0,
module=0,
variable=0,
)
def get_code_count(
self, type_name: Literal["code", "comment", "docstring", "empty", "total"]
) -> int:
"""Get a code type count."""
return self.code_type_count.get(type_name, 0)
def reset_code_count(self) -> None:
"""Resets the code_type_count attribute."""
self.code_type_count = CodeTypeCount(
code=0, comment=0, docstring=0, empty=0, total=0
)
def reset_duplicated_lines(self) -> None:
"""Resets the duplicated_lines attribute."""
self.duplicated_lines = DuplicatedLines(
nb_duplicated_lines=0, percent_duplicated_lines=0.0
)
def get_node_count(
self, node_name: Literal["function", "class", "method", "module"]
) -> int:
"""Get a node count while handling some extra conditions."""
if node_name == "class":
return self.node_count.get("klass", 0)
return self.node_count.get(node_name, 0)
def reset_node_count(self) -> None:
"""Resets the node count attribute."""
self.node_count = NodeCount(function=0, klass=0, method=0, module=0)
def get_undocumented(
self, node_name: Literal["function", "class", "method", "module"]
) -> float:
"""Get a undocumented node count."""
if node_name == "class":
return self.undocumented["klass"]
return self.undocumented[node_name]
def reset_undocumented(self) -> None:
"""Resets the undocumented attribute."""
self.undocumented = UndocumentedNodes(function=0, klass=0, method=0, module=0)
def get_global_message_count(self, type_name: str) -> int:
"""Get a global message count."""
return getattr(self, type_name, 0)
def get_module_message_count(self, modname: str, type_name: str) -> int:
"""Get a module message count."""
return getattr(self.by_module[modname], type_name, 0)
def increase_single_message_count(self, type_name: str, increase: int) -> None:
"""Increase the message type count of an individual message type."""
setattr(self, type_name, getattr(self, type_name) + increase)
def increase_single_module_message_count(
self, modname: str, type_name: MessageTypesFullName, increase: int
) -> None:
"""Increase the message type count of an individual message type of a module."""
self.by_module[modname][type_name] += increase
def reset_message_count(self) -> None:
"""Resets the message type count of the stats object."""
self.convention = 0
self.error = 0
self.fatal = 0
self.info = 0
self.refactor = 0
self.warning = 0
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 155 | ModuleStats | ref | function | self.by_module[module_name] = ModuleStats(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 159 | get_bad_names | def | function | def get_bad_names(
self,
node_name: Literal[
"argument",
"attr",
"class",
"class_attribute",
"class_const",
"const",
"inlinevar",
"function",
"method",
"module",
"variable",
],
) -> int:
"""Get a bad names node count."""
if node_name == "class":
return self.bad_names.get("klass", 0)
return self.bad_names.get(node_name, 0)
def increase_bad_name(self, node_name: str, increase: int) -> None:
"""Increase a bad names node count."""
if node_name not in {
"argument",
"attr",
"class",
"class_attribute",
"class_const",
"const",
"inlinevar",
"function",
"method",
"module",
"variable",
}:
raise ValueError("Node type not part of the bad_names stat")
node_name = cast(
Literal[
"argument",
"attr",
"class",
"class_attribute",
"class_const",
"const",
"inlinevar",
"function",
"method",
"module",
"variable",
],
node_name,
)
if node_name == "class":
self.bad_names["klass"] += increase
else:
self.bad_names[node_name] += increase
def reset_bad_names(self) -> None:
"""Resets the bad_names attribute."""
self.bad_names = BadNames(
argument=0,
attr=0,
klass=0,
class_attribute=0,
class_const=0,
const=0,
inlinevar=0,
function=0,
method=0,
module=0,
variable=0,
)
def get_code_count(
self, type_name: Literal["code", "comment", "docstring", "empty", "total"]
) -> int:
"""Get a code type count."""
return self.code_type_count.get(type_name, 0)
def reset_code_count(self) -> None:
"""Resets the code_type_count attribute."""
self.code_type_count = CodeTypeCount(
code=0, comment=0, docstring=0, empty=0, total=0
)
def reset_duplicated_lines(self) -> None:
"""Resets the duplicated_lines attribute."""
self.duplicated_lines = DuplicatedLines(
nb_duplicated_lines=0, percent_duplicated_lines=0.0
)
def get_node_count(
self, node_name: Literal["function", "class", "method", "module"]
) -> int:
"""Get a node count while handling some extra conditions."""
if node_name == "class":
return self.node_count.get("klass", 0)
return self.node_count.get(node_name, 0)
def reset_node_count(self) -> None:
"""Resets the node count attribute."""
self.node_count = NodeCount(function=0, klass=0, method=0, module=0)
def get_undocumented(
self, node_name: Literal["function", "class", "method", "module"]
) -> float:
"""Get a undocumented node count."""
if node_name == "class":
return self.undocumented["klass"]
return self.undocumented[node_name]
def reset_undocumented(self) -> None:
"""Resets the undocumented attribute."""
self.undocumented = UndocumentedNodes(function=0, klass=0, method=0, module=0)
def get_global_message_count(self, type_name: str) -> int:
"""Get a global message count."""
return getattr(self, type_name, 0)
def get_module_message_count(self, modname: str, type_name: str) -> int:
"""Get a module message count."""
return getattr(self.by_module[modname], type_name, 0)
def increase_single_message_count(self, type_name: str, increase: int) -> None:
"""Increase the message type count of an individual message type."""
setattr(self, type_name, getattr(self, type_name) + increase)
def increase_single_module_message_count(
self, modname: str, type_name: MessageTypesFullName, increase: int
) -> None:
"""Increase the message type count of an individual message type of a module."""
self.by_module[modname][type_name] += increase
def reset_message_count(self) -> None:
"""Resets the message type count of the stats object."""
self.convention = 0
self.error = 0
self.fatal = 0
self.info = 0
self.refactor = 0
self.warning = 0
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 180 | increase_bad_name | def | function | def increase_bad_name(self, node_name: str, increase: int) -> None:
"""Increase a bad names node count."""
if node_name not in {
"argument",
"attr",
"class",
"class_attribute",
"class_const",
"const",
"inlinevar",
"function",
"method",
"module",
"variable",
}:
raise ValueError("Node type not part of the bad_names stat")
node_name = cast(
Literal[
"argument",
"attr",
"class",
"class_attribute",
"class_const",
"const",
"inlinevar",
"function",
"method",
"module",
"variable",
],
node_name,
)
if node_name == "class":
self.bad_names["klass"] += increase
else:
self.bad_names[node_name] += increase
def reset_bad_names(self) -> None:
"""Resets the bad_names attribute."""
self.bad_names = BadNames(
argument=0,
attr=0,
klass=0,
class_attribute=0,
class_const=0,
const=0,
inlinevar=0,
function=0,
method=0,
module=0,
variable=0,
)
def get_code_count(
self, type_name: Literal["code", "comment", "docstring", "empty", "total"]
) -> int:
"""Get a code type count."""
return self.code_type_count.get(type_name, 0)
def reset_code_count(self) -> None:
"""Resets the code_type_count attribute."""
self.code_type_count = CodeTypeCount(
code=0, comment=0, docstring=0, empty=0, total=0
)
def reset_duplicated_lines(self) -> None:
"""Resets the duplicated_lines attribute."""
self.duplicated_lines = DuplicatedLines(
nb_duplicated_lines=0, percent_duplicated_lines=0.0
)
def get_node_count(
self, node_name: Literal["function", "class", "method", "module"]
) -> int:
"""Get a node count while handling some extra conditions."""
if node_name == "class":
return self.node_count.get("klass", 0)
return self.node_count.get(node_name, 0)
def reset_node_count(self) -> None:
"""Resets the node count attribute."""
self.node_count = NodeCount(function=0, klass=0, method=0, module=0)
def get_undocumented(
self, node_name: Literal["function", "class", "method", "module"]
) -> float:
"""Get a undocumented node count."""
if node_name == "class":
return self.undocumented["klass"]
return self.undocumented[node_name]
def reset_undocumented(self) -> None:
"""Resets the undocumented attribute."""
self.undocumented = UndocumentedNodes(function=0, klass=0, method=0, module=0)
def get_global_message_count(self, type_name: str) -> int:
"""Get a global message count."""
return getattr(self, type_name, 0)
def get_module_message_count(self, modname: str, type_name: str) -> int:
"""Get a module message count."""
return getattr(self.by_module[modname], type_name, 0)
def increase_single_message_count(self, type_name: str, increase: int) -> None:
"""Increase the message type count of an individual message type."""
setattr(self, type_name, getattr(self, type_name) + increase)
def increase_single_module_message_count(
self, modname: str, type_name: MessageTypesFullName, increase: int
) -> None:
"""Increase the message type count of an individual message type of a module."""
self.by_module[modname][type_name] += increase
def reset_message_count(self) -> None:
"""Resets the message type count of the stats object."""
self.convention = 0
self.error = 0
self.fatal = 0
self.info = 0
self.refactor = 0
self.warning = 0
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py | pylint/utils/linterstats.py | 218 | reset_bad_names | def | function | def reset_bad_names(self) -> None:
"""Resets the bad_names attribute."""
self.bad_names = BadNames(
argument=0,
attr=0,
klass=0,
class_attribute=0,
class_const=0,
const=0,
inlinevar=0,
function=0,
method=0,
module=0,
variable=0,
)
def get_code_count(
self, type_name: Literal["code", "comment", "docstring", "empty", "total"]
) -> int:
"""Get a code type count."""
return self.code_type_count.get(type_name, 0)
def reset_code_count(self) -> None:
"""Resets the code_type_count attribute."""
self.code_type_count = CodeTypeCount(
code=0, comment=0, docstring=0, empty=0, total=0
)
def reset_duplicated_lines(self) -> None:
"""Resets the duplicated_lines attribute."""
self.duplicated_lines = DuplicatedLines(
nb_duplicated_lines=0, percent_duplicated_lines=0.0
)
def get_node_count(
self, node_name: Literal["function", "class", "method", "module"]
) -> int:
"""Get a node count while handling some extra conditions."""
if node_name == "class":
return self.node_count.get("klass", 0)
return self.node_count.get(node_name, 0)
def reset_node_count(self) -> None:
"""Resets the node count attribute."""
self.node_count = NodeCount(function=0, klass=0, method=0, module=0)
def get_undocumented(
self, node_name: Literal["function", "class", "method", "module"]
) -> float:
"""Get a undocumented node count."""
if node_name == "class":
return self.undocumented["klass"]
return self.undocumented[node_name]
def reset_undocumented(self) -> None:
"""Resets the undocumented attribute."""
self.undocumented = UndocumentedNodes(function=0, klass=0, method=0, module=0)
def get_global_message_count(self, type_name: str) -> int:
"""Get a global message count."""
return getattr(self, type_name, 0)
def get_module_message_count(self, modname: str, type_name: str) -> int:
"""Get a module message count."""
return getattr(self.by_module[modname], type_name, 0)
def increase_single_message_count(self, type_name: str, increase: int) -> None:
"""Increase the message type count of an individual message type."""
setattr(self, type_name, getattr(self, type_name) + increase)
def increase_single_module_message_count(
self, modname: str, type_name: MessageTypesFullName, increase: int
) -> None:
"""Increase the message type count of an individual message type of a module."""
self.by_module[modname][type_name] += increase
def reset_message_count(self) -> None:
"""Resets the message type count of the stats object."""
self.convention = 0
self.error = 0
self.fatal = 0
self.info = 0
self.refactor = 0
self.warning = 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.