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/utils/linterstats.py
pylint/utils/linterstats.py
220
BadNames
ref
function
self.bad_names = BadNames(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
234
get_code_count
def
function
def get_code_count( self, type_name: Literal["code", "comment", "docstring", "empty", "total"] ) -> int: """Get a code type count.""" return self.code_type_count.get(type_name, 0) def reset_code_count(self) -> None: """Resets the code_type_count attribute.""" self.code_type_count = CodeTypeCount( code=0, comment=0, docstring=0, empty=0, total=0 ) def reset_duplicated_lines(self) -> None: """Resets the duplicated_lines attribute.""" self.duplicated_lines = DuplicatedLines( nb_duplicated_lines=0, percent_duplicated_lines=0.0 ) def get_node_count( self, node_name: Literal["function", "class", "method", "module"] ) -> int: """Get a node count while handling some extra conditions.""" if node_name == "class": return self.node_count.get("klass", 0) return self.node_count.get(node_name, 0) def reset_node_count(self) -> None: """Resets the node count attribute.""" self.node_count = NodeCount(function=0, klass=0, method=0, module=0) def get_undocumented( self, node_name: Literal["function", "class", "method", "module"] ) -> float: """Get a undocumented node count.""" if node_name == "class": return self.undocumented["klass"] return self.undocumented[node_name] def reset_undocumented(self) -> None: """Resets the undocumented attribute.""" self.undocumented = UndocumentedNodes(function=0, klass=0, method=0, module=0) def get_global_message_count(self, type_name: str) -> int: """Get a global message count.""" return getattr(self, type_name, 0) def get_module_message_count(self, modname: str, type_name: str) -> int: """Get a module message count.""" return getattr(self.by_module[modname], type_name, 0) def increase_single_message_count(self, type_name: str, increase: int) -> None: """Increase the message type count of an individual message type.""" setattr(self, type_name, getattr(self, type_name) + increase) def increase_single_module_message_count( self, modname: str, type_name: MessageTypesFullName, increase: int ) -> None: """Increase the message type count of an individual message type of a module.""" self.by_module[modname][type_name] += increase def reset_message_count(self) -> None: """Resets the message type count of the stats object.""" self.convention = 0 self.error = 0 self.fatal = 0 self.info = 0 self.refactor = 0 self.warning = 0
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
240
reset_code_count
def
function
def reset_code_count(self) -> None: """Resets the code_type_count attribute.""" self.code_type_count = CodeTypeCount( code=0, comment=0, docstring=0, empty=0, total=0 ) def reset_duplicated_lines(self) -> None: """Resets the duplicated_lines attribute.""" self.duplicated_lines = DuplicatedLines( nb_duplicated_lines=0, percent_duplicated_lines=0.0 ) def get_node_count( self, node_name: Literal["function", "class", "method", "module"] ) -> int: """Get a node count while handling some extra conditions.""" if node_name == "class": return self.node_count.get("klass", 0) return self.node_count.get(node_name, 0) def reset_node_count(self) -> None: """Resets the node count attribute.""" self.node_count = NodeCount(function=0, klass=0, method=0, module=0) def get_undocumented( self, node_name: Literal["function", "class", "method", "module"] ) -> float: """Get a undocumented node count.""" if node_name == "class": return self.undocumented["klass"] return self.undocumented[node_name] def reset_undocumented(self) -> None: """Resets the undocumented attribute.""" self.undocumented = UndocumentedNodes(function=0, klass=0, method=0, module=0) def get_global_message_count(self, type_name: str) -> int: """Get a global message count.""" return getattr(self, type_name, 0) def get_module_message_count(self, modname: str, type_name: str) -> int: """Get a module message count.""" return getattr(self.by_module[modname], type_name, 0) def increase_single_message_count(self, type_name: str, increase: int) -> None: """Increase the message type count of an individual message type.""" setattr(self, type_name, getattr(self, type_name) + increase) def increase_single_module_message_count( self, modname: str, type_name: MessageTypesFullName, increase: int ) -> None: """Increase the message type count of an individual message type of a module.""" self.by_module[modname][type_name] += increase def reset_message_count(self) -> None: """Resets the message type count of the stats object.""" self.convention = 0 self.error = 0 self.fatal = 0 self.info = 0 self.refactor = 0 self.warning = 0
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
242
CodeTypeCount
ref
function
self.code_type_count = CodeTypeCount(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
246
reset_duplicated_lines
def
function
def reset_duplicated_lines(self) -> None: """Resets the duplicated_lines attribute.""" self.duplicated_lines = DuplicatedLines( nb_duplicated_lines=0, percent_duplicated_lines=0.0 ) def get_node_count( self, node_name: Literal["function", "class", "method", "module"] ) -> int: """Get a node count while handling some extra conditions.""" if node_name == "class": return self.node_count.get("klass", 0) return self.node_count.get(node_name, 0) def reset_node_count(self) -> None: """Resets the node count attribute.""" self.node_count = NodeCount(function=0, klass=0, method=0, module=0) def get_undocumented( self, node_name: Literal["function", "class", "method", "module"] ) -> float: """Get a undocumented node count.""" if node_name == "class": return self.undocumented["klass"] return self.undocumented[node_name] def reset_undocumented(self) -> None: """Resets the undocumented attribute.""" self.undocumented = UndocumentedNodes(function=0, klass=0, method=0, module=0) def get_global_message_count(self, type_name: str) -> int: """Get a global message count.""" return getattr(self, type_name, 0) def get_module_message_count(self, modname: str, type_name: str) -> int: """Get a module message count.""" return getattr(self.by_module[modname], type_name, 0) def increase_single_message_count(self, type_name: str, increase: int) -> None: """Increase the message type count of an individual message type.""" setattr(self, type_name, getattr(self, type_name) + increase) def increase_single_module_message_count( self, modname: str, type_name: MessageTypesFullName, increase: int ) -> None: """Increase the message type count of an individual message type of a module.""" self.by_module[modname][type_name] += increase def reset_message_count(self) -> None: """Resets the message type count of the stats object.""" self.convention = 0 self.error = 0 self.fatal = 0 self.info = 0 self.refactor = 0 self.warning = 0
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
248
DuplicatedLines
ref
function
self.duplicated_lines = DuplicatedLines(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
252
get_node_count
def
function
def get_node_count( self, node_name: Literal["function", "class", "method", "module"] ) -> int: """Get a node count while handling some extra conditions.""" if node_name == "class": return self.node_count.get("klass", 0) return self.node_count.get(node_name, 0) def reset_node_count(self) -> None: """Resets the node count attribute.""" self.node_count = NodeCount(function=0, klass=0, method=0, module=0) def get_undocumented( self, node_name: Literal["function", "class", "method", "module"] ) -> float: """Get a undocumented node count.""" if node_name == "class": return self.undocumented["klass"] return self.undocumented[node_name] def reset_undocumented(self) -> None: """Resets the undocumented attribute.""" self.undocumented = UndocumentedNodes(function=0, klass=0, method=0, module=0) def get_global_message_count(self, type_name: str) -> int: """Get a global message count.""" return getattr(self, type_name, 0) def get_module_message_count(self, modname: str, type_name: str) -> int: """Get a module message count.""" return getattr(self.by_module[modname], type_name, 0) def increase_single_message_count(self, type_name: str, increase: int) -> None: """Increase the message type count of an individual message type.""" setattr(self, type_name, getattr(self, type_name) + increase) def increase_single_module_message_count( self, modname: str, type_name: MessageTypesFullName, increase: int ) -> None: """Increase the message type count of an individual message type of a module.""" self.by_module[modname][type_name] += increase def reset_message_count(self) -> None: """Resets the message type count of the stats object.""" self.convention = 0 self.error = 0 self.fatal = 0 self.info = 0 self.refactor = 0 self.warning = 0
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
260
reset_node_count
def
function
def reset_node_count(self) -> None: """Resets the node count attribute.""" self.node_count = NodeCount(function=0, klass=0, method=0, module=0) def get_undocumented( self, node_name: Literal["function", "class", "method", "module"] ) -> float: """Get a undocumented node count.""" if node_name == "class": return self.undocumented["klass"] return self.undocumented[node_name] def reset_undocumented(self) -> None: """Resets the undocumented attribute.""" self.undocumented = UndocumentedNodes(function=0, klass=0, method=0, module=0) def get_global_message_count(self, type_name: str) -> int: """Get a global message count.""" return getattr(self, type_name, 0) def get_module_message_count(self, modname: str, type_name: str) -> int: """Get a module message count.""" return getattr(self.by_module[modname], type_name, 0) def increase_single_message_count(self, type_name: str, increase: int) -> None: """Increase the message type count of an individual message type.""" setattr(self, type_name, getattr(self, type_name) + increase) def increase_single_module_message_count( self, modname: str, type_name: MessageTypesFullName, increase: int ) -> None: """Increase the message type count of an individual message type of a module.""" self.by_module[modname][type_name] += increase def reset_message_count(self) -> None: """Resets the message type count of the stats object.""" self.convention = 0 self.error = 0 self.fatal = 0 self.info = 0 self.refactor = 0 self.warning = 0
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
262
NodeCount
ref
function
self.node_count = NodeCount(function=0, klass=0, method=0, module=0)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
264
get_undocumented
def
function
def get_undocumented( self, node_name: Literal["function", "class", "method", "module"] ) -> float: """Get a undocumented node count.""" if node_name == "class": return self.undocumented["klass"] return self.undocumented[node_name] def reset_undocumented(self) -> None: """Resets the undocumented attribute.""" self.undocumented = UndocumentedNodes(function=0, klass=0, method=0, module=0) def get_global_message_count(self, type_name: str) -> int: """Get a global message count.""" return getattr(self, type_name, 0) def get_module_message_count(self, modname: str, type_name: str) -> int: """Get a module message count.""" return getattr(self.by_module[modname], type_name, 0) def increase_single_message_count(self, type_name: str, increase: int) -> None: """Increase the message type count of an individual message type.""" setattr(self, type_name, getattr(self, type_name) + increase) def increase_single_module_message_count( self, modname: str, type_name: MessageTypesFullName, increase: int ) -> None: """Increase the message type count of an individual message type of a module.""" self.by_module[modname][type_name] += increase def reset_message_count(self) -> None: """Resets the message type count of the stats object.""" self.convention = 0 self.error = 0 self.fatal = 0 self.info = 0 self.refactor = 0 self.warning = 0
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
272
reset_undocumented
def
function
def reset_undocumented(self) -> None: """Resets the undocumented attribute.""" self.undocumented = UndocumentedNodes(function=0, klass=0, method=0, module=0) def get_global_message_count(self, type_name: str) -> int: """Get a global message count.""" return getattr(self, type_name, 0) def get_module_message_count(self, modname: str, type_name: str) -> int: """Get a module message count.""" return getattr(self.by_module[modname], type_name, 0) def increase_single_message_count(self, type_name: str, increase: int) -> None: """Increase the message type count of an individual message type.""" setattr(self, type_name, getattr(self, type_name) + increase) def increase_single_module_message_count( self, modname: str, type_name: MessageTypesFullName, increase: int ) -> None: """Increase the message type count of an individual message type of a module.""" self.by_module[modname][type_name] += increase def reset_message_count(self) -> None: """Resets the message type count of the stats object.""" self.convention = 0 self.error = 0 self.fatal = 0 self.info = 0 self.refactor = 0 self.warning = 0
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
274
UndocumentedNodes
ref
function
self.undocumented = UndocumentedNodes(function=0, klass=0, method=0, module=0)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
276
get_global_message_count
def
function
def get_global_message_count(self, type_name: str) -> int: """Get a global message count.""" return getattr(self, type_name, 0) def get_module_message_count(self, modname: str, type_name: str) -> int: """Get a module message count.""" return getattr(self.by_module[modname], type_name, 0) def increase_single_message_count(self, type_name: str, increase: int) -> None: """Increase the message type count of an individual message type.""" setattr(self, type_name, getattr(self, type_name) + increase) def increase_single_module_message_count( self, modname: str, type_name: MessageTypesFullName, increase: int ) -> None: """Increase the message type count of an individual message type of a module.""" self.by_module[modname][type_name] += increase def reset_message_count(self) -> None: """Resets the message type count of the stats object.""" self.convention = 0 self.error = 0 self.fatal = 0 self.info = 0 self.refactor = 0 self.warning = 0
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
280
get_module_message_count
def
function
def get_module_message_count(self, modname: str, type_name: str) -> int: """Get a module message count.""" return getattr(self.by_module[modname], type_name, 0) def increase_single_message_count(self, type_name: str, increase: int) -> None: """Increase the message type count of an individual message type.""" setattr(self, type_name, getattr(self, type_name) + increase) def increase_single_module_message_count( self, modname: str, type_name: MessageTypesFullName, increase: int ) -> None: """Increase the message type count of an individual message type of a module.""" self.by_module[modname][type_name] += increase def reset_message_count(self) -> None: """Resets the message type count of the stats object.""" self.convention = 0 self.error = 0 self.fatal = 0 self.info = 0 self.refactor = 0 self.warning = 0
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
284
increase_single_message_count
def
function
def increase_single_message_count(self, type_name: str, increase: int) -> None: """Increase the message type count of an individual message type.""" setattr(self, type_name, getattr(self, type_name) + increase) def increase_single_module_message_count( self, modname: str, type_name: MessageTypesFullName, increase: int ) -> None: """Increase the message type count of an individual message type of a module.""" self.by_module[modname][type_name] += increase def reset_message_count(self) -> None: """Resets the message type count of the stats object.""" self.convention = 0 self.error = 0 self.fatal = 0 self.info = 0 self.refactor = 0 self.warning = 0
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
288
increase_single_module_message_count
def
function
def increase_single_module_message_count( self, modname: str, type_name: MessageTypesFullName, increase: int ) -> None: """Increase the message type count of an individual message type of a module.""" self.by_module[modname][type_name] += increase def reset_message_count(self) -> None: """Resets the message type count of the stats object.""" self.convention = 0 self.error = 0 self.fatal = 0 self.info = 0 self.refactor = 0 self.warning = 0
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
294
reset_message_count
def
function
def reset_message_count(self) -> None: """Resets the message type count of the stats object.""" self.convention = 0 self.error = 0 self.fatal = 0 self.info = 0 self.refactor = 0 self.warning = 0
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
304
merge_stats
def
function
def merge_stats(stats: List[LinterStats]): """Used to merge multiple stats objects into a new one when pylint is run in parallel mode.""" merged = LinterStats() for stat in stats: merged.bad_names["argument"] += stat.bad_names["argument"] merged.bad_names["attr"] += stat.bad_names["attr"] merged.bad_names["klass"] += stat.bad_names["klass"] merged.bad_names["class_attribute"] += stat.bad_names["class_attribute"] merged.bad_names["class_const"] += stat.bad_names["class_const"] merged.bad_names["const"] += stat.bad_names["const"] merged.bad_names["inlinevar"] += stat.bad_names["inlinevar"] merged.bad_names["function"] += stat.bad_names["function"] merged.bad_names["method"] += stat.bad_names["method"] merged.bad_names["module"] += stat.bad_names["module"] merged.bad_names["variable"] += stat.bad_names["variable"] for mod_key, mod_value in stat.by_module.items(): merged.by_module[mod_key] = mod_value for msg_key, msg_value in stat.by_msg.items(): try: merged.by_msg[msg_key] += msg_value except KeyError: merged.by_msg[msg_key] = msg_value merged.code_type_count["code"] += stat.code_type_count["code"] merged.code_type_count["comment"] += stat.code_type_count["comment"] merged.code_type_count["docstring"] += stat.code_type_count["docstring"] merged.code_type_count["empty"] += stat.code_type_count["empty"] merged.code_type_count["total"] += stat.code_type_count["total"] for dep_key, dep_value in stat.dependencies.items(): try: merged.dependencies[dep_key].update(dep_value) except KeyError: merged.dependencies[dep_key] = dep_value merged.duplicated_lines["nb_duplicated_lines"] += stat.duplicated_lines[ "nb_duplicated_lines" ] merged.duplicated_lines["percent_duplicated_lines"] += stat.duplicated_lines[ "percent_duplicated_lines" ] merged.node_count["function"] += stat.node_count["function"] merged.node_count["klass"] += stat.node_count["klass"] merged.node_count["method"] += stat.node_count["method"] merged.node_count["module"] += stat.node_count["module"] merged.undocumented["function"] += stat.undocumented["function"] merged.undocumented["klass"] += stat.undocumented["klass"] merged.undocumented["method"] += stat.undocumented["method"] merged.undocumented["module"] += stat.undocumented["module"] merged.convention += stat.convention merged.error += stat.error merged.fatal += stat.fatal merged.info += stat.info merged.refactor += stat.refactor merged.statement += stat.statement merged.warning += stat.warning merged.global_note += stat.global_note return merged
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/linterstats.py
pylint/utils/linterstats.py
306
LinterStats
ref
function
merged = LinterStats()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/pragma_parser.py
pylint/utils/pragma_parser.py
54
emit_pragma_representer
def
function
def emit_pragma_representer(action: str, messages: List[str]) -> PragmaRepresenter: if not messages and action in MESSAGE_KEYWORDS: raise InvalidPragmaError( "The keyword is not followed by message identifier", action ) return PragmaRepresenter(action, messages)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/pragma_parser.py
pylint/utils/pragma_parser.py
56
InvalidPragmaError
ref
function
raise InvalidPragmaError(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/pragma_parser.py
pylint/utils/pragma_parser.py
59
PragmaRepresenter
ref
function
return PragmaRepresenter(action, messages)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/pragma_parser.py
pylint/utils/pragma_parser.py
62
PragmaParserError
def
class
__init__
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/pragma_parser.py
pylint/utils/pragma_parser.py
74
UnRecognizedOptionError
def
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/pragma_parser.py
pylint/utils/pragma_parser.py
78
InvalidPragmaError
def
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/pragma_parser.py
pylint/utils/pragma_parser.py
82
parse_pragma
def
function
def parse_pragma(pylint_pragma: str) -> Generator[PragmaRepresenter, None, None]: action: Optional[str] = None messages: List[str] = [] assignment_required = _False previous_token = "" for mo in re.finditer(TOK_REGEX, pylint_pragma): kind = mo.lastgroup value = mo.group() if kind == "ASSIGN": if not assignment_required: if action: # A keyword has been found previously but doesn't support assignment raise UnRecognizedOptionError( "The keyword doesn't support assignment", action ) if previous_token: # Something found previously but not a known keyword raise UnRecognizedOptionError( "The keyword is unknown", previous_token ) # Nothing at all detected before this assignment raise InvalidPragmaError("Missing keyword before assignment", "") assignment_required = _False elif assignment_required: raise InvalidPragmaError( "The = sign is missing after the keyword", action or "" ) elif kind == "KEYWORD": if action: yield emit_pragma_representer(action, messages) action = value messages = [] assignment_required = action in MESSAGE_KEYWORDS elif kind in {"MESSAGE_STRING", "MESSAGE_NUMBER"}: messages.append(value) assignment_required = _False else: raise RuntimeError("Token not recognized") previous_token = value if action: yield emit_pragma_representer(action, messages) else: raise UnRecognizedOptionError("The keyword is unknown", previous_token)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/pragma_parser.py
pylint/utils/pragma_parser.py
90
group
ref
function
value = mo.group()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/pragma_parser.py
pylint/utils/pragma_parser.py
96
UnRecognizedOptionError
ref
function
raise UnRecognizedOptionError(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/pragma_parser.py
pylint/utils/pragma_parser.py
101
UnRecognizedOptionError
ref
function
raise UnRecognizedOptionError(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/pragma_parser.py
pylint/utils/pragma_parser.py
105
InvalidPragmaError
ref
function
raise InvalidPragmaError("Missing keyword before assignment", "")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/pragma_parser.py
pylint/utils/pragma_parser.py
108
InvalidPragmaError
ref
function
raise InvalidPragmaError(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/pragma_parser.py
pylint/utils/pragma_parser.py
113
emit_pragma_representer
ref
function
yield emit_pragma_representer(action, messages)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/pragma_parser.py
pylint/utils/pragma_parser.py
126
emit_pragma_representer
ref
function
yield emit_pragma_representer(action, messages)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/pragma_parser.py
pylint/utils/pragma_parser.py
128
UnRecognizedOptionError
ref
function
raise UnRecognizedOptionError("The keyword is unknown", previous_token)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
82
normalize_text
def
function
def normalize_text(text, line_len=DEFAULT_LINE_LENGTH, indent=""): """Wrap the text on the given line length.""" return "\n".join( textwrap.wrap( text, width=line_len, initial_indent=indent, subsequent_indent=indent ) )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
95
cmp
def
function
def cmp(a, b): return (a > b) - (a < b)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
99
diff_string
def
function
def diff_string(old, new): """Given an old and new int value, return a string representing the difference """ diff = abs(old - new) diff_str = f"{CMPS[cmp(old, new)]}{diff and f'{diff:.2f}' or ''}" return diff_str
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
104
cmp
ref
function
diff_str = f"{CMPS[cmp(old, new)]}{diff and f'{diff:.2f}' or ''}"
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
108
get_module_and_frameid
def
function
def get_module_and_frameid(node): """Return the module name and the frame id in the module.""" frame = node.frame(future=_True) module, obj = "", [] while frame: if isinstance(frame, Module): module = frame.name else: obj.append(getattr(frame, "name", "<lambda>")) try: frame = frame.parent.frame(future=_True) except AttributeError: break obj.reverse() return module, ".".join(obj)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
110
frame
ref
function
frame = node.frame(future=True)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
118
frame
ref
function
frame = frame.parent.frame(future=True)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
125
get_rst_title
def
function
def get_rst_title(title, character): """Permit to get a title formatted as ReStructuredText test (underlined with a chosen character).""" return f"{title}\n{character * len(title)}\n"
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
130
get_rst_section
def
function
def get_rst_section(section, options, doc=None): """Format an option's section using as a ReStructuredText formatted output.""" result = "" if section: result += get_rst_title(section, "'") if doc: formatted_doc = normalize_text(doc) result += f"{formatted_doc}\n\n" for optname, optdict, value in options: help_opt = optdict.get("help") result += f":{optname}:\n" if help_opt: formatted_help = normalize_text(help_opt, indent=" ") result += f"{formatted_help}\n" if value and optname != "py-version": value = str(_format_option_value(optdict, value)) result += f"\n Default: ``{value.replace('`` ', '```` ``')}``\n" return result
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
134
get_rst_title
ref
function
result += get_rst_title(section, "'")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
136
normalize_text
ref
function
formatted_doc = normalize_text(doc)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
142
normalize_text
ref
function
formatted_help = normalize_text(help_opt, indent=" ")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
145
_format_option_value
ref
function
value = str(_format_option_value(optdict, value))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
150
decoding_stream
def
function
def decoding_stream( stream: Union[BufferedReader, BytesIO], encoding: str, errors: Literal["strict"] = "strict",
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
159
reader_cls
ref
function
return reader_cls(stream, errors)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
162
tokenize_module
def
function
def tokenize_module(node: nodes.Module) -> List[tokenize.TokenInfo]: with node.stream() as stream: readline = stream.readline return list(tokenize.tokenize(readline))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
163
stream
ref
function
with node.stream() as stream:
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
168
register_plugins
def
function
def register_plugins(linter, directory): """Load all module and package in the given directory, looking for a 'register' function in each one, used to register pylint checkers """ imported = {} for filename in os.listdir(directory): base, extension = os.path.splitext(filename) if base in imported or base == "__pycache__": continue if ( extension in PY_EXTS and base != "__init__" or ( not extension and os.path.isdir(os.path.join(directory, base)) and not filename.startswith(".") ) ): try: module = modutils.load_module_from_file( os.path.join(directory, filename) ) except ValueError: # empty module name (usually emacs auto-save files) continue except ImportError as exc: print(f"Problem importing module {filename}: {exc}", file=sys.stderr) else: if hasattr(module, "register"): module.register(linter) imported[base] = 1
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
174
splitext
ref
function
base, extension = os.path.splitext(filename)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
182
isdir
ref
function
and os.path.isdir(os.path.join(directory, base))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
187
load_module_from_file
ref
function
module = modutils.load_module_from_file(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
202
get_global_option
def
function
def get_global_option( checker: "BaseChecker", option: GLOBAL_OPTION_BOOL, default: Optional[bool] = None
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
209
get_global_option
def
function
def get_global_option( checker: "BaseChecker", option: GLOBAL_OPTION_BOOL, default: Optional[bool] = None
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
216
get_global_option
def
function
def get_global_option( checker: "BaseChecker", option: GLOBAL_OPTION_BOOL, default: Optional[bool] = None
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
225
get_global_option
def
function
def get_global_option( checker: "BaseChecker", option: GLOBAL_OPTION_BOOL, default: Optional[bool] = None
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
234
get_global_option
def
function
def get_global_option( checker: "BaseChecker", option: GLOBAL_OPTION_BOOL, default: Optional[bool] = None
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
243
get_global_option
def
function
def get_global_option( checker: "BaseChecker", option: GLOBAL_OPTION_BOOL, default: Optional[bool] = None
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
251
get_global_option
def
function
def get_global_option( checker: "BaseChecker", option: GLOBAL_OPTION_BOOL, default: Optional[bool] = None
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
277
_splitstrip
def
function
def _splitstrip(string, sep=","): """Return a list of stripped string by splitting the string given as argument on `sep` (',' by default). Empty string are discarded. >>> _splitstrip('a, b, c , 4,,') ['a', 'b', 'c', '4'] >>> _splitstrip('a') ['a'] >>> _splitstrip('a,\nb,\nc,') ['a', 'b', 'c'] :type string: str or unicode :param string: a csv line :type sep: str or unicode :param sep: field separator, default to the comma (',') :rtype: str or unicode :return: the unquoted string (or the input string if it wasn't quoted) """ return [word.strip() for word in string.split(sep) if word.strip()]
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
300
_unquote
def
function
def _unquote(string): """Remove optional quotes (simple or double) from the string. :type string: str or unicode :param string: an optionally quoted string :rtype: str or unicode :return: the unquoted string (or the input string if it wasn't quoted) """ if not string: return string if string[0] in "\"'": string = string[1:] if string[-1] in "\"'": string = string[:-1] return string
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
318
_check_csv
def
function
def _check_csv(value): if isinstance(value, (list, tuple)): return value return _splitstrip(value)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
321
_splitstrip
ref
function
return _splitstrip(value)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
324
_comment
def
function
def _comment(string: str) -> str: """Return string as a comment.""" lines = [line.strip() for line in string.splitlines()] sep = "\n" return "# " + f"{sep}# ".join(lines)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
331
_format_option_value
def
function
def _format_option_value(optdict, value): """Return the user input's value from a 'compiled' value.""" if optdict.get("type", None) == "py_version": value = ".".join(str(item) for item in value) elif isinstance(value, (list, tuple)): value = ",".join(_format_option_value(optdict, item) for item in value) elif isinstance(value, dict): value = ",".join(f"{k}:{v}" for k, v in value.items()) elif hasattr(value, "match"): # optdict.get('type') == 'regexp' # compiled regexp value = value.pattern elif optdict.get("type") == "yn": value = "yes" if value else "no" elif isinstance(value, str) and value.isspace(): value = f"'{value}'" return value
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
336
_format_option_value
ref
function
value = ",".join(_format_option_value(optdict, item) for item in value)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
349
format_section
def
function
def format_section( stream: TextIO, section: str, options: List[Tuple], doc: Optional[str] = None
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
354
_comment
ref
function
print(_comment(doc), file=stream)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
356
_ini_format
ref
function
_ini_format(stream, options)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
359
_ini_format
def
function
def _ini_format(stream: TextIO, options: List[Tuple]) -> None: """Format options using the INI format.""" for optname, optdict, value in options: value = _format_option_value(optdict, value) help_opt = optdict.get("help") if help_opt: help_opt = normalize_text(help_opt, indent="# ") print(file=stream) print(help_opt, file=stream) else: print(file=stream) if value is None: print(f"#{optname}=", file=stream) else: value = str(value).strip() if re.match(r"^([\w-]+,)+[\w-]+$", str(value)): separator = "\n " + " " * len(optname) value = separator.join(x + "," for x in str(value).split(",")) # remove trailing ',' from last element of the list value = value[:-1] print(f"{optname}={value}", file=stream)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
362
_format_option_value
ref
function
value = _format_option_value(optdict, value)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
365
normalize_text
ref
function
help_opt = normalize_text(help_opt, indent="# ")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
382
IsortDriver
def
class
__init__ place_module
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
387
Config
ref
function
self.isort5_config = isort.api.Config(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
396
SortImports
ref
function
self.isort4_obj = isort.SortImports( # pylint: disable=no-member
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
402
place_module
def
function
def place_module(self, package): if HAS_ISORT_5: return isort.api.place_module(package, self.isort5_config) return self.isort4_obj.place_module(package)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
404
place_module
ref
function
return isort.api.place_module(package, self.isort5_config)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/utils/utils.py
pylint/utils/utils.py
405
place_module
ref
function
return self.isort4_obj.place_module(package)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
21
main
def
function
def main() -> None: parser = argparse.ArgumentParser(__doc__) parser.add_argument("version", help="The version we want to release") parser.add_argument( "-v", "--verbose", action="store_true", default=_False, help="Logging or not" ) args = parser.parse_args() if args.verbose: logging.basicConfig(level=logging.DEBUG) logging.debug(f"Launching bump_changelog with args: {args}") if "dev" in args.version: return with open(DEFAULT_CHANGELOG_PATH, encoding="utf-8") as f: content = f.read() content = transform_content(content, args.version) with open(DEFAULT_CHANGELOG_PATH, "w", encoding="utf-8") as f: f.write(content)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
23
add_argument
ref
function
parser.add_argument("version", help="The version we want to release")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
24
add_argument
ref
function
parser.add_argument(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
27
parse_args
ref
function
args = parser.parse_args()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
34
read
ref
function
content = f.read()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
35
transform_content
ref
function
content = transform_content(content, args.version)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
37
write
ref
function
f.write(content)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
40
VersionType
def
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
46
get_next_version
def
function
def get_next_version(version: str, version_type: VersionType) -> str: new_version = version.split(".") part_to_increase = new_version[version_type.value] if "-" in part_to_increase: part_to_increase = part_to_increase.split("-")[0] for i in range(version_type.value, 3): new_version[i] = "0" new_version[version_type.value] = str(int(part_to_increase) + 1) return ".".join(new_version)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
57
get_next_versions
def
function
def get_next_versions(version: str, version_type: VersionType) -> List[str]: if version_type == VersionType.PATCH: # "2.6.1" => ["2.6.2"] return [get_next_version(version, VersionType.PATCH)] if version_type == VersionType.MINOR: # "2.6.0" => ["2.7.0", "2.6.1"] assert version.endswith(".0"), f"{version} does not look like a minor version" else: # "3.0.0" => ["3.1.0", "3.0.1"] assert version.endswith(".0.0"), f"{version} does not look like a major version" next_minor_version = get_next_version(version, VersionType.MINOR) next_patch_version = get_next_version(version, VersionType.PATCH) logging.debug(f"Getting the new version for {version} - {version_type.name}") return [next_minor_version, next_patch_version]
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
61
get_next_version
ref
function
return [get_next_version(version, VersionType.PATCH)]
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
68
get_next_version
ref
function
next_minor_version = get_next_version(version, VersionType.MINOR)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
69
get_next_version
ref
function
next_patch_version = get_next_version(version, VersionType.PATCH)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
74
get_version_type
def
function
def get_version_type(version: str) -> VersionType: if version.endswith(".0.0"): version_type = VersionType.MAJOR elif version.endswith(".0"): version_type = VersionType.MINOR else: version_type = VersionType.PATCH return version_type
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
84
get_whats_new
def
function
def get_whats_new( version: str, add_date: bool = _False, change_date: bool = _False
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
101
get_all_whats_new
def
function
def get_all_whats_new(version: str, version_type: VersionType) -> str: result = "" for version_ in get_next_versions(version, version_type=version_type): result += get_whats_new(version_, add_date=_True) + "\n" * 4 return result
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
103
get_next_versions
ref
function
for version_ in get_next_versions(version, version_type=version_type):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
104
get_whats_new
ref
function
result += get_whats_new(version_, add_date=True) + "\n" * 4
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/script/bump_changelog.py
script/bump_changelog.py
108
transform_content
def
function
def transform_content(content: str, version: str) -> str: version_type = get_version_type(version) next_version = get_next_version(version, version_type) old_date = get_whats_new(version, add_date=_True) new_date = get_whats_new(version, add_date=_True, change_date=_True) next_version_with_date = get_all_whats_new(version, version_type) do_checks(content, next_version, version, version_type) index = content.find(old_date) logging.debug(f"Replacing\n'{old_date}'\nby\n'{new_date}'\n") content = content.replace(old_date, new_date) end_content = content[index:] content = content[:index] logging.debug(f"Adding:\n'{next_version_with_date}'\n") content += next_version_with_date + end_content return content