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/lint/pylinter.py | pylint/lint/pylinter.py | 1,359 | get_global_option | ref | function | self._ignore_paths = get_global_option(self, "ignore-paths")
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,361 | generate_reports | def | function | def generate_reports(self):
"""Close the whole package /module, it's time to make reports !
if persistent run, pickle results for later comparison
"""
# Display whatever messages are left on the reporter.
self.reporter.display_messages(report_nodes.Section())
if self.file_state.base_name is not None:
# load previous results if any
previous_stats = config.load_results(self.file_state.base_name)
self.reporter.on_close(self.stats, previous_stats)
if self.config.reports:
sect = self.make_reports(self.stats, previous_stats)
else:
sect = report_nodes.Section()
if self.config.reports:
self.reporter.display_reports(sect)
score_value = self._report_evaluation()
# save results if persistent run
if self.config.persistent:
config.save_results(self.stats, self.file_state.base_name)
else:
self.reporter.on_close(self.stats, LinterStats())
score_value = None
return score_value
def _report_evaluation(self):
"""Make the global evaluation report."""
# check with at least check 1 statements (usually 0 when there is a
# syntax error preventing pylint from further processing)
note = None
previous_stats = config.load_results(self.file_state.base_name)
if self.stats.statement == 0:
return note
# get a global note for the code
evaluation = self.config.evaluation
try:
stats_dict = {
"fatal": self.stats.fatal,
"error": self.stats.error,
"warning": self.stats.warning,
"refactor": self.stats.refactor,
"convention": self.stats.convention,
"statement": self.stats.statement,
"info": self.stats.info,
}
note = eval(evaluation, {}, stats_dict) # pylint: disable=eval-used
except Exception as ex: # pylint: disable=broad-except
msg = f"An exception occurred while rating: {ex}"
else:
self.stats.global_note = note
msg = f"Your code has been rated at {note:.2f}/10"
if previous_stats:
pnote = previous_stats.global_note
if pnote is not None:
msg += f" (previous run: {pnote:.2f}/10, {note - pnote:+.2f})"
if self.config.score:
sect = report_nodes.EvaluationSection(msg)
self.reporter.display_reports(sect)
return note
# Adding (ignored) messages to the Message Reporter
def _get_message_state_scope(
self,
msgid: str,
line: Optional[int] = None,
confidence: Optional[interfaces.Confidence] = None,
) -> Optional[Literal[0, 1, 2]]:
"""Returns the scope at which a message was enabled/disabled."""
if confidence is None:
confidence = interfaces.UNDEFINED
if self.config.confidence and confidence.name not in self.config.confidence:
return MSG_STATE_CONFIDENCE # type: ignore[return-value] # mypy does not infer Literal correctly
try:
if line in self.file_state._module_msgs_state[msgid]:
return MSG_STATE_SCOPE_MODULE # type: ignore[return-value]
except (KeyError, TypeError):
return MSG_STATE_SCOPE_CONFIG # type: ignore[return-value]
return None
def _is_one_message_enabled(self, msgid: str, line: Optional[int]) -> bool:
"""Checks state of a single message for the current file.
This function can't be cached as it depends on self.file_state which can
change.
"""
if line is None:
return self._msgs_state.get(msgid, _True)
try:
return self.file_state._module_msgs_state[msgid][line]
except KeyError:
# Check if the message's line is after the maximum line existing in ast tree.
# This line won't appear in the ast tree and won't be referred in
# self.file_state._module_msgs_state
# This happens for example with a commented line at the end of a module.
max_line_number = self.file_state.get_effective_max_line_number()
if max_line_number and line > max_line_number:
fallback = _True
lines = self.file_state._raw_module_msgs_state.get(msgid, {})
# Doesn't consider scopes, as a 'disable' can be in a
# different scope than that of the current line.
closest_lines = reversed(
[
(message_line, enable)
for message_line, enable in lines.items()
if message_line <= line
]
)
_, fallback_iter = next(closest_lines, (None, None))
if fallback_iter is not None:
fallback = fallback_iter
return self._msgs_state.get(msgid, fallback)
return self._msgs_state.get(msgid, _True)
def is_message_enabled(
self,
msg_descr: str,
line: Optional[int] = None,
confidence: Optional[interfaces.Confidence] = None,
) -> bool:
"""Return whether this message is enabled for the current file, line and confidence level.
This function can't be cached right now as the line is the line of
the currently analysed file (self.file_state), if it changes, then the
result for the same msg_descr/line might need to change.
:param msg_descr: Either the msgid or the symbol for a MessageDefinition
:param line: The line of the currently analysed file
:param confidence: The confidence of the message
"""
if self.config.confidence and confidence:
if confidence.name not in self.config.confidence:
return _False
try:
msgids = self.msgs_store.message_id_store.get_active_msgids(msg_descr)
except exceptions.UnknownMessageError:
# The linter checks for messages that are not registered
# due to version mismatch, just treat them as message IDs
# for now.
msgids = [msg_descr]
return any(self._is_one_message_enabled(msgid, line) for msgid in msgids)
def _add_one_message(
self,
message_definition: MessageDefinition,
line: Optional[int],
node: Optional[nodes.NodeNG],
args: Optional[Any],
confidence: Optional[interfaces.Confidence],
col_offset: Optional[int],
end_lineno: Optional[int],
end_col_offset: Optional[int],
) -> None:
"""After various checks have passed a single Message is
passed to the reporter and added to stats
"""
message_definition.check_message_definition(line, node)
# Look up "location" data of node if not yet supplied
if node:
if not line:
line = node.fromlineno
if not col_offset:
col_offset = node.col_offset
if not end_lineno:
end_lineno = node.end_lineno
if not end_col_offset:
end_col_offset = node.end_col_offset
# should this message be displayed
if not self.is_message_enabled(message_definition.msgid, line, confidence):
self.file_state.handle_ignored_message(
self._get_message_state_scope(
message_definition.msgid, line, confidence
),
message_definition.msgid,
line,
)
return
# update stats
msg_cat = MSG_TYPES[message_definition.msgid[0]]
self.msg_status |= MSG_TYPES_STATUS[message_definition.msgid[0]]
self.stats.increase_single_message_count(msg_cat, 1)
self.stats.increase_single_module_message_count(
self.current_name, # type: ignore[arg-type] # Should be removable after https://github.com/PyCQA/pylint/pull/5580
msg_cat,
1,
)
try:
self.stats.by_msg[message_definition.symbol] += 1
except KeyError:
self.stats.by_msg[message_definition.symbol] = 1
# Interpolate arguments into message string
msg = message_definition.msg
if args:
msg %= args
# get module and object
if node is None:
module, obj = self.current_name, ""
abspath = self.current_file
else:
module, obj = utils.get_module_and_frameid(node)
abspath = node.root().file
if abspath is not None:
path = abspath.replace(self.reporter.path_strip_prefix, "", 1)
else:
path = "configuration"
# add the message
self.reporter.handle_message(
Message(
message_definition.msgid,
message_definition.symbol,
MessageLocationTuple(
abspath or "",
path,
module or "",
obj,
line or 1,
col_offset or 0,
end_lineno,
end_col_offset,
),
msg,
confidence,
)
)
def add_message(
self,
msgid: str,
line: Optional[int] = None,
node: Optional[nodes.NodeNG] = None,
args: Optional[Any] = None,
confidence: Optional[interfaces.Confidence] = None,
col_offset: Optional[int] = None,
end_lineno: Optional[int] = None,
end_col_offset: Optional[int] = None,
) -> None:
"""Adds a message given by ID or name.
If provided, the message string is expanded using args.
AST checkers must provide the node argument (but may optionally
provide line if the line number is different), raw and token checkers
must provide the line argument.
"""
if confidence is None:
confidence = interfaces.UNDEFINED
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
self._add_one_message(
message_definition,
line,
node,
args,
confidence,
col_offset,
end_lineno,
end_col_offset,
)
def add_ignored_message(
self,
msgid: str,
line: int,
node: Optional[nodes.NodeNG] = None,
confidence: Optional[interfaces.Confidence] = interfaces.UNDEFINED,
) -> None:
"""Prepares a message to be added to the ignored message storage.
Some checks return early in special cases and never reach add_message(),
even though they would normally issue a message.
This creates false positives for useless-suppression.
This function avoids this by adding those message to the ignored msgs attribute
"""
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
message_definition.check_message_definition(line, node)
self.file_state.handle_ignored_message(
self._get_message_state_scope(
message_definition.msgid, line, confidence
),
message_definition.msgid,
line,
)
# Setting the state (disabled/enabled) of messages and registering them
def _message_symbol(self, msgid: str) -> List[str]:
"""Get the message symbol of the given message id.
Return the original message id if the message does not
exist.
"""
try:
return [md.symbol for md in self.msgs_store.get_message_definitions(msgid)]
except exceptions.UnknownMessageError:
return [msgid]
def _set_one_msg_status(
self, scope: str, msg: MessageDefinition, line: Optional[int], enable: bool
) -> None:
"""Set the status of an individual message."""
if scope == "module":
assert isinstance(line, int) # should always be int inside module scope
self.file_state.set_msg_status(msg, line, enable)
if not enable and msg.symbol != "locally-disabled":
self.add_message(
"locally-disabled", line=line, args=(msg.symbol, msg.msgid)
)
else:
msgs = self._msgs_state
msgs[msg.msgid] = enable
def _get_messages_to_set(
self, msgid: str, enable: bool, ignore_unknown: bool = _False
) -> List[MessageDefinition]:
"""Do some tests and find the actual messages of which the status should be set."""
message_definitions = []
if msgid == "all":
for _msgid in MSG_TYPES:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a category?
category_id = msgid.upper()
if category_id not in MSG_TYPES:
category_id_formatted = MSG_TYPES_LONG.get(category_id)
else:
category_id_formatted = category_id
if category_id_formatted is not None:
for _msgid in self.msgs_store._msgs_by_category[category_id_formatted]:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a checker name?
if msgid.lower() in self._checkers:
for checker in self._checkers[msgid.lower()]:
for _msgid in checker.msgs:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is report id?
if msgid.lower().startswith("rp"):
if enable:
self.enable_report(msgid)
else:
self.disable_report(msgid)
return message_definitions
try:
# msgid is a symbolic or numeric msgid.
message_definitions = self.msgs_store.get_message_definitions(msgid)
except exceptions.UnknownMessageError:
if not ignore_unknown:
raise
return message_definitions
def _set_msg_status(
self,
msgid: str,
enable: bool,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Do some tests and then iterate over message definitions to set state."""
assert scope in {"package", "module"}
message_definitions = self._get_messages_to_set(msgid, enable, ignore_unknown)
for message_definition in message_definitions:
self._set_one_msg_status(scope, message_definition, line, enable)
# sync configuration object
self.config.enable = []
self.config.disable = []
for mid, val in self._msgs_state.items():
if val:
self.config.enable.append(self._message_symbol(mid))
else:
self.config.disable.append(self._message_symbol(mid))
def _register_by_id_managed_msg(
self, msgid_or_symbol: str, line: Optional[int], is_disabled: bool = _True
) -> None:
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid.
"""
if msgid_or_symbol[1:].isdigit():
try:
symbol = self.msgs_store.message_id_store.get_symbol(
msgid=msgid_or_symbol
)
except exceptions.UnknownMessageError:
return
managed = ManagedMessage(
self.current_name, msgid_or_symbol, symbol, line, is_disabled
)
self._by_id_managed_msgs.append(managed)
def disable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for a scope."""
self._set_msg_status(
msgid, enable=_False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line)
def disable_next(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for the next line."""
if not line:
raise exceptions.NoLineSuppliedError
self._set_msg_status(
msgid,
enable=_False,
scope=scope,
line=line + 1,
ignore_unknown=ignore_unknown,
)
self._register_by_id_managed_msg(msgid, line + 1)
def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,367 | display_messages | ref | function | self.reporter.display_messages(report_nodes.Section())
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,367 | Section | ref | function | self.reporter.display_messages(report_nodes.Section())
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,371 | load_results | ref | function | previous_stats = config.load_results(self.file_state.base_name)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,372 | on_close | ref | function | self.reporter.on_close(self.stats, previous_stats)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,374 | make_reports | ref | function | sect = self.make_reports(self.stats, previous_stats)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,376 | Section | ref | function | sect = report_nodes.Section()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,379 | display_reports | ref | function | self.reporter.display_reports(sect)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,380 | _report_evaluation | ref | function | score_value = self._report_evaluation()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,383 | save_results | ref | function | config.save_results(self.stats, self.file_state.base_name)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,385 | on_close | ref | function | self.reporter.on_close(self.stats, LinterStats())
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,385 | LinterStats | ref | function | self.reporter.on_close(self.stats, LinterStats())
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,389 | _report_evaluation | def | function | def _report_evaluation(self):
"""Make the global evaluation report."""
# check with at least check 1 statements (usually 0 when there is a
# syntax error preventing pylint from further processing)
note = None
previous_stats = config.load_results(self.file_state.base_name)
if self.stats.statement == 0:
return note
# get a global note for the code
evaluation = self.config.evaluation
try:
stats_dict = {
"fatal": self.stats.fatal,
"error": self.stats.error,
"warning": self.stats.warning,
"refactor": self.stats.refactor,
"convention": self.stats.convention,
"statement": self.stats.statement,
"info": self.stats.info,
}
note = eval(evaluation, {}, stats_dict) # pylint: disable=eval-used
except Exception as ex: # pylint: disable=broad-except
msg = f"An exception occurred while rating: {ex}"
else:
self.stats.global_note = note
msg = f"Your code has been rated at {note:.2f}/10"
if previous_stats:
pnote = previous_stats.global_note
if pnote is not None:
msg += f" (previous run: {pnote:.2f}/10, {note - pnote:+.2f})"
if self.config.score:
sect = report_nodes.EvaluationSection(msg)
self.reporter.display_reports(sect)
return note
# Adding (ignored) messages to the Message Reporter
def _get_message_state_scope(
self,
msgid: str,
line: Optional[int] = None,
confidence: Optional[interfaces.Confidence] = None,
) -> Optional[Literal[0, 1, 2]]:
"""Returns the scope at which a message was enabled/disabled."""
if confidence is None:
confidence = interfaces.UNDEFINED
if self.config.confidence and confidence.name not in self.config.confidence:
return MSG_STATE_CONFIDENCE # type: ignore[return-value] # mypy does not infer Literal correctly
try:
if line in self.file_state._module_msgs_state[msgid]:
return MSG_STATE_SCOPE_MODULE # type: ignore[return-value]
except (KeyError, TypeError):
return MSG_STATE_SCOPE_CONFIG # type: ignore[return-value]
return None
def _is_one_message_enabled(self, msgid: str, line: Optional[int]) -> bool:
"""Checks state of a single message for the current file.
This function can't be cached as it depends on self.file_state which can
change.
"""
if line is None:
return self._msgs_state.get(msgid, _True)
try:
return self.file_state._module_msgs_state[msgid][line]
except KeyError:
# Check if the message's line is after the maximum line existing in ast tree.
# This line won't appear in the ast tree and won't be referred in
# self.file_state._module_msgs_state
# This happens for example with a commented line at the end of a module.
max_line_number = self.file_state.get_effective_max_line_number()
if max_line_number and line > max_line_number:
fallback = _True
lines = self.file_state._raw_module_msgs_state.get(msgid, {})
# Doesn't consider scopes, as a 'disable' can be in a
# different scope than that of the current line.
closest_lines = reversed(
[
(message_line, enable)
for message_line, enable in lines.items()
if message_line <= line
]
)
_, fallback_iter = next(closest_lines, (None, None))
if fallback_iter is not None:
fallback = fallback_iter
return self._msgs_state.get(msgid, fallback)
return self._msgs_state.get(msgid, _True)
def is_message_enabled(
self,
msg_descr: str,
line: Optional[int] = None,
confidence: Optional[interfaces.Confidence] = None,
) -> bool:
"""Return whether this message is enabled for the current file, line and confidence level.
This function can't be cached right now as the line is the line of
the currently analysed file (self.file_state), if it changes, then the
result for the same msg_descr/line might need to change.
:param msg_descr: Either the msgid or the symbol for a MessageDefinition
:param line: The line of the currently analysed file
:param confidence: The confidence of the message
"""
if self.config.confidence and confidence:
if confidence.name not in self.config.confidence:
return _False
try:
msgids = self.msgs_store.message_id_store.get_active_msgids(msg_descr)
except exceptions.UnknownMessageError:
# The linter checks for messages that are not registered
# due to version mismatch, just treat them as message IDs
# for now.
msgids = [msg_descr]
return any(self._is_one_message_enabled(msgid, line) for msgid in msgids)
def _add_one_message(
self,
message_definition: MessageDefinition,
line: Optional[int],
node: Optional[nodes.NodeNG],
args: Optional[Any],
confidence: Optional[interfaces.Confidence],
col_offset: Optional[int],
end_lineno: Optional[int],
end_col_offset: Optional[int],
) -> None:
"""After various checks have passed a single Message is
passed to the reporter and added to stats
"""
message_definition.check_message_definition(line, node)
# Look up "location" data of node if not yet supplied
if node:
if not line:
line = node.fromlineno
if not col_offset:
col_offset = node.col_offset
if not end_lineno:
end_lineno = node.end_lineno
if not end_col_offset:
end_col_offset = node.end_col_offset
# should this message be displayed
if not self.is_message_enabled(message_definition.msgid, line, confidence):
self.file_state.handle_ignored_message(
self._get_message_state_scope(
message_definition.msgid, line, confidence
),
message_definition.msgid,
line,
)
return
# update stats
msg_cat = MSG_TYPES[message_definition.msgid[0]]
self.msg_status |= MSG_TYPES_STATUS[message_definition.msgid[0]]
self.stats.increase_single_message_count(msg_cat, 1)
self.stats.increase_single_module_message_count(
self.current_name, # type: ignore[arg-type] # Should be removable after https://github.com/PyCQA/pylint/pull/5580
msg_cat,
1,
)
try:
self.stats.by_msg[message_definition.symbol] += 1
except KeyError:
self.stats.by_msg[message_definition.symbol] = 1
# Interpolate arguments into message string
msg = message_definition.msg
if args:
msg %= args
# get module and object
if node is None:
module, obj = self.current_name, ""
abspath = self.current_file
else:
module, obj = utils.get_module_and_frameid(node)
abspath = node.root().file
if abspath is not None:
path = abspath.replace(self.reporter.path_strip_prefix, "", 1)
else:
path = "configuration"
# add the message
self.reporter.handle_message(
Message(
message_definition.msgid,
message_definition.symbol,
MessageLocationTuple(
abspath or "",
path,
module or "",
obj,
line or 1,
col_offset or 0,
end_lineno,
end_col_offset,
),
msg,
confidence,
)
)
def add_message(
self,
msgid: str,
line: Optional[int] = None,
node: Optional[nodes.NodeNG] = None,
args: Optional[Any] = None,
confidence: Optional[interfaces.Confidence] = None,
col_offset: Optional[int] = None,
end_lineno: Optional[int] = None,
end_col_offset: Optional[int] = None,
) -> None:
"""Adds a message given by ID or name.
If provided, the message string is expanded using args.
AST checkers must provide the node argument (but may optionally
provide line if the line number is different), raw and token checkers
must provide the line argument.
"""
if confidence is None:
confidence = interfaces.UNDEFINED
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
self._add_one_message(
message_definition,
line,
node,
args,
confidence,
col_offset,
end_lineno,
end_col_offset,
)
def add_ignored_message(
self,
msgid: str,
line: int,
node: Optional[nodes.NodeNG] = None,
confidence: Optional[interfaces.Confidence] = interfaces.UNDEFINED,
) -> None:
"""Prepares a message to be added to the ignored message storage.
Some checks return early in special cases and never reach add_message(),
even though they would normally issue a message.
This creates false positives for useless-suppression.
This function avoids this by adding those message to the ignored msgs attribute
"""
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
message_definition.check_message_definition(line, node)
self.file_state.handle_ignored_message(
self._get_message_state_scope(
message_definition.msgid, line, confidence
),
message_definition.msgid,
line,
)
# Setting the state (disabled/enabled) of messages and registering them
def _message_symbol(self, msgid: str) -> List[str]:
"""Get the message symbol of the given message id.
Return the original message id if the message does not
exist.
"""
try:
return [md.symbol for md in self.msgs_store.get_message_definitions(msgid)]
except exceptions.UnknownMessageError:
return [msgid]
def _set_one_msg_status(
self, scope: str, msg: MessageDefinition, line: Optional[int], enable: bool
) -> None:
"""Set the status of an individual message."""
if scope == "module":
assert isinstance(line, int) # should always be int inside module scope
self.file_state.set_msg_status(msg, line, enable)
if not enable and msg.symbol != "locally-disabled":
self.add_message(
"locally-disabled", line=line, args=(msg.symbol, msg.msgid)
)
else:
msgs = self._msgs_state
msgs[msg.msgid] = enable
def _get_messages_to_set(
self, msgid: str, enable: bool, ignore_unknown: bool = _False
) -> List[MessageDefinition]:
"""Do some tests and find the actual messages of which the status should be set."""
message_definitions = []
if msgid == "all":
for _msgid in MSG_TYPES:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a category?
category_id = msgid.upper()
if category_id not in MSG_TYPES:
category_id_formatted = MSG_TYPES_LONG.get(category_id)
else:
category_id_formatted = category_id
if category_id_formatted is not None:
for _msgid in self.msgs_store._msgs_by_category[category_id_formatted]:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a checker name?
if msgid.lower() in self._checkers:
for checker in self._checkers[msgid.lower()]:
for _msgid in checker.msgs:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is report id?
if msgid.lower().startswith("rp"):
if enable:
self.enable_report(msgid)
else:
self.disable_report(msgid)
return message_definitions
try:
# msgid is a symbolic or numeric msgid.
message_definitions = self.msgs_store.get_message_definitions(msgid)
except exceptions.UnknownMessageError:
if not ignore_unknown:
raise
return message_definitions
def _set_msg_status(
self,
msgid: str,
enable: bool,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Do some tests and then iterate over message definitions to set state."""
assert scope in {"package", "module"}
message_definitions = self._get_messages_to_set(msgid, enable, ignore_unknown)
for message_definition in message_definitions:
self._set_one_msg_status(scope, message_definition, line, enable)
# sync configuration object
self.config.enable = []
self.config.disable = []
for mid, val in self._msgs_state.items():
if val:
self.config.enable.append(self._message_symbol(mid))
else:
self.config.disable.append(self._message_symbol(mid))
def _register_by_id_managed_msg(
self, msgid_or_symbol: str, line: Optional[int], is_disabled: bool = _True
) -> None:
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid.
"""
if msgid_or_symbol[1:].isdigit():
try:
symbol = self.msgs_store.message_id_store.get_symbol(
msgid=msgid_or_symbol
)
except exceptions.UnknownMessageError:
return
managed = ManagedMessage(
self.current_name, msgid_or_symbol, symbol, line, is_disabled
)
self._by_id_managed_msgs.append(managed)
def disable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for a scope."""
self._set_msg_status(
msgid, enable=_False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line)
def disable_next(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for the next line."""
if not line:
raise exceptions.NoLineSuppliedError
self._set_msg_status(
msgid,
enable=_False,
scope=scope,
line=line + 1,
ignore_unknown=ignore_unknown,
)
self._register_by_id_managed_msg(msgid, line + 1)
def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,394 | load_results | ref | function | previous_stats = config.load_results(self.file_state.base_name)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,422 | EvaluationSection | ref | function | sect = report_nodes.EvaluationSection(msg)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,423 | display_reports | ref | function | self.reporter.display_reports(sect)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,428 | _get_message_state_scope | def | function | def _get_message_state_scope(
self,
msgid: str,
line: Optional[int] = None,
confidence: Optional[interfaces.Confidence] = None,
) -> Optional[Literal[0, 1, 2]]:
"""Returns the scope at which a message was enabled/disabled."""
if confidence is None:
confidence = interfaces.UNDEFINED
if self.config.confidence and confidence.name not in self.config.confidence:
return MSG_STATE_CONFIDENCE # type: ignore[return-value] # mypy does not infer Literal correctly
try:
if line in self.file_state._module_msgs_state[msgid]:
return MSG_STATE_SCOPE_MODULE # type: ignore[return-value]
except (KeyError, TypeError):
return MSG_STATE_SCOPE_CONFIG # type: ignore[return-value]
return None
def _is_one_message_enabled(self, msgid: str, line: Optional[int]) -> bool:
"""Checks state of a single message for the current file.
This function can't be cached as it depends on self.file_state which can
change.
"""
if line is None:
return self._msgs_state.get(msgid, _True)
try:
return self.file_state._module_msgs_state[msgid][line]
except KeyError:
# Check if the message's line is after the maximum line existing in ast tree.
# This line won't appear in the ast tree and won't be referred in
# self.file_state._module_msgs_state
# This happens for example with a commented line at the end of a module.
max_line_number = self.file_state.get_effective_max_line_number()
if max_line_number and line > max_line_number:
fallback = _True
lines = self.file_state._raw_module_msgs_state.get(msgid, {})
# Doesn't consider scopes, as a 'disable' can be in a
# different scope than that of the current line.
closest_lines = reversed(
[
(message_line, enable)
for message_line, enable in lines.items()
if message_line <= line
]
)
_, fallback_iter = next(closest_lines, (None, None))
if fallback_iter is not None:
fallback = fallback_iter
return self._msgs_state.get(msgid, fallback)
return self._msgs_state.get(msgid, _True)
def is_message_enabled(
self,
msg_descr: str,
line: Optional[int] = None,
confidence: Optional[interfaces.Confidence] = None,
) -> bool:
"""Return whether this message is enabled for the current file, line and confidence level.
This function can't be cached right now as the line is the line of
the currently analysed file (self.file_state), if it changes, then the
result for the same msg_descr/line might need to change.
:param msg_descr: Either the msgid or the symbol for a MessageDefinition
:param line: The line of the currently analysed file
:param confidence: The confidence of the message
"""
if self.config.confidence and confidence:
if confidence.name not in self.config.confidence:
return _False
try:
msgids = self.msgs_store.message_id_store.get_active_msgids(msg_descr)
except exceptions.UnknownMessageError:
# The linter checks for messages that are not registered
# due to version mismatch, just treat them as message IDs
# for now.
msgids = [msg_descr]
return any(self._is_one_message_enabled(msgid, line) for msgid in msgids)
def _add_one_message(
self,
message_definition: MessageDefinition,
line: Optional[int],
node: Optional[nodes.NodeNG],
args: Optional[Any],
confidence: Optional[interfaces.Confidence],
col_offset: Optional[int],
end_lineno: Optional[int],
end_col_offset: Optional[int],
) -> None:
"""After various checks have passed a single Message is
passed to the reporter and added to stats
"""
message_definition.check_message_definition(line, node)
# Look up "location" data of node if not yet supplied
if node:
if not line:
line = node.fromlineno
if not col_offset:
col_offset = node.col_offset
if not end_lineno:
end_lineno = node.end_lineno
if not end_col_offset:
end_col_offset = node.end_col_offset
# should this message be displayed
if not self.is_message_enabled(message_definition.msgid, line, confidence):
self.file_state.handle_ignored_message(
self._get_message_state_scope(
message_definition.msgid, line, confidence
),
message_definition.msgid,
line,
)
return
# update stats
msg_cat = MSG_TYPES[message_definition.msgid[0]]
self.msg_status |= MSG_TYPES_STATUS[message_definition.msgid[0]]
self.stats.increase_single_message_count(msg_cat, 1)
self.stats.increase_single_module_message_count(
self.current_name, # type: ignore[arg-type] # Should be removable after https://github.com/PyCQA/pylint/pull/5580
msg_cat,
1,
)
try:
self.stats.by_msg[message_definition.symbol] += 1
except KeyError:
self.stats.by_msg[message_definition.symbol] = 1
# Interpolate arguments into message string
msg = message_definition.msg
if args:
msg %= args
# get module and object
if node is None:
module, obj = self.current_name, ""
abspath = self.current_file
else:
module, obj = utils.get_module_and_frameid(node)
abspath = node.root().file
if abspath is not None:
path = abspath.replace(self.reporter.path_strip_prefix, "", 1)
else:
path = "configuration"
# add the message
self.reporter.handle_message(
Message(
message_definition.msgid,
message_definition.symbol,
MessageLocationTuple(
abspath or "",
path,
module or "",
obj,
line or 1,
col_offset or 0,
end_lineno,
end_col_offset,
),
msg,
confidence,
)
)
def add_message(
self,
msgid: str,
line: Optional[int] = None,
node: Optional[nodes.NodeNG] = None,
args: Optional[Any] = None,
confidence: Optional[interfaces.Confidence] = None,
col_offset: Optional[int] = None,
end_lineno: Optional[int] = None,
end_col_offset: Optional[int] = None,
) -> None:
"""Adds a message given by ID or name.
If provided, the message string is expanded using args.
AST checkers must provide the node argument (but may optionally
provide line if the line number is different), raw and token checkers
must provide the line argument.
"""
if confidence is None:
confidence = interfaces.UNDEFINED
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
self._add_one_message(
message_definition,
line,
node,
args,
confidence,
col_offset,
end_lineno,
end_col_offset,
)
def add_ignored_message(
self,
msgid: str,
line: int,
node: Optional[nodes.NodeNG] = None,
confidence: Optional[interfaces.Confidence] = interfaces.UNDEFINED,
) -> None:
"""Prepares a message to be added to the ignored message storage.
Some checks return early in special cases and never reach add_message(),
even though they would normally issue a message.
This creates false positives for useless-suppression.
This function avoids this by adding those message to the ignored msgs attribute
"""
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
message_definition.check_message_definition(line, node)
self.file_state.handle_ignored_message(
self._get_message_state_scope(
message_definition.msgid, line, confidence
),
message_definition.msgid,
line,
)
# Setting the state (disabled/enabled) of messages and registering them
def _message_symbol(self, msgid: str) -> List[str]:
"""Get the message symbol of the given message id.
Return the original message id if the message does not
exist.
"""
try:
return [md.symbol for md in self.msgs_store.get_message_definitions(msgid)]
except exceptions.UnknownMessageError:
return [msgid]
def _set_one_msg_status(
self, scope: str, msg: MessageDefinition, line: Optional[int], enable: bool
) -> None:
"""Set the status of an individual message."""
if scope == "module":
assert isinstance(line, int) # should always be int inside module scope
self.file_state.set_msg_status(msg, line, enable)
if not enable and msg.symbol != "locally-disabled":
self.add_message(
"locally-disabled", line=line, args=(msg.symbol, msg.msgid)
)
else:
msgs = self._msgs_state
msgs[msg.msgid] = enable
def _get_messages_to_set(
self, msgid: str, enable: bool, ignore_unknown: bool = _False
) -> List[MessageDefinition]:
"""Do some tests and find the actual messages of which the status should be set."""
message_definitions = []
if msgid == "all":
for _msgid in MSG_TYPES:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a category?
category_id = msgid.upper()
if category_id not in MSG_TYPES:
category_id_formatted = MSG_TYPES_LONG.get(category_id)
else:
category_id_formatted = category_id
if category_id_formatted is not None:
for _msgid in self.msgs_store._msgs_by_category[category_id_formatted]:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a checker name?
if msgid.lower() in self._checkers:
for checker in self._checkers[msgid.lower()]:
for _msgid in checker.msgs:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is report id?
if msgid.lower().startswith("rp"):
if enable:
self.enable_report(msgid)
else:
self.disable_report(msgid)
return message_definitions
try:
# msgid is a symbolic or numeric msgid.
message_definitions = self.msgs_store.get_message_definitions(msgid)
except exceptions.UnknownMessageError:
if not ignore_unknown:
raise
return message_definitions
def _set_msg_status(
self,
msgid: str,
enable: bool,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Do some tests and then iterate over message definitions to set state."""
assert scope in {"package", "module"}
message_definitions = self._get_messages_to_set(msgid, enable, ignore_unknown)
for message_definition in message_definitions:
self._set_one_msg_status(scope, message_definition, line, enable)
# sync configuration object
self.config.enable = []
self.config.disable = []
for mid, val in self._msgs_state.items():
if val:
self.config.enable.append(self._message_symbol(mid))
else:
self.config.disable.append(self._message_symbol(mid))
def _register_by_id_managed_msg(
self, msgid_or_symbol: str, line: Optional[int], is_disabled: bool = _True
) -> None:
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid.
"""
if msgid_or_symbol[1:].isdigit():
try:
symbol = self.msgs_store.message_id_store.get_symbol(
msgid=msgid_or_symbol
)
except exceptions.UnknownMessageError:
return
managed = ManagedMessage(
self.current_name, msgid_or_symbol, symbol, line, is_disabled
)
self._by_id_managed_msgs.append(managed)
def disable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for a scope."""
self._set_msg_status(
msgid, enable=_False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line)
def disable_next(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for the next line."""
if not line:
raise exceptions.NoLineSuppliedError
self._set_msg_status(
msgid,
enable=_False,
scope=scope,
line=line + 1,
ignore_unknown=ignore_unknown,
)
self._register_by_id_managed_msg(msgid, line + 1)
def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,446 | _is_one_message_enabled | def | function | def _is_one_message_enabled(self, msgid: str, line: Optional[int]) -> bool:
"""Checks state of a single message for the current file.
This function can't be cached as it depends on self.file_state which can
change.
"""
if line is None:
return self._msgs_state.get(msgid, _True)
try:
return self.file_state._module_msgs_state[msgid][line]
except KeyError:
# Check if the message's line is after the maximum line existing in ast tree.
# This line won't appear in the ast tree and won't be referred in
# self.file_state._module_msgs_state
# This happens for example with a commented line at the end of a module.
max_line_number = self.file_state.get_effective_max_line_number()
if max_line_number and line > max_line_number:
fallback = _True
lines = self.file_state._raw_module_msgs_state.get(msgid, {})
# Doesn't consider scopes, as a 'disable' can be in a
# different scope than that of the current line.
closest_lines = reversed(
[
(message_line, enable)
for message_line, enable in lines.items()
if message_line <= line
]
)
_, fallback_iter = next(closest_lines, (None, None))
if fallback_iter is not None:
fallback = fallback_iter
return self._msgs_state.get(msgid, fallback)
return self._msgs_state.get(msgid, _True)
def is_message_enabled(
self,
msg_descr: str,
line: Optional[int] = None,
confidence: Optional[interfaces.Confidence] = None,
) -> bool:
"""Return whether this message is enabled for the current file, line and confidence level.
This function can't be cached right now as the line is the line of
the currently analysed file (self.file_state), if it changes, then the
result for the same msg_descr/line might need to change.
:param msg_descr: Either the msgid or the symbol for a MessageDefinition
:param line: The line of the currently analysed file
:param confidence: The confidence of the message
"""
if self.config.confidence and confidence:
if confidence.name not in self.config.confidence:
return _False
try:
msgids = self.msgs_store.message_id_store.get_active_msgids(msg_descr)
except exceptions.UnknownMessageError:
# The linter checks for messages that are not registered
# due to version mismatch, just treat them as message IDs
# for now.
msgids = [msg_descr]
return any(self._is_one_message_enabled(msgid, line) for msgid in msgids)
def _add_one_message(
self,
message_definition: MessageDefinition,
line: Optional[int],
node: Optional[nodes.NodeNG],
args: Optional[Any],
confidence: Optional[interfaces.Confidence],
col_offset: Optional[int],
end_lineno: Optional[int],
end_col_offset: Optional[int],
) -> None:
"""After various checks have passed a single Message is
passed to the reporter and added to stats
"""
message_definition.check_message_definition(line, node)
# Look up "location" data of node if not yet supplied
if node:
if not line:
line = node.fromlineno
if not col_offset:
col_offset = node.col_offset
if not end_lineno:
end_lineno = node.end_lineno
if not end_col_offset:
end_col_offset = node.end_col_offset
# should this message be displayed
if not self.is_message_enabled(message_definition.msgid, line, confidence):
self.file_state.handle_ignored_message(
self._get_message_state_scope(
message_definition.msgid, line, confidence
),
message_definition.msgid,
line,
)
return
# update stats
msg_cat = MSG_TYPES[message_definition.msgid[0]]
self.msg_status |= MSG_TYPES_STATUS[message_definition.msgid[0]]
self.stats.increase_single_message_count(msg_cat, 1)
self.stats.increase_single_module_message_count(
self.current_name, # type: ignore[arg-type] # Should be removable after https://github.com/PyCQA/pylint/pull/5580
msg_cat,
1,
)
try:
self.stats.by_msg[message_definition.symbol] += 1
except KeyError:
self.stats.by_msg[message_definition.symbol] = 1
# Interpolate arguments into message string
msg = message_definition.msg
if args:
msg %= args
# get module and object
if node is None:
module, obj = self.current_name, ""
abspath = self.current_file
else:
module, obj = utils.get_module_and_frameid(node)
abspath = node.root().file
if abspath is not None:
path = abspath.replace(self.reporter.path_strip_prefix, "", 1)
else:
path = "configuration"
# add the message
self.reporter.handle_message(
Message(
message_definition.msgid,
message_definition.symbol,
MessageLocationTuple(
abspath or "",
path,
module or "",
obj,
line or 1,
col_offset or 0,
end_lineno,
end_col_offset,
),
msg,
confidence,
)
)
def add_message(
self,
msgid: str,
line: Optional[int] = None,
node: Optional[nodes.NodeNG] = None,
args: Optional[Any] = None,
confidence: Optional[interfaces.Confidence] = None,
col_offset: Optional[int] = None,
end_lineno: Optional[int] = None,
end_col_offset: Optional[int] = None,
) -> None:
"""Adds a message given by ID or name.
If provided, the message string is expanded using args.
AST checkers must provide the node argument (but may optionally
provide line if the line number is different), raw and token checkers
must provide the line argument.
"""
if confidence is None:
confidence = interfaces.UNDEFINED
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
self._add_one_message(
message_definition,
line,
node,
args,
confidence,
col_offset,
end_lineno,
end_col_offset,
)
def add_ignored_message(
self,
msgid: str,
line: int,
node: Optional[nodes.NodeNG] = None,
confidence: Optional[interfaces.Confidence] = interfaces.UNDEFINED,
) -> None:
"""Prepares a message to be added to the ignored message storage.
Some checks return early in special cases and never reach add_message(),
even though they would normally issue a message.
This creates false positives for useless-suppression.
This function avoids this by adding those message to the ignored msgs attribute
"""
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
message_definition.check_message_definition(line, node)
self.file_state.handle_ignored_message(
self._get_message_state_scope(
message_definition.msgid, line, confidence
),
message_definition.msgid,
line,
)
# Setting the state (disabled/enabled) of messages and registering them
def _message_symbol(self, msgid: str) -> List[str]:
"""Get the message symbol of the given message id.
Return the original message id if the message does not
exist.
"""
try:
return [md.symbol for md in self.msgs_store.get_message_definitions(msgid)]
except exceptions.UnknownMessageError:
return [msgid]
def _set_one_msg_status(
self, scope: str, msg: MessageDefinition, line: Optional[int], enable: bool
) -> None:
"""Set the status of an individual message."""
if scope == "module":
assert isinstance(line, int) # should always be int inside module scope
self.file_state.set_msg_status(msg, line, enable)
if not enable and msg.symbol != "locally-disabled":
self.add_message(
"locally-disabled", line=line, args=(msg.symbol, msg.msgid)
)
else:
msgs = self._msgs_state
msgs[msg.msgid] = enable
def _get_messages_to_set(
self, msgid: str, enable: bool, ignore_unknown: bool = _False
) -> List[MessageDefinition]:
"""Do some tests and find the actual messages of which the status should be set."""
message_definitions = []
if msgid == "all":
for _msgid in MSG_TYPES:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a category?
category_id = msgid.upper()
if category_id not in MSG_TYPES:
category_id_formatted = MSG_TYPES_LONG.get(category_id)
else:
category_id_formatted = category_id
if category_id_formatted is not None:
for _msgid in self.msgs_store._msgs_by_category[category_id_formatted]:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a checker name?
if msgid.lower() in self._checkers:
for checker in self._checkers[msgid.lower()]:
for _msgid in checker.msgs:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is report id?
if msgid.lower().startswith("rp"):
if enable:
self.enable_report(msgid)
else:
self.disable_report(msgid)
return message_definitions
try:
# msgid is a symbolic or numeric msgid.
message_definitions = self.msgs_store.get_message_definitions(msgid)
except exceptions.UnknownMessageError:
if not ignore_unknown:
raise
return message_definitions
def _set_msg_status(
self,
msgid: str,
enable: bool,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Do some tests and then iterate over message definitions to set state."""
assert scope in {"package", "module"}
message_definitions = self._get_messages_to_set(msgid, enable, ignore_unknown)
for message_definition in message_definitions:
self._set_one_msg_status(scope, message_definition, line, enable)
# sync configuration object
self.config.enable = []
self.config.disable = []
for mid, val in self._msgs_state.items():
if val:
self.config.enable.append(self._message_symbol(mid))
else:
self.config.disable.append(self._message_symbol(mid))
def _register_by_id_managed_msg(
self, msgid_or_symbol: str, line: Optional[int], is_disabled: bool = _True
) -> None:
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid.
"""
if msgid_or_symbol[1:].isdigit():
try:
symbol = self.msgs_store.message_id_store.get_symbol(
msgid=msgid_or_symbol
)
except exceptions.UnknownMessageError:
return
managed = ManagedMessage(
self.current_name, msgid_or_symbol, symbol, line, is_disabled
)
self._by_id_managed_msgs.append(managed)
def disable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for a scope."""
self._set_msg_status(
msgid, enable=_False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line)
def disable_next(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for the next line."""
if not line:
raise exceptions.NoLineSuppliedError
self._set_msg_status(
msgid,
enable=_False,
scope=scope,
line=line + 1,
ignore_unknown=ignore_unknown,
)
self._register_by_id_managed_msg(msgid, line + 1)
def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,461 | get_effective_max_line_number | ref | function | max_line_number = self.file_state.get_effective_max_line_number()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,482 | is_message_enabled | def | function | def is_message_enabled(
self,
msg_descr: str,
line: Optional[int] = None,
confidence: Optional[interfaces.Confidence] = None,
) -> bool:
"""Return whether this message is enabled for the current file, line and confidence level.
This function can't be cached right now as the line is the line of
the currently analysed file (self.file_state), if it changes, then the
result for the same msg_descr/line might need to change.
:param msg_descr: Either the msgid or the symbol for a MessageDefinition
:param line: The line of the currently analysed file
:param confidence: The confidence of the message
"""
if self.config.confidence and confidence:
if confidence.name not in self.config.confidence:
return _False
try:
msgids = self.msgs_store.message_id_store.get_active_msgids(msg_descr)
except exceptions.UnknownMessageError:
# The linter checks for messages that are not registered
# due to version mismatch, just treat them as message IDs
# for now.
msgids = [msg_descr]
return any(self._is_one_message_enabled(msgid, line) for msgid in msgids)
def _add_one_message(
self,
message_definition: MessageDefinition,
line: Optional[int],
node: Optional[nodes.NodeNG],
args: Optional[Any],
confidence: Optional[interfaces.Confidence],
col_offset: Optional[int],
end_lineno: Optional[int],
end_col_offset: Optional[int],
) -> None:
"""After various checks have passed a single Message is
passed to the reporter and added to stats
"""
message_definition.check_message_definition(line, node)
# Look up "location" data of node if not yet supplied
if node:
if not line:
line = node.fromlineno
if not col_offset:
col_offset = node.col_offset
if not end_lineno:
end_lineno = node.end_lineno
if not end_col_offset:
end_col_offset = node.end_col_offset
# should this message be displayed
if not self.is_message_enabled(message_definition.msgid, line, confidence):
self.file_state.handle_ignored_message(
self._get_message_state_scope(
message_definition.msgid, line, confidence
),
message_definition.msgid,
line,
)
return
# update stats
msg_cat = MSG_TYPES[message_definition.msgid[0]]
self.msg_status |= MSG_TYPES_STATUS[message_definition.msgid[0]]
self.stats.increase_single_message_count(msg_cat, 1)
self.stats.increase_single_module_message_count(
self.current_name, # type: ignore[arg-type] # Should be removable after https://github.com/PyCQA/pylint/pull/5580
msg_cat,
1,
)
try:
self.stats.by_msg[message_definition.symbol] += 1
except KeyError:
self.stats.by_msg[message_definition.symbol] = 1
# Interpolate arguments into message string
msg = message_definition.msg
if args:
msg %= args
# get module and object
if node is None:
module, obj = self.current_name, ""
abspath = self.current_file
else:
module, obj = utils.get_module_and_frameid(node)
abspath = node.root().file
if abspath is not None:
path = abspath.replace(self.reporter.path_strip_prefix, "", 1)
else:
path = "configuration"
# add the message
self.reporter.handle_message(
Message(
message_definition.msgid,
message_definition.symbol,
MessageLocationTuple(
abspath or "",
path,
module or "",
obj,
line or 1,
col_offset or 0,
end_lineno,
end_col_offset,
),
msg,
confidence,
)
)
def add_message(
self,
msgid: str,
line: Optional[int] = None,
node: Optional[nodes.NodeNG] = None,
args: Optional[Any] = None,
confidence: Optional[interfaces.Confidence] = None,
col_offset: Optional[int] = None,
end_lineno: Optional[int] = None,
end_col_offset: Optional[int] = None,
) -> None:
"""Adds a message given by ID or name.
If provided, the message string is expanded using args.
AST checkers must provide the node argument (but may optionally
provide line if the line number is different), raw and token checkers
must provide the line argument.
"""
if confidence is None:
confidence = interfaces.UNDEFINED
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
self._add_one_message(
message_definition,
line,
node,
args,
confidence,
col_offset,
end_lineno,
end_col_offset,
)
def add_ignored_message(
self,
msgid: str,
line: int,
node: Optional[nodes.NodeNG] = None,
confidence: Optional[interfaces.Confidence] = interfaces.UNDEFINED,
) -> None:
"""Prepares a message to be added to the ignored message storage.
Some checks return early in special cases and never reach add_message(),
even though they would normally issue a message.
This creates false positives for useless-suppression.
This function avoids this by adding those message to the ignored msgs attribute
"""
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
message_definition.check_message_definition(line, node)
self.file_state.handle_ignored_message(
self._get_message_state_scope(
message_definition.msgid, line, confidence
),
message_definition.msgid,
line,
)
# Setting the state (disabled/enabled) of messages and registering them
def _message_symbol(self, msgid: str) -> List[str]:
"""Get the message symbol of the given message id.
Return the original message id if the message does not
exist.
"""
try:
return [md.symbol for md in self.msgs_store.get_message_definitions(msgid)]
except exceptions.UnknownMessageError:
return [msgid]
def _set_one_msg_status(
self, scope: str, msg: MessageDefinition, line: Optional[int], enable: bool
) -> None:
"""Set the status of an individual message."""
if scope == "module":
assert isinstance(line, int) # should always be int inside module scope
self.file_state.set_msg_status(msg, line, enable)
if not enable and msg.symbol != "locally-disabled":
self.add_message(
"locally-disabled", line=line, args=(msg.symbol, msg.msgid)
)
else:
msgs = self._msgs_state
msgs[msg.msgid] = enable
def _get_messages_to_set(
self, msgid: str, enable: bool, ignore_unknown: bool = _False
) -> List[MessageDefinition]:
"""Do some tests and find the actual messages of which the status should be set."""
message_definitions = []
if msgid == "all":
for _msgid in MSG_TYPES:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a category?
category_id = msgid.upper()
if category_id not in MSG_TYPES:
category_id_formatted = MSG_TYPES_LONG.get(category_id)
else:
category_id_formatted = category_id
if category_id_formatted is not None:
for _msgid in self.msgs_store._msgs_by_category[category_id_formatted]:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a checker name?
if msgid.lower() in self._checkers:
for checker in self._checkers[msgid.lower()]:
for _msgid in checker.msgs:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is report id?
if msgid.lower().startswith("rp"):
if enable:
self.enable_report(msgid)
else:
self.disable_report(msgid)
return message_definitions
try:
# msgid is a symbolic or numeric msgid.
message_definitions = self.msgs_store.get_message_definitions(msgid)
except exceptions.UnknownMessageError:
if not ignore_unknown:
raise
return message_definitions
def _set_msg_status(
self,
msgid: str,
enable: bool,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Do some tests and then iterate over message definitions to set state."""
assert scope in {"package", "module"}
message_definitions = self._get_messages_to_set(msgid, enable, ignore_unknown)
for message_definition in message_definitions:
self._set_one_msg_status(scope, message_definition, line, enable)
# sync configuration object
self.config.enable = []
self.config.disable = []
for mid, val in self._msgs_state.items():
if val:
self.config.enable.append(self._message_symbol(mid))
else:
self.config.disable.append(self._message_symbol(mid))
def _register_by_id_managed_msg(
self, msgid_or_symbol: str, line: Optional[int], is_disabled: bool = _True
) -> None:
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid.
"""
if msgid_or_symbol[1:].isdigit():
try:
symbol = self.msgs_store.message_id_store.get_symbol(
msgid=msgid_or_symbol
)
except exceptions.UnknownMessageError:
return
managed = ManagedMessage(
self.current_name, msgid_or_symbol, symbol, line, is_disabled
)
self._by_id_managed_msgs.append(managed)
def disable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for a scope."""
self._set_msg_status(
msgid, enable=_False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line)
def disable_next(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for the next line."""
if not line:
raise exceptions.NoLineSuppliedError
self._set_msg_status(
msgid,
enable=_False,
scope=scope,
line=line + 1,
ignore_unknown=ignore_unknown,
)
self._register_by_id_managed_msg(msgid, line + 1)
def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,502 | get_active_msgids | ref | function | msgids = self.msgs_store.message_id_store.get_active_msgids(msg_descr)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,508 | _is_one_message_enabled | ref | function | return any(self._is_one_message_enabled(msgid, line) for msgid in msgids)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,510 | _add_one_message | def | function | def _add_one_message(
self,
message_definition: MessageDefinition,
line: Optional[int],
node: Optional[nodes.NodeNG],
args: Optional[Any],
confidence: Optional[interfaces.Confidence],
col_offset: Optional[int],
end_lineno: Optional[int],
end_col_offset: Optional[int],
) -> None:
"""After various checks have passed a single Message is
passed to the reporter and added to stats
"""
message_definition.check_message_definition(line, node)
# Look up "location" data of node if not yet supplied
if node:
if not line:
line = node.fromlineno
if not col_offset:
col_offset = node.col_offset
if not end_lineno:
end_lineno = node.end_lineno
if not end_col_offset:
end_col_offset = node.end_col_offset
# should this message be displayed
if not self.is_message_enabled(message_definition.msgid, line, confidence):
self.file_state.handle_ignored_message(
self._get_message_state_scope(
message_definition.msgid, line, confidence
),
message_definition.msgid,
line,
)
return
# update stats
msg_cat = MSG_TYPES[message_definition.msgid[0]]
self.msg_status |= MSG_TYPES_STATUS[message_definition.msgid[0]]
self.stats.increase_single_message_count(msg_cat, 1)
self.stats.increase_single_module_message_count(
self.current_name, # type: ignore[arg-type] # Should be removable after https://github.com/PyCQA/pylint/pull/5580
msg_cat,
1,
)
try:
self.stats.by_msg[message_definition.symbol] += 1
except KeyError:
self.stats.by_msg[message_definition.symbol] = 1
# Interpolate arguments into message string
msg = message_definition.msg
if args:
msg %= args
# get module and object
if node is None:
module, obj = self.current_name, ""
abspath = self.current_file
else:
module, obj = utils.get_module_and_frameid(node)
abspath = node.root().file
if abspath is not None:
path = abspath.replace(self.reporter.path_strip_prefix, "", 1)
else:
path = "configuration"
# add the message
self.reporter.handle_message(
Message(
message_definition.msgid,
message_definition.symbol,
MessageLocationTuple(
abspath or "",
path,
module or "",
obj,
line or 1,
col_offset or 0,
end_lineno,
end_col_offset,
),
msg,
confidence,
)
)
def add_message(
self,
msgid: str,
line: Optional[int] = None,
node: Optional[nodes.NodeNG] = None,
args: Optional[Any] = None,
confidence: Optional[interfaces.Confidence] = None,
col_offset: Optional[int] = None,
end_lineno: Optional[int] = None,
end_col_offset: Optional[int] = None,
) -> None:
"""Adds a message given by ID or name.
If provided, the message string is expanded using args.
AST checkers must provide the node argument (but may optionally
provide line if the line number is different), raw and token checkers
must provide the line argument.
"""
if confidence is None:
confidence = interfaces.UNDEFINED
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
self._add_one_message(
message_definition,
line,
node,
args,
confidence,
col_offset,
end_lineno,
end_col_offset,
)
def add_ignored_message(
self,
msgid: str,
line: int,
node: Optional[nodes.NodeNG] = None,
confidence: Optional[interfaces.Confidence] = interfaces.UNDEFINED,
) -> None:
"""Prepares a message to be added to the ignored message storage.
Some checks return early in special cases and never reach add_message(),
even though they would normally issue a message.
This creates false positives for useless-suppression.
This function avoids this by adding those message to the ignored msgs attribute
"""
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
message_definition.check_message_definition(line, node)
self.file_state.handle_ignored_message(
self._get_message_state_scope(
message_definition.msgid, line, confidence
),
message_definition.msgid,
line,
)
# Setting the state (disabled/enabled) of messages and registering them
def _message_symbol(self, msgid: str) -> List[str]:
"""Get the message symbol of the given message id.
Return the original message id if the message does not
exist.
"""
try:
return [md.symbol for md in self.msgs_store.get_message_definitions(msgid)]
except exceptions.UnknownMessageError:
return [msgid]
def _set_one_msg_status(
self, scope: str, msg: MessageDefinition, line: Optional[int], enable: bool
) -> None:
"""Set the status of an individual message."""
if scope == "module":
assert isinstance(line, int) # should always be int inside module scope
self.file_state.set_msg_status(msg, line, enable)
if not enable and msg.symbol != "locally-disabled":
self.add_message(
"locally-disabled", line=line, args=(msg.symbol, msg.msgid)
)
else:
msgs = self._msgs_state
msgs[msg.msgid] = enable
def _get_messages_to_set(
self, msgid: str, enable: bool, ignore_unknown: bool = _False
) -> List[MessageDefinition]:
"""Do some tests and find the actual messages of which the status should be set."""
message_definitions = []
if msgid == "all":
for _msgid in MSG_TYPES:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a category?
category_id = msgid.upper()
if category_id not in MSG_TYPES:
category_id_formatted = MSG_TYPES_LONG.get(category_id)
else:
category_id_formatted = category_id
if category_id_formatted is not None:
for _msgid in self.msgs_store._msgs_by_category[category_id_formatted]:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a checker name?
if msgid.lower() in self._checkers:
for checker in self._checkers[msgid.lower()]:
for _msgid in checker.msgs:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is report id?
if msgid.lower().startswith("rp"):
if enable:
self.enable_report(msgid)
else:
self.disable_report(msgid)
return message_definitions
try:
# msgid is a symbolic or numeric msgid.
message_definitions = self.msgs_store.get_message_definitions(msgid)
except exceptions.UnknownMessageError:
if not ignore_unknown:
raise
return message_definitions
def _set_msg_status(
self,
msgid: str,
enable: bool,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Do some tests and then iterate over message definitions to set state."""
assert scope in {"package", "module"}
message_definitions = self._get_messages_to_set(msgid, enable, ignore_unknown)
for message_definition in message_definitions:
self._set_one_msg_status(scope, message_definition, line, enable)
# sync configuration object
self.config.enable = []
self.config.disable = []
for mid, val in self._msgs_state.items():
if val:
self.config.enable.append(self._message_symbol(mid))
else:
self.config.disable.append(self._message_symbol(mid))
def _register_by_id_managed_msg(
self, msgid_or_symbol: str, line: Optional[int], is_disabled: bool = _True
) -> None:
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid.
"""
if msgid_or_symbol[1:].isdigit():
try:
symbol = self.msgs_store.message_id_store.get_symbol(
msgid=msgid_or_symbol
)
except exceptions.UnknownMessageError:
return
managed = ManagedMessage(
self.current_name, msgid_or_symbol, symbol, line, is_disabled
)
self._by_id_managed_msgs.append(managed)
def disable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for a scope."""
self._set_msg_status(
msgid, enable=_False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line)
def disable_next(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for the next line."""
if not line:
raise exceptions.NoLineSuppliedError
self._set_msg_status(
msgid,
enable=_False,
scope=scope,
line=line + 1,
ignore_unknown=ignore_unknown,
)
self._register_by_id_managed_msg(msgid, line + 1)
def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,524 | check_message_definition | ref | function | message_definition.check_message_definition(line, node)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,538 | is_message_enabled | ref | function | if not self.is_message_enabled(message_definition.msgid, line, confidence):
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,539 | handle_ignored_message | ref | function | self.file_state.handle_ignored_message(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,540 | _get_message_state_scope | ref | function | self._get_message_state_scope(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,551 | increase_single_message_count | ref | function | self.stats.increase_single_message_count(msg_cat, 1)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,552 | increase_single_module_message_count | ref | function | self.stats.increase_single_module_message_count(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,570 | get_module_and_frameid | ref | function | module, obj = utils.get_module_and_frameid(node)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,571 | root | ref | function | abspath = node.root().file
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,577 | handle_message | ref | function | self.reporter.handle_message(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,578 | Message | ref | function | Message(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,581 | MessageLocationTuple | ref | function | MessageLocationTuple(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,596 | add_message | def | function | def add_message(
self,
msgid: str,
line: Optional[int] = None,
node: Optional[nodes.NodeNG] = None,
args: Optional[Any] = None,
confidence: Optional[interfaces.Confidence] = None,
col_offset: Optional[int] = None,
end_lineno: Optional[int] = None,
end_col_offset: Optional[int] = None,
) -> None:
"""Adds a message given by ID or name.
If provided, the message string is expanded using args.
AST checkers must provide the node argument (but may optionally
provide line if the line number is different), raw and token checkers
must provide the line argument.
"""
if confidence is None:
confidence = interfaces.UNDEFINED
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
self._add_one_message(
message_definition,
line,
node,
args,
confidence,
col_offset,
end_lineno,
end_col_offset,
)
def add_ignored_message(
self,
msgid: str,
line: int,
node: Optional[nodes.NodeNG] = None,
confidence: Optional[interfaces.Confidence] = interfaces.UNDEFINED,
) -> None:
"""Prepares a message to be added to the ignored message storage.
Some checks return early in special cases and never reach add_message(),
even though they would normally issue a message.
This creates false positives for useless-suppression.
This function avoids this by adding those message to the ignored msgs attribute
"""
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
message_definition.check_message_definition(line, node)
self.file_state.handle_ignored_message(
self._get_message_state_scope(
message_definition.msgid, line, confidence
),
message_definition.msgid,
line,
)
# Setting the state (disabled/enabled) of messages and registering them
def _message_symbol(self, msgid: str) -> List[str]:
"""Get the message symbol of the given message id.
Return the original message id if the message does not
exist.
"""
try:
return [md.symbol for md in self.msgs_store.get_message_definitions(msgid)]
except exceptions.UnknownMessageError:
return [msgid]
def _set_one_msg_status(
self, scope: str, msg: MessageDefinition, line: Optional[int], enable: bool
) -> None:
"""Set the status of an individual message."""
if scope == "module":
assert isinstance(line, int) # should always be int inside module scope
self.file_state.set_msg_status(msg, line, enable)
if not enable and msg.symbol != "locally-disabled":
self.add_message(
"locally-disabled", line=line, args=(msg.symbol, msg.msgid)
)
else:
msgs = self._msgs_state
msgs[msg.msgid] = enable
def _get_messages_to_set(
self, msgid: str, enable: bool, ignore_unknown: bool = _False
) -> List[MessageDefinition]:
"""Do some tests and find the actual messages of which the status should be set."""
message_definitions = []
if msgid == "all":
for _msgid in MSG_TYPES:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a category?
category_id = msgid.upper()
if category_id not in MSG_TYPES:
category_id_formatted = MSG_TYPES_LONG.get(category_id)
else:
category_id_formatted = category_id
if category_id_formatted is not None:
for _msgid in self.msgs_store._msgs_by_category[category_id_formatted]:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a checker name?
if msgid.lower() in self._checkers:
for checker in self._checkers[msgid.lower()]:
for _msgid in checker.msgs:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is report id?
if msgid.lower().startswith("rp"):
if enable:
self.enable_report(msgid)
else:
self.disable_report(msgid)
return message_definitions
try:
# msgid is a symbolic or numeric msgid.
message_definitions = self.msgs_store.get_message_definitions(msgid)
except exceptions.UnknownMessageError:
if not ignore_unknown:
raise
return message_definitions
def _set_msg_status(
self,
msgid: str,
enable: bool,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Do some tests and then iterate over message definitions to set state."""
assert scope in {"package", "module"}
message_definitions = self._get_messages_to_set(msgid, enable, ignore_unknown)
for message_definition in message_definitions:
self._set_one_msg_status(scope, message_definition, line, enable)
# sync configuration object
self.config.enable = []
self.config.disable = []
for mid, val in self._msgs_state.items():
if val:
self.config.enable.append(self._message_symbol(mid))
else:
self.config.disable.append(self._message_symbol(mid))
def _register_by_id_managed_msg(
self, msgid_or_symbol: str, line: Optional[int], is_disabled: bool = _True
) -> None:
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid.
"""
if msgid_or_symbol[1:].isdigit():
try:
symbol = self.msgs_store.message_id_store.get_symbol(
msgid=msgid_or_symbol
)
except exceptions.UnknownMessageError:
return
managed = ManagedMessage(
self.current_name, msgid_or_symbol, symbol, line, is_disabled
)
self._by_id_managed_msgs.append(managed)
def disable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for a scope."""
self._set_msg_status(
msgid, enable=_False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line)
def disable_next(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for the next line."""
if not line:
raise exceptions.NoLineSuppliedError
self._set_msg_status(
msgid,
enable=_False,
scope=scope,
line=line + 1,
ignore_unknown=ignore_unknown,
)
self._register_by_id_managed_msg(msgid, line + 1)
def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,617 | get_message_definitions | ref | function | message_definitions = self.msgs_store.get_message_definitions(msgid)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,619 | _add_one_message | ref | function | self._add_one_message(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,630 | add_ignored_message | def | function | def add_ignored_message(
self,
msgid: str,
line: int,
node: Optional[nodes.NodeNG] = None,
confidence: Optional[interfaces.Confidence] = interfaces.UNDEFINED,
) -> None:
"""Prepares a message to be added to the ignored message storage.
Some checks return early in special cases and never reach add_message(),
even though they would normally issue a message.
This creates false positives for useless-suppression.
This function avoids this by adding those message to the ignored msgs attribute
"""
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_definition in message_definitions:
message_definition.check_message_definition(line, node)
self.file_state.handle_ignored_message(
self._get_message_state_scope(
message_definition.msgid, line, confidence
),
message_definition.msgid,
line,
)
# Setting the state (disabled/enabled) of messages and registering them
def _message_symbol(self, msgid: str) -> List[str]:
"""Get the message symbol of the given message id.
Return the original message id if the message does not
exist.
"""
try:
return [md.symbol for md in self.msgs_store.get_message_definitions(msgid)]
except exceptions.UnknownMessageError:
return [msgid]
def _set_one_msg_status(
self, scope: str, msg: MessageDefinition, line: Optional[int], enable: bool
) -> None:
"""Set the status of an individual message."""
if scope == "module":
assert isinstance(line, int) # should always be int inside module scope
self.file_state.set_msg_status(msg, line, enable)
if not enable and msg.symbol != "locally-disabled":
self.add_message(
"locally-disabled", line=line, args=(msg.symbol, msg.msgid)
)
else:
msgs = self._msgs_state
msgs[msg.msgid] = enable
def _get_messages_to_set(
self, msgid: str, enable: bool, ignore_unknown: bool = _False
) -> List[MessageDefinition]:
"""Do some tests and find the actual messages of which the status should be set."""
message_definitions = []
if msgid == "all":
for _msgid in MSG_TYPES:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a category?
category_id = msgid.upper()
if category_id not in MSG_TYPES:
category_id_formatted = MSG_TYPES_LONG.get(category_id)
else:
category_id_formatted = category_id
if category_id_formatted is not None:
for _msgid in self.msgs_store._msgs_by_category[category_id_formatted]:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a checker name?
if msgid.lower() in self._checkers:
for checker in self._checkers[msgid.lower()]:
for _msgid in checker.msgs:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is report id?
if msgid.lower().startswith("rp"):
if enable:
self.enable_report(msgid)
else:
self.disable_report(msgid)
return message_definitions
try:
# msgid is a symbolic or numeric msgid.
message_definitions = self.msgs_store.get_message_definitions(msgid)
except exceptions.UnknownMessageError:
if not ignore_unknown:
raise
return message_definitions
def _set_msg_status(
self,
msgid: str,
enable: bool,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Do some tests and then iterate over message definitions to set state."""
assert scope in {"package", "module"}
message_definitions = self._get_messages_to_set(msgid, enable, ignore_unknown)
for message_definition in message_definitions:
self._set_one_msg_status(scope, message_definition, line, enable)
# sync configuration object
self.config.enable = []
self.config.disable = []
for mid, val in self._msgs_state.items():
if val:
self.config.enable.append(self._message_symbol(mid))
else:
self.config.disable.append(self._message_symbol(mid))
def _register_by_id_managed_msg(
self, msgid_or_symbol: str, line: Optional[int], is_disabled: bool = _True
) -> None:
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid.
"""
if msgid_or_symbol[1:].isdigit():
try:
symbol = self.msgs_store.message_id_store.get_symbol(
msgid=msgid_or_symbol
)
except exceptions.UnknownMessageError:
return
managed = ManagedMessage(
self.current_name, msgid_or_symbol, symbol, line, is_disabled
)
self._by_id_managed_msgs.append(managed)
def disable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for a scope."""
self._set_msg_status(
msgid, enable=_False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line)
def disable_next(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for the next line."""
if not line:
raise exceptions.NoLineSuppliedError
self._set_msg_status(
msgid,
enable=_False,
scope=scope,
line=line + 1,
ignore_unknown=ignore_unknown,
)
self._register_by_id_managed_msg(msgid, line + 1)
def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,644 | get_message_definitions | ref | function | message_definitions = self.msgs_store.get_message_definitions(msgid)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,646 | check_message_definition | ref | function | message_definition.check_message_definition(line, node)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,647 | handle_ignored_message | ref | function | self.file_state.handle_ignored_message(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,648 | _get_message_state_scope | ref | function | self._get_message_state_scope(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,657 | _message_symbol | def | function | def _message_symbol(self, msgid: str) -> List[str]:
"""Get the message symbol of the given message id.
Return the original message id if the message does not
exist.
"""
try:
return [md.symbol for md in self.msgs_store.get_message_definitions(msgid)]
except exceptions.UnknownMessageError:
return [msgid]
def _set_one_msg_status(
self, scope: str, msg: MessageDefinition, line: Optional[int], enable: bool
) -> None:
"""Set the status of an individual message."""
if scope == "module":
assert isinstance(line, int) # should always be int inside module scope
self.file_state.set_msg_status(msg, line, enable)
if not enable and msg.symbol != "locally-disabled":
self.add_message(
"locally-disabled", line=line, args=(msg.symbol, msg.msgid)
)
else:
msgs = self._msgs_state
msgs[msg.msgid] = enable
def _get_messages_to_set(
self, msgid: str, enable: bool, ignore_unknown: bool = _False
) -> List[MessageDefinition]:
"""Do some tests and find the actual messages of which the status should be set."""
message_definitions = []
if msgid == "all":
for _msgid in MSG_TYPES:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a category?
category_id = msgid.upper()
if category_id not in MSG_TYPES:
category_id_formatted = MSG_TYPES_LONG.get(category_id)
else:
category_id_formatted = category_id
if category_id_formatted is not None:
for _msgid in self.msgs_store._msgs_by_category[category_id_formatted]:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a checker name?
if msgid.lower() in self._checkers:
for checker in self._checkers[msgid.lower()]:
for _msgid in checker.msgs:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is report id?
if msgid.lower().startswith("rp"):
if enable:
self.enable_report(msgid)
else:
self.disable_report(msgid)
return message_definitions
try:
# msgid is a symbolic or numeric msgid.
message_definitions = self.msgs_store.get_message_definitions(msgid)
except exceptions.UnknownMessageError:
if not ignore_unknown:
raise
return message_definitions
def _set_msg_status(
self,
msgid: str,
enable: bool,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Do some tests and then iterate over message definitions to set state."""
assert scope in {"package", "module"}
message_definitions = self._get_messages_to_set(msgid, enable, ignore_unknown)
for message_definition in message_definitions:
self._set_one_msg_status(scope, message_definition, line, enable)
# sync configuration object
self.config.enable = []
self.config.disable = []
for mid, val in self._msgs_state.items():
if val:
self.config.enable.append(self._message_symbol(mid))
else:
self.config.disable.append(self._message_symbol(mid))
def _register_by_id_managed_msg(
self, msgid_or_symbol: str, line: Optional[int], is_disabled: bool = _True
) -> None:
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid.
"""
if msgid_or_symbol[1:].isdigit():
try:
symbol = self.msgs_store.message_id_store.get_symbol(
msgid=msgid_or_symbol
)
except exceptions.UnknownMessageError:
return
managed = ManagedMessage(
self.current_name, msgid_or_symbol, symbol, line, is_disabled
)
self._by_id_managed_msgs.append(managed)
def disable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for a scope."""
self._set_msg_status(
msgid, enable=_False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line)
def disable_next(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for the next line."""
if not line:
raise exceptions.NoLineSuppliedError
self._set_msg_status(
msgid,
enable=_False,
scope=scope,
line=line + 1,
ignore_unknown=ignore_unknown,
)
self._register_by_id_managed_msg(msgid, line + 1)
def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,664 | get_message_definitions | ref | function | return [md.symbol for md in self.msgs_store.get_message_definitions(msgid)]
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,668 | _set_one_msg_status | def | function | def _set_one_msg_status(
self, scope: str, msg: MessageDefinition, line: Optional[int], enable: bool
) -> None:
"""Set the status of an individual message."""
if scope == "module":
assert isinstance(line, int) # should always be int inside module scope
self.file_state.set_msg_status(msg, line, enable)
if not enable and msg.symbol != "locally-disabled":
self.add_message(
"locally-disabled", line=line, args=(msg.symbol, msg.msgid)
)
else:
msgs = self._msgs_state
msgs[msg.msgid] = enable
def _get_messages_to_set(
self, msgid: str, enable: bool, ignore_unknown: bool = _False
) -> List[MessageDefinition]:
"""Do some tests and find the actual messages of which the status should be set."""
message_definitions = []
if msgid == "all":
for _msgid in MSG_TYPES:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a category?
category_id = msgid.upper()
if category_id not in MSG_TYPES:
category_id_formatted = MSG_TYPES_LONG.get(category_id)
else:
category_id_formatted = category_id
if category_id_formatted is not None:
for _msgid in self.msgs_store._msgs_by_category[category_id_formatted]:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a checker name?
if msgid.lower() in self._checkers:
for checker in self._checkers[msgid.lower()]:
for _msgid in checker.msgs:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is report id?
if msgid.lower().startswith("rp"):
if enable:
self.enable_report(msgid)
else:
self.disable_report(msgid)
return message_definitions
try:
# msgid is a symbolic or numeric msgid.
message_definitions = self.msgs_store.get_message_definitions(msgid)
except exceptions.UnknownMessageError:
if not ignore_unknown:
raise
return message_definitions
def _set_msg_status(
self,
msgid: str,
enable: bool,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Do some tests and then iterate over message definitions to set state."""
assert scope in {"package", "module"}
message_definitions = self._get_messages_to_set(msgid, enable, ignore_unknown)
for message_definition in message_definitions:
self._set_one_msg_status(scope, message_definition, line, enable)
# sync configuration object
self.config.enable = []
self.config.disable = []
for mid, val in self._msgs_state.items():
if val:
self.config.enable.append(self._message_symbol(mid))
else:
self.config.disable.append(self._message_symbol(mid))
def _register_by_id_managed_msg(
self, msgid_or_symbol: str, line: Optional[int], is_disabled: bool = _True
) -> None:
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid.
"""
if msgid_or_symbol[1:].isdigit():
try:
symbol = self.msgs_store.message_id_store.get_symbol(
msgid=msgid_or_symbol
)
except exceptions.UnknownMessageError:
return
managed = ManagedMessage(
self.current_name, msgid_or_symbol, symbol, line, is_disabled
)
self._by_id_managed_msgs.append(managed)
def disable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for a scope."""
self._set_msg_status(
msgid, enable=_False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line)
def disable_next(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for the next line."""
if not line:
raise exceptions.NoLineSuppliedError
self._set_msg_status(
msgid,
enable=_False,
scope=scope,
line=line + 1,
ignore_unknown=ignore_unknown,
)
self._register_by_id_managed_msg(msgid, line + 1)
def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,675 | set_msg_status | ref | function | self.file_state.set_msg_status(msg, line, enable)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,677 | add_message | ref | function | self.add_message(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,684 | _get_messages_to_set | def | function | def _get_messages_to_set(
self, msgid: str, enable: bool, ignore_unknown: bool = _False
) -> List[MessageDefinition]:
"""Do some tests and find the actual messages of which the status should be set."""
message_definitions = []
if msgid == "all":
for _msgid in MSG_TYPES:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a category?
category_id = msgid.upper()
if category_id not in MSG_TYPES:
category_id_formatted = MSG_TYPES_LONG.get(category_id)
else:
category_id_formatted = category_id
if category_id_formatted is not None:
for _msgid in self.msgs_store._msgs_by_category[category_id_formatted]:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is a checker name?
if msgid.lower() in self._checkers:
for checker in self._checkers[msgid.lower()]:
for _msgid in checker.msgs:
message_definitions.extend(
self._get_messages_to_set(_msgid, enable, ignore_unknown)
)
return message_definitions
# msgid is report id?
if msgid.lower().startswith("rp"):
if enable:
self.enable_report(msgid)
else:
self.disable_report(msgid)
return message_definitions
try:
# msgid is a symbolic or numeric msgid.
message_definitions = self.msgs_store.get_message_definitions(msgid)
except exceptions.UnknownMessageError:
if not ignore_unknown:
raise
return message_definitions
def _set_msg_status(
self,
msgid: str,
enable: bool,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Do some tests and then iterate over message definitions to set state."""
assert scope in {"package", "module"}
message_definitions = self._get_messages_to_set(msgid, enable, ignore_unknown)
for message_definition in message_definitions:
self._set_one_msg_status(scope, message_definition, line, enable)
# sync configuration object
self.config.enable = []
self.config.disable = []
for mid, val in self._msgs_state.items():
if val:
self.config.enable.append(self._message_symbol(mid))
else:
self.config.disable.append(self._message_symbol(mid))
def _register_by_id_managed_msg(
self, msgid_or_symbol: str, line: Optional[int], is_disabled: bool = _True
) -> None:
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid.
"""
if msgid_or_symbol[1:].isdigit():
try:
symbol = self.msgs_store.message_id_store.get_symbol(
msgid=msgid_or_symbol
)
except exceptions.UnknownMessageError:
return
managed = ManagedMessage(
self.current_name, msgid_or_symbol, symbol, line, is_disabled
)
self._by_id_managed_msgs.append(managed)
def disable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for a scope."""
self._set_msg_status(
msgid, enable=_False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line)
def disable_next(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for the next line."""
if not line:
raise exceptions.NoLineSuppliedError
self._set_msg_status(
msgid,
enable=_False,
scope=scope,
line=line + 1,
ignore_unknown=ignore_unknown,
)
self._register_by_id_managed_msg(msgid, line + 1)
def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,692 | _get_messages_to_set | ref | function | self._get_messages_to_set(_msgid, enable, ignore_unknown)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,705 | _get_messages_to_set | ref | function | self._get_messages_to_set(_msgid, enable, ignore_unknown)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,714 | _get_messages_to_set | ref | function | self._get_messages_to_set(_msgid, enable, ignore_unknown)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,721 | enable_report | ref | function | self.enable_report(msgid)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,723 | disable_report | ref | function | self.disable_report(msgid)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,728 | get_message_definitions | ref | function | message_definitions = self.msgs_store.get_message_definitions(msgid)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,734 | _set_msg_status | def | function | def _set_msg_status(
self,
msgid: str,
enable: bool,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Do some tests and then iterate over message definitions to set state."""
assert scope in {"package", "module"}
message_definitions = self._get_messages_to_set(msgid, enable, ignore_unknown)
for message_definition in message_definitions:
self._set_one_msg_status(scope, message_definition, line, enable)
# sync configuration object
self.config.enable = []
self.config.disable = []
for mid, val in self._msgs_state.items():
if val:
self.config.enable.append(self._message_symbol(mid))
else:
self.config.disable.append(self._message_symbol(mid))
def _register_by_id_managed_msg(
self, msgid_or_symbol: str, line: Optional[int], is_disabled: bool = _True
) -> None:
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid.
"""
if msgid_or_symbol[1:].isdigit():
try:
symbol = self.msgs_store.message_id_store.get_symbol(
msgid=msgid_or_symbol
)
except exceptions.UnknownMessageError:
return
managed = ManagedMessage(
self.current_name, msgid_or_symbol, symbol, line, is_disabled
)
self._by_id_managed_msgs.append(managed)
def disable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for a scope."""
self._set_msg_status(
msgid, enable=_False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line)
def disable_next(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for the next line."""
if not line:
raise exceptions.NoLineSuppliedError
self._set_msg_status(
msgid,
enable=_False,
scope=scope,
line=line + 1,
ignore_unknown=ignore_unknown,
)
self._register_by_id_managed_msg(msgid, line + 1)
def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,745 | _get_messages_to_set | ref | function | message_definitions = self._get_messages_to_set(msgid, enable, ignore_unknown)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,748 | _set_one_msg_status | ref | function | self._set_one_msg_status(scope, message_definition, line, enable)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,755 | _message_symbol | ref | function | self.config.enable.append(self._message_symbol(mid))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,757 | _message_symbol | ref | function | self.config.disable.append(self._message_symbol(mid))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,759 | _register_by_id_managed_msg | def | function | def _register_by_id_managed_msg(
self, msgid_or_symbol: str, line: Optional[int], is_disabled: bool = _True
) -> None:
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid.
"""
if msgid_or_symbol[1:].isdigit():
try:
symbol = self.msgs_store.message_id_store.get_symbol(
msgid=msgid_or_symbol
)
except exceptions.UnknownMessageError:
return
managed = ManagedMessage(
self.current_name, msgid_or_symbol, symbol, line, is_disabled
)
self._by_id_managed_msgs.append(managed)
def disable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for a scope."""
self._set_msg_status(
msgid, enable=_False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line)
def disable_next(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for the next line."""
if not line:
raise exceptions.NoLineSuppliedError
self._set_msg_status(
msgid,
enable=_False,
scope=scope,
line=line + 1,
ignore_unknown=ignore_unknown,
)
self._register_by_id_managed_msg(msgid, line + 1)
def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,767 | get_symbol | ref | function | symbol = self.msgs_store.message_id_store.get_symbol(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,772 | ManagedMessage | ref | function | managed = ManagedMessage(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,777 | disable | def | function | def disable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for a scope."""
self._set_msg_status(
msgid, enable=_False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line)
def disable_next(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for the next line."""
if not line:
raise exceptions.NoLineSuppliedError
self._set_msg_status(
msgid,
enable=_False,
scope=scope,
line=line + 1,
ignore_unknown=ignore_unknown,
)
self._register_by_id_managed_msg(msgid, line + 1)
def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,785 | _set_msg_status | ref | function | self._set_msg_status(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,788 | _register_by_id_managed_msg | ref | function | self._register_by_id_managed_msg(msgid, line)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,790 | disable_next | def | function | def disable_next(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Disable a message for the next line."""
if not line:
raise exceptions.NoLineSuppliedError
self._set_msg_status(
msgid,
enable=_False,
scope=scope,
line=line + 1,
ignore_unknown=ignore_unknown,
)
self._register_by_id_managed_msg(msgid, line + 1)
def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,800 | _set_msg_status | ref | function | self._set_msg_status(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,807 | _register_by_id_managed_msg | ref | function | self._register_by_id_managed_msg(msgid, line + 1)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,809 | enable | def | function | def enable(
self,
msgid: str,
scope: str = "package",
line: Optional[int] = None,
ignore_unknown: bool = _False,
) -> None:
"""Enable a message for a scope."""
self._set_msg_status(
msgid, enable=_True, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line, is_disabled=_False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,817 | _set_msg_status | ref | function | self._set_msg_status(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/pylinter.py | pylint/lint/pylinter.py | 1,820 | _register_by_id_managed_msg | ref | function | self._register_by_id_managed_msg(msgid, line, is_disabled=False)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/report_functions.py | pylint/lint/report_functions.py | 11 | report_total_messages_stats | def | function | def report_total_messages_stats(
sect,
stats: LinterStats,
previous_stats: LinterStats,
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/report_functions.py | pylint/lint/report_functions.py | 18 | table_lines_from_stats | ref | function | lines += checkers.table_lines_from_stats(stats, previous_stats, "message_types")
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/report_functions.py | pylint/lint/report_functions.py | 19 | Table | ref | function | sect.append(Table(children=lines, cols=4, rheaders=1))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/report_functions.py | pylint/lint/report_functions.py | 22 | report_messages_stats | def | function | def report_messages_stats(
sect,
stats: LinterStats,
_: LinterStats,
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/report_functions.py | pylint/lint/report_functions.py | 38 | Table | ref | function | sect.append(Table(children=lines, cols=2, rheaders=1))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/report_functions.py | pylint/lint/report_functions.py | 41 | report_messages_by_module_stats | def | function | def report_messages_by_module_stats(
sect,
stats: LinterStats,
_: LinterStats,
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/report_functions.py | pylint/lint/report_functions.py | 50 | EmptyReportError | ref | function | raise exceptions.EmptyReportError()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/report_functions.py | pylint/lint/report_functions.py | 55 | get_global_message_count | ref | function | total = stats.get_global_message_count(m_type)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/report_functions.py | pylint/lint/report_functions.py | 57 | get_module_message_count | ref | function | mod_total = stats.get_module_message_count(module, m_type)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/report_functions.py | pylint/lint/report_functions.py | 82 | EmptyReportError | ref | function | raise exceptions.EmptyReportError()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/report_functions.py | pylint/lint/report_functions.py | 83 | Table | ref | function | sect.append(Table(children=lines, cols=5, rheaders=1))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 21 | _cpu_count | def | function | def _cpu_count() -> int:
"""Use sched_affinity if available for virtualized or containerized environments."""
sched_getaffinity = getattr(os, "sched_getaffinity", None)
# pylint: disable=not-callable,using-constant-test,useless-suppression
if sched_getaffinity:
return len(sched_getaffinity(0))
if multiprocessing:
return multiprocessing.cpu_count()
return 1
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 32 | cb_list_extensions | def | function | def cb_list_extensions(option, optname, value, parser):
"""List all the extensions under pylint.extensions."""
for filename in os.listdir(os.path.dirname(extensions.__file__)):
if filename.endswith(".py") and not filename.startswith("_"):
extension_name, _, _ = filename.partition(".")
print(f"pylint.extensions.{extension_name}")
sys.exit(0)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 35 | dirname | ref | function | for filename in os.listdir(os.path.dirname(extensions.__file__)):
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 42 | cb_list_confidence_levels | def | function | def cb_list_confidence_levels(option, optname, value, parser):
for level in interfaces.CONFIDENCE_LEVELS:
print(f"%-18s: {level}")
sys.exit(0)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 48 | cb_init_hook | def | function | def cb_init_hook(optname, value):
"""Execute arbitrary code to set 'sys.path' for instance."""
exec(value) # pylint: disable=exec-used
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 56 | Run | def | class | _return_one __init__ version_asked cb_set_rcfile cb_set_output cb_add_plugins cb_error_mode cb_generate_config cb_generate_manpage cb_help_message cb_full_documentation cb_list_messages cb_list_messages_enabled cb_list_groups cb_verbose_mode cb_enable_all_extensions |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 69 | _return_one | def | function | def _return_one(*args): # pylint: disable=unused-argument
return 1
def __init__(
self,
args,
reporter=None,
exit=_True,
do_exit=UNUSED_PARAM_SENTINEL,
): # pylint: disable=redefined-builtin
self._rcfile = None
self._output = None
self._version_asked = _False
self._plugins = []
self.verbose = None
try:
preprocess_options(
args,
{
# option: (callback, takearg)
"version": (self.version_asked, _False),
"init-hook": (cb_init_hook, _True),
"rcfile": (self.cb_set_rcfile, _True),
"load-plugins": (self.cb_add_plugins, _True),
"enable-all-extensions": (self.cb_enable_all_extensions, _False),
"verbose": (self.cb_verbose_mode, _False),
"output": (self.cb_set_output, _True),
},
)
except ArgumentPreprocessingError as ex:
print(ex, file=sys.stderr)
sys.exit(32)
self.linter = linter = self.LinterClass(
(
(
"rcfile",
{
"action": "callback",
"callback": Run._return_one,
"group": "Commands",
"type": "string",
"metavar": "<file>",
"help": "Specify a configuration file to load.",
},
),
(
"output",
{
"action": "callback",
"callback": Run._return_one,
"group": "Commands",
"type": "string",
"metavar": "<file>",
"help": "Specify an output file.",
},
),
(
"init-hook",
{
"action": "callback",
"callback": Run._return_one,
"type": "string",
"metavar": "<code>",
"level": 1,
"help": "Python code to execute, usually for sys.path "
"manipulation such as pygtk.require().",
},
),
(
"help-msg",
{
"action": "callback",
"type": "string",
"metavar": "<msg-id>",
"callback": self.cb_help_message,
"group": "Commands",
"help": "Display a help message for the given message id and "
"exit. The value may be a comma separated list of message ids.",
},
),
(
"list-msgs",
{
"action": "callback",
"metavar": "<msg-id>",
"callback": self.cb_list_messages,
"group": "Commands",
"level": 1,
"help": "Display a list of all pylint's messages divided by whether "
"they are emittable with the given interpreter.",
},
),
(
"list-msgs-enabled",
{
"action": "callback",
"metavar": "<msg-id>",
"callback": self.cb_list_messages_enabled,
"group": "Commands",
"level": 1,
"help": "Display a list of what messages are enabled, "
"disabled and non-emittable with the given configuration.",
},
),
(
"list-groups",
{
"action": "callback",
"metavar": "<msg-id>",
"callback": self.cb_list_groups,
"group": "Commands",
"level": 1,
"help": "List pylint's message groups.",
},
),
(
"list-conf-levels",
{
"action": "callback",
"callback": cb_list_confidence_levels,
"group": "Commands",
"level": 1,
"help": "Generate pylint's confidence levels.",
},
),
(
"list-extensions",
{
"action": "callback",
"callback": cb_list_extensions,
"group": "Commands",
"level": 1,
"help": "List available extensions.",
},
),
(
"full-documentation",
{
"action": "callback",
"metavar": "<msg-id>",
"callback": self.cb_full_documentation,
"group": "Commands",
"level": 1,
"help": "Generate pylint's full documentation.",
},
),
(
"generate-rcfile",
{
"action": "callback",
"callback": self.cb_generate_config,
"group": "Commands",
"help": "Generate a sample configuration file according to "
"the current configuration. You can put other options "
"before this one to get them in the generated "
"configuration.",
},
),
(
"generate-man",
{
"action": "callback",
"callback": self.cb_generate_manpage,
"group": "Commands",
"help": "Generate pylint's man page.",
"hide": _True,
},
),
(
"errors-only",
{
"action": "callback",
"callback": self.cb_error_mode,
"short": "E",
"help": "In error mode, checkers without error messages are "
"disabled and for others, only the ERROR messages are "
"displayed, and no reports are done by default.",
},
),
(
"verbose",
{
"action": "callback",
"callback": self.cb_verbose_mode,
"short": "v",
"help": "In verbose mode, extra non-checker-related info "
"will be displayed.",
},
),
(
"enable-all-extensions",
{
"action": "callback",
"callback": self.cb_enable_all_extensions,
"help": "Load and enable all available extensions. "
"Use --list-extensions to see a list all available extensions.",
},
),
),
option_groups=self.option_groups,
pylintrc=self._rcfile,
)
# register standard checkers
if self._version_asked:
print(full_version)
sys.exit(0)
linter.load_default_plugins()
# load command line plugins
linter.load_plugin_modules(self._plugins)
# add some help section
linter.add_help_section(
"Environment variables",
f"""
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 85 | preprocess_options | ref | function | preprocess_options(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 102 | LinterClass | ref | function | self.linter = linter = self.LinterClass(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 276 | load_default_plugins | ref | function | linter.load_default_plugins()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 278 | load_plugin_modules | ref | function | linter.load_plugin_modules(self._plugins)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 280 | add_help_section | ref | function | linter.add_help_section(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 294 | add_help_section | ref | function | linter.add_help_section(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 309 | add_help_section | ref | function | linter.add_help_section(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 325 | disable | ref | function | linter.disable("I")
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 326 | enable | ref | function | linter.enable("c-extension-no-member")
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py | pylint/lint/run.py | 328 | _config_initialization | ref | function | args = _config_initialization(linter, args, reporter, verbose_mode=self.verbose)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.