partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | ClassChecker._check_classmethod_declaration | Checks for uses of classmethod() or staticmethod()
When a @classmethod or @staticmethod decorator should be used instead.
A message will be emitted only if the assignment is at a class scope
and only if the classmethod's argument belongs to the class where it
is defined.
`node` ... | pylint/checkers/classes.py | def _check_classmethod_declaration(self, node):
"""Checks for uses of classmethod() or staticmethod()
When a @classmethod or @staticmethod decorator should be used instead.
A message will be emitted only if the assignment is at a class scope
and only if the classmethod's argument belong... | def _check_classmethod_declaration(self, node):
"""Checks for uses of classmethod() or staticmethod()
When a @classmethod or @staticmethod decorator should be used instead.
A message will be emitted only if the assignment is at a class scope
and only if the classmethod's argument belong... | [
"Checks",
"for",
"uses",
"of",
"classmethod",
"()",
"or",
"staticmethod",
"()"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/classes.py#L1202-L1239 | [
"def",
"_check_classmethod_declaration",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"isinstance",
"(",
"node",
".",
"value",
",",
"astroid",
".",
"Call",
")",
":",
"return",
"# check the function called is \"classmethod\" or \"staticmethod\"",
"func",
"=",
"no... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | ClassChecker._check_protected_attribute_access | Given an attribute access node (set or get), check if attribute
access is legitimate. Call _check_first_attr with node before calling
this method. Valid cases are:
* self._attr in a method or cls._attr in a classmethod. Checked by
_check_first_attr.
* Klass._attr inside "Klass" c... | pylint/checkers/classes.py | def _check_protected_attribute_access(self, node):
"""Given an attribute access node (set or get), check if attribute
access is legitimate. Call _check_first_attr with node before calling
this method. Valid cases are:
* self._attr in a method or cls._attr in a classmethod. Checked by
... | def _check_protected_attribute_access(self, node):
"""Given an attribute access node (set or get), check if attribute
access is legitimate. Call _check_first_attr with node before calling
this method. Valid cases are:
* self._attr in a method or cls._attr in a classmethod. Checked by
... | [
"Given",
"an",
"attribute",
"access",
"node",
"(",
"set",
"or",
"get",
")",
"check",
"if",
"attribute",
"access",
"is",
"legitimate",
".",
"Call",
"_check_first_attr",
"with",
"node",
"before",
"calling",
"this",
"method",
".",
"Valid",
"cases",
"are",
":",
... | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/classes.py#L1241-L1301 | [
"def",
"_check_protected_attribute_access",
"(",
"self",
",",
"node",
")",
":",
"attrname",
"=",
"node",
".",
"attrname",
"if",
"(",
"is_attr_protected",
"(",
"attrname",
")",
"and",
"attrname",
"not",
"in",
"self",
".",
"config",
".",
"exclude_protected",
")"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | ClassChecker.visit_name | check if the name handle an access to a class member
if so, register it | pylint/checkers/classes.py | def visit_name(self, node):
"""check if the name handle an access to a class member
if so, register it
"""
if self._first_attrs and (
node.name == self._first_attrs[-1] or not self._first_attrs[-1]
):
self._meth_could_be_func = False | def visit_name(self, node):
"""check if the name handle an access to a class member
if so, register it
"""
if self._first_attrs and (
node.name == self._first_attrs[-1] or not self._first_attrs[-1]
):
self._meth_could_be_func = False | [
"check",
"if",
"the",
"name",
"handle",
"an",
"access",
"to",
"a",
"class",
"member",
"if",
"so",
"register",
"it"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/classes.py#L1312-L1319 | [
"def",
"visit_name",
"(",
"self",
",",
"node",
")",
":",
"if",
"self",
".",
"_first_attrs",
"and",
"(",
"node",
".",
"name",
"==",
"self",
".",
"_first_attrs",
"[",
"-",
"1",
"]",
"or",
"not",
"self",
".",
"_first_attrs",
"[",
"-",
"1",
"]",
")",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | ClassChecker._check_accessed_members | check that accessed members are defined | pylint/checkers/classes.py | def _check_accessed_members(self, node, accessed):
"""check that accessed members are defined"""
# XXX refactor, probably much simpler now that E0201 is in type checker
excs = ("AttributeError", "Exception", "BaseException")
for attr, nodes in accessed.items():
try:
... | def _check_accessed_members(self, node, accessed):
"""check that accessed members are defined"""
# XXX refactor, probably much simpler now that E0201 is in type checker
excs = ("AttributeError", "Exception", "BaseException")
for attr, nodes in accessed.items():
try:
... | [
"check",
"that",
"accessed",
"members",
"are",
"defined"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/classes.py#L1321-L1380 | [
"def",
"_check_accessed_members",
"(",
"self",
",",
"node",
",",
"accessed",
")",
":",
"# XXX refactor, probably much simpler now that E0201 is in type checker",
"excs",
"=",
"(",
"\"AttributeError\"",
",",
"\"Exception\"",
",",
"\"BaseException\"",
")",
"for",
"attr",
",... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | ClassChecker._check_first_arg_for_type | check the name of first argument, expect:
* 'self' for a regular method
* 'cls' for a class method or a metaclass regular method (actually
valid-classmethod-first-arg value)
* 'mcs' for a metaclass class method (actually
valid-metaclass-classmethod-first-arg)
* not o... | pylint/checkers/classes.py | def _check_first_arg_for_type(self, node, metaclass=0):
"""check the name of first argument, expect:
* 'self' for a regular method
* 'cls' for a class method or a metaclass regular method (actually
valid-classmethod-first-arg value)
* 'mcs' for a metaclass class method (actual... | def _check_first_arg_for_type(self, node, metaclass=0):
"""check the name of first argument, expect:
* 'self' for a regular method
* 'cls' for a class method or a metaclass regular method (actually
valid-classmethod-first-arg value)
* 'mcs' for a metaclass class method (actual... | [
"check",
"the",
"name",
"of",
"first",
"argument",
"expect",
":"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/classes.py#L1382-L1444 | [
"def",
"_check_first_arg_for_type",
"(",
"self",
",",
"node",
",",
"metaclass",
"=",
"0",
")",
":",
"# don't care about functions with unknown argument (builtins)",
"if",
"node",
".",
"args",
".",
"args",
"is",
"None",
":",
"return",
"first_arg",
"=",
"node",
".",... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | ClassChecker._check_bases_classes | check that the given class node implements abstract methods from
base classes | pylint/checkers/classes.py | def _check_bases_classes(self, node):
"""check that the given class node implements abstract methods from
base classes
"""
def is_abstract(method):
return method.is_abstract(pass_is_abstract=False)
# check if this class abstract
if class_is_abstract(node):
... | def _check_bases_classes(self, node):
"""check that the given class node implements abstract methods from
base classes
"""
def is_abstract(method):
return method.is_abstract(pass_is_abstract=False)
# check if this class abstract
if class_is_abstract(node):
... | [
"check",
"that",
"the",
"given",
"class",
"node",
"implements",
"abstract",
"methods",
"from",
"base",
"classes"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/classes.py#L1455-L1480 | [
"def",
"_check_bases_classes",
"(",
"self",
",",
"node",
")",
":",
"def",
"is_abstract",
"(",
"method",
")",
":",
"return",
"method",
".",
"is_abstract",
"(",
"pass_is_abstract",
"=",
"False",
")",
"# check if this class abstract",
"if",
"class_is_abstract",
"(",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | ClassChecker._check_init | check that the __init__ method call super or ancestors'__init__
method | pylint/checkers/classes.py | def _check_init(self, node):
"""check that the __init__ method call super or ancestors'__init__
method
"""
if not self.linter.is_message_enabled(
"super-init-not-called"
) and not self.linter.is_message_enabled("non-parent-init-called"):
return
kla... | def _check_init(self, node):
"""check that the __init__ method call super or ancestors'__init__
method
"""
if not self.linter.is_message_enabled(
"super-init-not-called"
) and not self.linter.is_message_enabled("non-parent-init-called"):
return
kla... | [
"check",
"that",
"the",
"__init__",
"method",
"call",
"super",
"or",
"ancestors",
"__init__",
"method"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/classes.py#L1482-L1537 | [
"def",
"_check_init",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"self",
".",
"linter",
".",
"is_message_enabled",
"(",
"\"super-init-not-called\"",
")",
"and",
"not",
"self",
".",
"linter",
".",
"is_message_enabled",
"(",
"\"non-parent-init-called\"",
")"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | ClassChecker._check_signature | check that the signature of the two given methods match | pylint/checkers/classes.py | def _check_signature(self, method1, refmethod, class_type, cls):
"""check that the signature of the two given methods match
"""
if not (
isinstance(method1, astroid.FunctionDef)
and isinstance(refmethod, astroid.FunctionDef)
):
self.add_message(
... | def _check_signature(self, method1, refmethod, class_type, cls):
"""check that the signature of the two given methods match
"""
if not (
isinstance(method1, astroid.FunctionDef)
and isinstance(refmethod, astroid.FunctionDef)
):
self.add_message(
... | [
"check",
"that",
"the",
"signature",
"of",
"the",
"two",
"given",
"methods",
"match"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/classes.py#L1539-L1581 | [
"def",
"_check_signature",
"(",
"self",
",",
"method1",
",",
"refmethod",
",",
"class_type",
",",
"cls",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"method1",
",",
"astroid",
".",
"FunctionDef",
")",
"and",
"isinstance",
"(",
"refmethod",
",",
"astroid... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | ClassChecker._is_mandatory_method_param | Check if astroid.Name corresponds to first attribute variable name
Name is `self` for method, `cls` for classmethod and `mcs` for metaclass. | pylint/checkers/classes.py | def _is_mandatory_method_param(self, node):
"""Check if astroid.Name corresponds to first attribute variable name
Name is `self` for method, `cls` for classmethod and `mcs` for metaclass.
"""
return (
self._first_attrs
and isinstance(node, astroid.Name)
... | def _is_mandatory_method_param(self, node):
"""Check if astroid.Name corresponds to first attribute variable name
Name is `self` for method, `cls` for classmethod and `mcs` for metaclass.
"""
return (
self._first_attrs
and isinstance(node, astroid.Name)
... | [
"Check",
"if",
"astroid",
".",
"Name",
"corresponds",
"to",
"first",
"attribute",
"variable",
"name"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/classes.py#L1590-L1599 | [
"def",
"_is_mandatory_method_param",
"(",
"self",
",",
"node",
")",
":",
"return",
"(",
"self",
".",
"_first_attrs",
"and",
"isinstance",
"(",
"node",
",",
"astroid",
".",
"Name",
")",
"and",
"node",
".",
"name",
"==",
"self",
".",
"_first_attrs",
"[",
"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | _annotated_unpack_infer | Recursively generate nodes inferred by the given statement.
If the inferred value is a list or a tuple, recurse on the elements.
Returns an iterator which yields tuples in the format
('original node', 'infered node'). | pylint/checkers/exceptions.py | def _annotated_unpack_infer(stmt, context=None):
"""
Recursively generate nodes inferred by the given statement.
If the inferred value is a list or a tuple, recurse on the elements.
Returns an iterator which yields tuples in the format
('original node', 'infered node').
"""
if isinstance(stm... | def _annotated_unpack_infer(stmt, context=None):
"""
Recursively generate nodes inferred by the given statement.
If the inferred value is a list or a tuple, recurse on the elements.
Returns an iterator which yields tuples in the format
('original node', 'infered node').
"""
if isinstance(stm... | [
"Recursively",
"generate",
"nodes",
"inferred",
"by",
"the",
"given",
"statement",
".",
"If",
"the",
"inferred",
"value",
"is",
"a",
"list",
"or",
"a",
"tuple",
"recurse",
"on",
"the",
"elements",
".",
"Returns",
"an",
"iterator",
"which",
"yields",
"tuples"... | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/exceptions.py#L45-L61 | [
"def",
"_annotated_unpack_infer",
"(",
"stmt",
",",
"context",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"stmt",
",",
"(",
"astroid",
".",
"List",
",",
"astroid",
".",
"Tuple",
")",
")",
":",
"for",
"elt",
"in",
"stmt",
".",
"elts",
":",
"infer... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | _is_raising | Return true if the given statement node raise an exception | pylint/checkers/exceptions.py | def _is_raising(body: typing.List) -> bool:
"""Return true if the given statement node raise an exception"""
for node in body:
if isinstance(node, astroid.Raise):
return True
return False | def _is_raising(body: typing.List) -> bool:
"""Return true if the given statement node raise an exception"""
for node in body:
if isinstance(node, astroid.Raise):
return True
return False | [
"Return",
"true",
"if",
"the",
"given",
"statement",
"node",
"raise",
"an",
"exception"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/exceptions.py#L64-L69 | [
"def",
"_is_raising",
"(",
"body",
":",
"typing",
".",
"List",
")",
"->",
"bool",
":",
"for",
"node",
"in",
"body",
":",
"if",
"isinstance",
"(",
"node",
",",
"astroid",
".",
"Raise",
")",
":",
"return",
"True",
"return",
"False"
] | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | ExceptionsChecker._check_bad_exception_context | Verify that the exception context is properly set.
An exception context can be only `None` or an exception. | pylint/checkers/exceptions.py | def _check_bad_exception_context(self, node):
"""Verify that the exception context is properly set.
An exception context can be only `None` or an exception.
"""
cause = utils.safe_infer(node.cause)
if cause in (astroid.Uninferable, None):
return
if isinstanc... | def _check_bad_exception_context(self, node):
"""Verify that the exception context is properly set.
An exception context can be only `None` or an exception.
"""
cause = utils.safe_infer(node.cause)
if cause in (astroid.Uninferable, None):
return
if isinstanc... | [
"Verify",
"that",
"the",
"exception",
"context",
"is",
"properly",
"set",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/exceptions.py#L342-L357 | [
"def",
"_check_bad_exception_context",
"(",
"self",
",",
"node",
")",
":",
"cause",
"=",
"utils",
".",
"safe_infer",
"(",
"node",
".",
"cause",
")",
"if",
"cause",
"in",
"(",
"astroid",
".",
"Uninferable",
",",
"None",
")",
":",
"return",
"if",
"isinstan... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | ExceptionsChecker.visit_tryexcept | check for empty except | pylint/checkers/exceptions.py | def visit_tryexcept(self, node):
"""check for empty except"""
self._check_try_except_raise(node)
exceptions_classes = []
nb_handlers = len(node.handlers)
for index, handler in enumerate(node.handlers):
if handler.type is None:
if not _is_raising(handle... | def visit_tryexcept(self, node):
"""check for empty except"""
self._check_try_except_raise(node)
exceptions_classes = []
nb_handlers = len(node.handlers)
for index, handler in enumerate(node.handlers):
if handler.type is None:
if not _is_raising(handle... | [
"check",
"for",
"empty",
"except"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/exceptions.py#L499-L568 | [
"def",
"visit_tryexcept",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"_check_try_except_raise",
"(",
"node",
")",
"exceptions_classes",
"=",
"[",
"]",
"nb_handlers",
"=",
"len",
"(",
"node",
".",
"handlers",
")",
"for",
"index",
",",
"handler",
"in",... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | NewStyleConflictChecker.visit_functiondef | check use of super | pylint/checkers/newstyle.py | def visit_functiondef(self, node):
"""check use of super"""
# ignore actual functions or method within a new style class
if not node.is_method():
return
klass = node.parent.frame()
for stmt in node.nodes_of_class(astroid.Call):
if node_frame_class(stmt) !=... | def visit_functiondef(self, node):
"""check use of super"""
# ignore actual functions or method within a new style class
if not node.is_method():
return
klass = node.parent.frame()
for stmt in node.nodes_of_class(astroid.Call):
if node_frame_class(stmt) !=... | [
"check",
"use",
"of",
"super"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/newstyle.py#L58-L135 | [
"def",
"visit_functiondef",
"(",
"self",
",",
"node",
")",
":",
"# ignore actual functions or method within a new style class",
"if",
"not",
"node",
".",
"is_method",
"(",
")",
":",
"return",
"klass",
"=",
"node",
".",
"parent",
".",
"frame",
"(",
")",
"for",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | BaseReporter.display_reports | display results encapsulated in the layout tree | pylint/reporters/base_reporter.py | def display_reports(self, layout):
"""display results encapsulated in the layout tree"""
self.section = 0
if hasattr(layout, "report_id"):
layout.children[0].children[0].data += " (%s)" % layout.report_id
self._display(layout) | def display_reports(self, layout):
"""display results encapsulated in the layout tree"""
self.section = 0
if hasattr(layout, "report_id"):
layout.children[0].children[0].data += " (%s)" % layout.report_id
self._display(layout) | [
"display",
"results",
"encapsulated",
"in",
"the",
"layout",
"tree"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/reporters/base_reporter.py#L40-L45 | [
"def",
"display_reports",
"(",
"self",
",",
"layout",
")",
":",
"self",
".",
"section",
"=",
"0",
"if",
"hasattr",
"(",
"layout",
",",
"\"report_id\"",
")",
":",
"layout",
".",
"children",
"[",
"0",
"]",
".",
"children",
"[",
"0",
"]",
".",
"data",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | _is_typing_namedtuple | Check if a class node is a typing.NamedTuple class | pylint/checkers/design_analysis.py | def _is_typing_namedtuple(node: astroid.ClassDef) -> bool:
"""Check if a class node is a typing.NamedTuple class"""
for base in node.ancestors():
if base.qname() == TYPING_NAMEDTUPLE:
return True
return False | def _is_typing_namedtuple(node: astroid.ClassDef) -> bool:
"""Check if a class node is a typing.NamedTuple class"""
for base in node.ancestors():
if base.qname() == TYPING_NAMEDTUPLE:
return True
return False | [
"Check",
"if",
"a",
"class",
"node",
"is",
"a",
"typing",
".",
"NamedTuple",
"class"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/design_analysis.py#L96-L101 | [
"def",
"_is_typing_namedtuple",
"(",
"node",
":",
"astroid",
".",
"ClassDef",
")",
"->",
"bool",
":",
"for",
"base",
"in",
"node",
".",
"ancestors",
"(",
")",
":",
"if",
"base",
".",
"qname",
"(",
")",
"==",
"TYPING_NAMEDTUPLE",
":",
"return",
"True",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | _is_enum_class | Check if a class definition defines an Enum class.
:param node: The class node to check.
:type node: astroid.ClassDef
:returns: True if the given node represents an Enum class. False otherwise.
:rtype: bool | pylint/checkers/design_analysis.py | def _is_enum_class(node: astroid.ClassDef) -> bool:
"""Check if a class definition defines an Enum class.
:param node: The class node to check.
:type node: astroid.ClassDef
:returns: True if the given node represents an Enum class. False otherwise.
:rtype: bool
"""
for base in node.bases:
... | def _is_enum_class(node: astroid.ClassDef) -> bool:
"""Check if a class definition defines an Enum class.
:param node: The class node to check.
:type node: astroid.ClassDef
:returns: True if the given node represents an Enum class. False otherwise.
:rtype: bool
"""
for base in node.bases:
... | [
"Check",
"if",
"a",
"class",
"definition",
"defines",
"an",
"Enum",
"class",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/design_analysis.py#L104-L126 | [
"def",
"_is_enum_class",
"(",
"node",
":",
"astroid",
".",
"ClassDef",
")",
"->",
"bool",
":",
"for",
"base",
"in",
"node",
".",
"bases",
":",
"try",
":",
"inferred_bases",
"=",
"base",
".",
"inferred",
"(",
")",
"except",
"astroid",
".",
"InferenceError... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | _is_dataclass | Check if a class definition defines a Python 3.7+ dataclass
:param node: The class node to check.
:type node: astroid.ClassDef
:returns: True if the given node represents a dataclass class. False otherwise.
:rtype: bool | pylint/checkers/design_analysis.py | def _is_dataclass(node: astroid.ClassDef) -> bool:
"""Check if a class definition defines a Python 3.7+ dataclass
:param node: The class node to check.
:type node: astroid.ClassDef
:returns: True if the given node represents a dataclass class. False otherwise.
:rtype: bool
"""
if not node.... | def _is_dataclass(node: astroid.ClassDef) -> bool:
"""Check if a class definition defines a Python 3.7+ dataclass
:param node: The class node to check.
:type node: astroid.ClassDef
:returns: True if the given node represents a dataclass class. False otherwise.
:rtype: bool
"""
if not node.... | [
"Check",
"if",
"a",
"class",
"definition",
"defines",
"a",
"Python",
"3",
".",
"7",
"+",
"dataclass"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/design_analysis.py#L129-L153 | [
"def",
"_is_dataclass",
"(",
"node",
":",
"astroid",
".",
"ClassDef",
")",
"->",
"bool",
":",
"if",
"not",
"node",
".",
"decorators",
":",
"return",
"False",
"root_locals",
"=",
"node",
".",
"root",
"(",
")",
".",
"locals",
"for",
"decorator",
"in",
"n... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | _count_boolean_expressions | Counts the number of boolean expressions in BoolOp `bool_op` (recursive)
example: a and (b or c or (d and e)) ==> 5 boolean expressions | pylint/checkers/design_analysis.py | def _count_boolean_expressions(bool_op):
"""Counts the number of boolean expressions in BoolOp `bool_op` (recursive)
example: a and (b or c or (d and e)) ==> 5 boolean expressions
"""
nb_bool_expr = 0
for bool_expr in bool_op.get_children():
if isinstance(bool_expr, BoolOp):
nb_... | def _count_boolean_expressions(bool_op):
"""Counts the number of boolean expressions in BoolOp `bool_op` (recursive)
example: a and (b or c or (d and e)) ==> 5 boolean expressions
"""
nb_bool_expr = 0
for bool_expr in bool_op.get_children():
if isinstance(bool_expr, BoolOp):
nb_... | [
"Counts",
"the",
"number",
"of",
"boolean",
"expressions",
"in",
"BoolOp",
"bool_op",
"(",
"recursive",
")"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/design_analysis.py#L156-L167 | [
"def",
"_count_boolean_expressions",
"(",
"bool_op",
")",
":",
"nb_bool_expr",
"=",
"0",
"for",
"bool_expr",
"in",
"bool_op",
".",
"get_children",
"(",
")",
":",
"if",
"isinstance",
"(",
"bool_expr",
",",
"BoolOp",
")",
":",
"nb_bool_expr",
"+=",
"_count_boole... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MisdesignChecker.open | initialize visit variables | pylint/checkers/design_analysis.py | def open(self):
"""initialize visit variables"""
self.stats = self.linter.add_stats()
self._returns = []
self._branches = defaultdict(int)
self._stmts = [] | def open(self):
"""initialize visit variables"""
self.stats = self.linter.add_stats()
self._returns = []
self._branches = defaultdict(int)
self._stmts = [] | [
"initialize",
"visit",
"variables"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/design_analysis.py#L299-L304 | [
"def",
"open",
"(",
"self",
")",
":",
"self",
".",
"stats",
"=",
"self",
".",
"linter",
".",
"add_stats",
"(",
")",
"self",
".",
"_returns",
"=",
"[",
"]",
"self",
".",
"_branches",
"=",
"defaultdict",
"(",
"int",
")",
"self",
".",
"_stmts",
"=",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MisdesignChecker.visit_classdef | check size of inheritance hierarchy and number of instance attributes | pylint/checkers/design_analysis.py | def visit_classdef(self, node):
"""check size of inheritance hierarchy and number of instance attributes
"""
nb_parents = len(list(node.ancestors()))
if nb_parents > self.config.max_parents:
self.add_message(
"too-many-ancestors",
node=node,
... | def visit_classdef(self, node):
"""check size of inheritance hierarchy and number of instance attributes
"""
nb_parents = len(list(node.ancestors()))
if nb_parents > self.config.max_parents:
self.add_message(
"too-many-ancestors",
node=node,
... | [
"check",
"size",
"of",
"inheritance",
"hierarchy",
"and",
"number",
"of",
"instance",
"attributes"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/design_analysis.py#L320-L336 | [
"def",
"visit_classdef",
"(",
"self",
",",
"node",
")",
":",
"nb_parents",
"=",
"len",
"(",
"list",
"(",
"node",
".",
"ancestors",
"(",
")",
")",
")",
"if",
"nb_parents",
">",
"self",
".",
"config",
".",
"max_parents",
":",
"self",
".",
"add_message",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MisdesignChecker.leave_classdef | check number of public methods | pylint/checkers/design_analysis.py | def leave_classdef(self, node):
"""check number of public methods"""
my_methods = sum(
1 for method in node.mymethods() if not method.name.startswith("_")
)
# Does the class contain less than n public methods ?
# This checks only the methods defined in the current cl... | def leave_classdef(self, node):
"""check number of public methods"""
my_methods = sum(
1 for method in node.mymethods() if not method.name.startswith("_")
)
# Does the class contain less than n public methods ?
# This checks only the methods defined in the current cl... | [
"check",
"number",
"of",
"public",
"methods"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/design_analysis.py#L339-L378 | [
"def",
"leave_classdef",
"(",
"self",
",",
"node",
")",
":",
"my_methods",
"=",
"sum",
"(",
"1",
"for",
"method",
"in",
"node",
".",
"mymethods",
"(",
")",
"if",
"not",
"method",
".",
"name",
".",
"startswith",
"(",
"\"_\"",
")",
")",
"# Does the class... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MisdesignChecker.visit_functiondef | check function name, docstring, arguments, redefinition,
variable names, max locals | pylint/checkers/design_analysis.py | def visit_functiondef(self, node):
"""check function name, docstring, arguments, redefinition,
variable names, max locals
"""
# init branch and returns counters
self._returns.append(0)
# check number of arguments
args = node.args.args
ignored_argument_name... | def visit_functiondef(self, node):
"""check function name, docstring, arguments, redefinition,
variable names, max locals
"""
# init branch and returns counters
self._returns.append(0)
# check number of arguments
args = node.args.args
ignored_argument_name... | [
"check",
"function",
"name",
"docstring",
"arguments",
"redefinition",
"variable",
"names",
"max",
"locals"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/design_analysis.py#L388-L420 | [
"def",
"visit_functiondef",
"(",
"self",
",",
"node",
")",
":",
"# init branch and returns counters",
"self",
".",
"_returns",
".",
"append",
"(",
"0",
")",
"# check number of arguments",
"args",
"=",
"node",
".",
"args",
".",
"args",
"ignored_argument_names",
"="... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MisdesignChecker.leave_functiondef | most of the work is done here on close:
checks for max returns, branch, return in __init__ | pylint/checkers/design_analysis.py | def leave_functiondef(self, node):
"""most of the work is done here on close:
checks for max returns, branch, return in __init__
"""
returns = self._returns.pop()
if returns > self.config.max_returns:
self.add_message(
"too-many-return-statements",
... | def leave_functiondef(self, node):
"""most of the work is done here on close:
checks for max returns, branch, return in __init__
"""
returns = self._returns.pop()
if returns > self.config.max_returns:
self.add_message(
"too-many-return-statements",
... | [
"most",
"of",
"the",
"work",
"is",
"done",
"here",
"on",
"close",
":",
"checks",
"for",
"max",
"returns",
"branch",
"return",
"in",
"__init__"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/design_analysis.py#L431-L456 | [
"def",
"leave_functiondef",
"(",
"self",
",",
"node",
")",
":",
"returns",
"=",
"self",
".",
"_returns",
".",
"pop",
"(",
")",
"if",
"returns",
">",
"self",
".",
"config",
".",
"max_returns",
":",
"self",
".",
"add_message",
"(",
"\"too-many-return-stateme... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MisdesignChecker.visit_tryexcept | increments the branches counter | pylint/checkers/design_analysis.py | def visit_tryexcept(self, node):
"""increments the branches counter"""
branches = len(node.handlers)
if node.orelse:
branches += 1
self._inc_branch(node, branches)
self._inc_all_stmts(branches) | def visit_tryexcept(self, node):
"""increments the branches counter"""
branches = len(node.handlers)
if node.orelse:
branches += 1
self._inc_branch(node, branches)
self._inc_all_stmts(branches) | [
"increments",
"the",
"branches",
"counter"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/design_analysis.py#L473-L479 | [
"def",
"visit_tryexcept",
"(",
"self",
",",
"node",
")",
":",
"branches",
"=",
"len",
"(",
"node",
".",
"handlers",
")",
"if",
"node",
".",
"orelse",
":",
"branches",
"+=",
"1",
"self",
".",
"_inc_branch",
"(",
"node",
",",
"branches",
")",
"self",
"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MisdesignChecker.visit_if | increments the branches counter and checks boolean expressions | pylint/checkers/design_analysis.py | def visit_if(self, node):
"""increments the branches counter and checks boolean expressions"""
self._check_boolean_expressions(node)
branches = 1
# don't double count If nodes coming from some 'elif'
if node.orelse and (len(node.orelse) > 1 or not isinstance(node.orelse[0], If)):... | def visit_if(self, node):
"""increments the branches counter and checks boolean expressions"""
self._check_boolean_expressions(node)
branches = 1
# don't double count If nodes coming from some 'elif'
if node.orelse and (len(node.orelse) > 1 or not isinstance(node.orelse[0], If)):... | [
"increments",
"the",
"branches",
"counter",
"and",
"checks",
"boolean",
"expressions"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/design_analysis.py#L487-L495 | [
"def",
"visit_if",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"_check_boolean_expressions",
"(",
"node",
")",
"branches",
"=",
"1",
"# don't double count If nodes coming from some 'elif'",
"if",
"node",
".",
"orelse",
"and",
"(",
"len",
"(",
"node",
".",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MisdesignChecker._check_boolean_expressions | Go through "if" node `node` and counts its boolean expressions
if the "if" node test is a BoolOp node | pylint/checkers/design_analysis.py | def _check_boolean_expressions(self, node):
"""Go through "if" node `node` and counts its boolean expressions
if the "if" node test is a BoolOp node
"""
condition = node.test
if not isinstance(condition, BoolOp):
return
nb_bool_expr = _count_boolean_expressio... | def _check_boolean_expressions(self, node):
"""Go through "if" node `node` and counts its boolean expressions
if the "if" node test is a BoolOp node
"""
condition = node.test
if not isinstance(condition, BoolOp):
return
nb_bool_expr = _count_boolean_expressio... | [
"Go",
"through",
"if",
"node",
"node",
"and",
"counts",
"its",
"boolean",
"expressions"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/design_analysis.py#L497-L511 | [
"def",
"_check_boolean_expressions",
"(",
"self",
",",
"node",
")",
":",
"condition",
"=",
"node",
".",
"test",
"if",
"not",
"isinstance",
"(",
"condition",
",",
"BoolOp",
")",
":",
"return",
"nb_bool_expr",
"=",
"_count_boolean_expressions",
"(",
"condition",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MisdesignChecker.visit_while | increments the branches counter | pylint/checkers/design_analysis.py | def visit_while(self, node):
"""increments the branches counter"""
branches = 1
if node.orelse:
branches += 1
self._inc_branch(node, branches) | def visit_while(self, node):
"""increments the branches counter"""
branches = 1
if node.orelse:
branches += 1
self._inc_branch(node, branches) | [
"increments",
"the",
"branches",
"counter"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/design_analysis.py#L513-L518 | [
"def",
"visit_while",
"(",
"self",
",",
"node",
")",
":",
"branches",
"=",
"1",
"if",
"node",
".",
"orelse",
":",
"branches",
"+=",
"1",
"self",
".",
"_inc_branch",
"(",
"node",
",",
"branches",
")"
] | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | SpellingChecker._check_docstring | check the node has any spelling errors | pylint/checkers/spelling.py | def _check_docstring(self, node):
"""check the node has any spelling errors"""
docstring = node.doc
if not docstring:
return
start_line = node.lineno + 1
# Go through lines of docstring
for idx, line in enumerate(docstring.splitlines()):
self._ch... | def _check_docstring(self, node):
"""check the node has any spelling errors"""
docstring = node.doc
if not docstring:
return
start_line = node.lineno + 1
# Go through lines of docstring
for idx, line in enumerate(docstring.splitlines()):
self._ch... | [
"check",
"the",
"node",
"has",
"any",
"spelling",
"errors"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/spelling.py#L388-L398 | [
"def",
"_check_docstring",
"(",
"self",
",",
"node",
")",
":",
"docstring",
"=",
"node",
".",
"doc",
"if",
"not",
"docstring",
":",
"return",
"start_line",
"=",
"node",
".",
"lineno",
"+",
"1",
"# Go through lines of docstring",
"for",
"idx",
",",
"line",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | Message.format | Format the message according to the given template.
The template format is the one of the format method :
cf. http://docs.python.org/2/library/string.html#formatstrings | pylint/message/message.py | def format(self, template):
"""Format the message according to the given template.
The template format is the one of the format method :
cf. http://docs.python.org/2/library/string.html#formatstrings
"""
# For some reason, _asdict on derived namedtuples does not work with
... | def format(self, template):
"""Format the message according to the given template.
The template format is the one of the format method :
cf. http://docs.python.org/2/library/string.html#formatstrings
"""
# For some reason, _asdict on derived namedtuples does not work with
... | [
"Format",
"the",
"message",
"according",
"to",
"the",
"given",
"template",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message.py#L45-L53 | [
"def",
"format",
"(",
"self",
",",
"template",
")",
":",
"# For some reason, _asdict on derived namedtuples does not work with",
"# Python 3.4. Needs some investigation.",
"return",
"template",
".",
"format",
"(",
"*",
"*",
"dict",
"(",
"zip",
"(",
"self",
".",
"_fields... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | _is_len_call | Checks if node is len(SOMETHING). | pylint/checkers/refactoring.py | def _is_len_call(node):
"""Checks if node is len(SOMETHING)."""
return (
isinstance(node, astroid.Call)
and isinstance(node.func, astroid.Name)
and node.func.name == "len"
) | def _is_len_call(node):
"""Checks if node is len(SOMETHING)."""
return (
isinstance(node, astroid.Call)
and isinstance(node.func, astroid.Name)
and node.func.name == "len"
) | [
"Checks",
"if",
"node",
"is",
"len",
"(",
"SOMETHING",
")",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L47-L53 | [
"def",
"_is_len_call",
"(",
"node",
")",
":",
"return",
"(",
"isinstance",
"(",
"node",
",",
"astroid",
".",
"Call",
")",
"and",
"isinstance",
"(",
"node",
".",
"func",
",",
"astroid",
".",
"Name",
")",
"and",
"node",
".",
"func",
".",
"name",
"==",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | _is_trailing_comma | Check if the given token is a trailing comma
:param tokens: Sequence of modules tokens
:type tokens: list[tokenize.TokenInfo]
:param int index: Index of token under check in tokens
:returns: True if the token is a comma which trails an expression
:rtype: bool | pylint/checkers/refactoring.py | def _is_trailing_comma(tokens, index):
"""Check if the given token is a trailing comma
:param tokens: Sequence of modules tokens
:type tokens: list[tokenize.TokenInfo]
:param int index: Index of token under check in tokens
:returns: True if the token is a comma which trails an expression
:rtype... | def _is_trailing_comma(tokens, index):
"""Check if the given token is a trailing comma
:param tokens: Sequence of modules tokens
:type tokens: list[tokenize.TokenInfo]
:param int index: Index of token under check in tokens
:returns: True if the token is a comma which trails an expression
:rtype... | [
"Check",
"if",
"the",
"given",
"token",
"is",
"a",
"trailing",
"comma"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L65-L107 | [
"def",
"_is_trailing_comma",
"(",
"tokens",
",",
"index",
")",
":",
"token",
"=",
"tokens",
"[",
"index",
"]",
"if",
"token",
".",
"exact_type",
"!=",
"tokenize",
".",
"COMMA",
":",
"return",
"False",
"# Must have remaining tokens on the same line such as NEWLINE",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | register | Required method to auto register this checker. | pylint/checkers/refactoring.py | def register(linter):
"""Required method to auto register this checker."""
linter.register_checker(RefactoringChecker(linter))
linter.register_checker(NotChecker(linter))
linter.register_checker(RecommandationChecker(linter))
linter.register_checker(LenChecker(linter)) | def register(linter):
"""Required method to auto register this checker."""
linter.register_checker(RefactoringChecker(linter))
linter.register_checker(NotChecker(linter))
linter.register_checker(RecommandationChecker(linter))
linter.register_checker(LenChecker(linter)) | [
"Required",
"method",
"to",
"auto",
"register",
"this",
"checker",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L1376-L1381 | [
"def",
"register",
"(",
"linter",
")",
":",
"linter",
".",
"register_checker",
"(",
"RefactoringChecker",
"(",
"linter",
")",
")",
"linter",
".",
"register_checker",
"(",
"NotChecker",
"(",
"linter",
")",
")",
"linter",
".",
"register_checker",
"(",
"Recommand... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RefactoringChecker._is_actual_elif | Check if the given node is an actual elif
This is a problem we're having with the builtin ast module,
which splits `elif` branches into a separate if statement.
Unfortunately we need to know the exact type in certain
cases. | pylint/checkers/refactoring.py | def _is_actual_elif(self, node):
"""Check if the given node is an actual elif
This is a problem we're having with the builtin ast module,
which splits `elif` branches into a separate if statement.
Unfortunately we need to know the exact type in certain
cases.
"""
... | def _is_actual_elif(self, node):
"""Check if the given node is an actual elif
This is a problem we're having with the builtin ast module,
which splits `elif` branches into a separate if statement.
Unfortunately we need to know the exact type in certain
cases.
"""
... | [
"Check",
"if",
"the",
"given",
"node",
"is",
"an",
"actual",
"elif"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L319-L333 | [
"def",
"_is_actual_elif",
"(",
"self",
",",
"node",
")",
":",
"if",
"isinstance",
"(",
"node",
".",
"parent",
",",
"astroid",
".",
"If",
")",
":",
"orelse",
"=",
"node",
".",
"parent",
".",
"orelse",
"# current if node must directly follow an \"else\"",
"if",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RefactoringChecker._check_simplifiable_if | Check if the given if node can be simplified.
The if statement can be reduced to a boolean expression
in some cases. For instance, if there are two branches
and both of them return a boolean value that depends on
the result of the statement's test, then this can be reduced
to `b... | pylint/checkers/refactoring.py | def _check_simplifiable_if(self, node):
"""Check if the given if node can be simplified.
The if statement can be reduced to a boolean expression
in some cases. For instance, if there are two branches
and both of them return a boolean value that depends on
the result of the state... | def _check_simplifiable_if(self, node):
"""Check if the given if node can be simplified.
The if statement can be reduced to a boolean expression
in some cases. For instance, if there are two branches
and both of them return a boolean value that depends on
the result of the state... | [
"Check",
"if",
"the",
"given",
"if",
"node",
"can",
"be",
"simplified",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L335-L404 | [
"def",
"_check_simplifiable_if",
"(",
"self",
",",
"node",
")",
":",
"if",
"self",
".",
"_is_actual_elif",
"(",
"node",
")",
":",
"# Not interested in if statements with multiple branches.",
"return",
"if",
"len",
"(",
"node",
".",
"orelse",
")",
"!=",
"1",
"or"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RefactoringChecker._check_stop_iteration_inside_generator | Check if an exception of type StopIteration is raised inside a generator | pylint/checkers/refactoring.py | def _check_stop_iteration_inside_generator(self, node):
"""Check if an exception of type StopIteration is raised inside a generator"""
frame = node.frame()
if not isinstance(frame, astroid.FunctionDef) or not frame.is_generator():
return
if utils.node_ignores_exception(node, ... | def _check_stop_iteration_inside_generator(self, node):
"""Check if an exception of type StopIteration is raised inside a generator"""
frame = node.frame()
if not isinstance(frame, astroid.FunctionDef) or not frame.is_generator():
return
if utils.node_ignores_exception(node, ... | [
"Check",
"if",
"an",
"exception",
"of",
"type",
"StopIteration",
"is",
"raised",
"inside",
"a",
"generator"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L595-L608 | [
"def",
"_check_stop_iteration_inside_generator",
"(",
"self",
",",
"node",
")",
":",
"frame",
"=",
"node",
".",
"frame",
"(",
")",
"if",
"not",
"isinstance",
"(",
"frame",
",",
"astroid",
".",
"FunctionDef",
")",
"or",
"not",
"frame",
".",
"is_generator",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RefactoringChecker._check_exception_inherit_from_stopiteration | Return True if the exception node in argument inherit from StopIteration | pylint/checkers/refactoring.py | def _check_exception_inherit_from_stopiteration(exc):
"""Return True if the exception node in argument inherit from StopIteration"""
stopiteration_qname = "{}.StopIteration".format(utils.EXCEPTIONS_MODULE)
return any(_class.qname() == stopiteration_qname for _class in exc.mro()) | def _check_exception_inherit_from_stopiteration(exc):
"""Return True if the exception node in argument inherit from StopIteration"""
stopiteration_qname = "{}.StopIteration".format(utils.EXCEPTIONS_MODULE)
return any(_class.qname() == stopiteration_qname for _class in exc.mro()) | [
"Return",
"True",
"if",
"the",
"exception",
"node",
"in",
"argument",
"inherit",
"from",
"StopIteration"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L611-L614 | [
"def",
"_check_exception_inherit_from_stopiteration",
"(",
"exc",
")",
":",
"stopiteration_qname",
"=",
"\"{}.StopIteration\"",
".",
"format",
"(",
"utils",
".",
"EXCEPTIONS_MODULE",
")",
"return",
"any",
"(",
"_class",
".",
"qname",
"(",
")",
"==",
"stopiteration_q... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RefactoringChecker._check_raising_stopiteration_in_generator_next_call | Check if a StopIteration exception is raised by the call to next function
If the next value has a default value, then do not add message.
:param node: Check to see if this Call node is a next function
:type node: :class:`astroid.node_classes.Call` | pylint/checkers/refactoring.py | def _check_raising_stopiteration_in_generator_next_call(self, node):
"""Check if a StopIteration exception is raised by the call to next function
If the next value has a default value, then do not add message.
:param node: Check to see if this Call node is a next function
:type node: :... | def _check_raising_stopiteration_in_generator_next_call(self, node):
"""Check if a StopIteration exception is raised by the call to next function
If the next value has a default value, then do not add message.
:param node: Check to see if this Call node is a next function
:type node: :... | [
"Check",
"if",
"a",
"StopIteration",
"exception",
"is",
"raised",
"by",
"the",
"call",
"to",
"next",
"function"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L635-L667 | [
"def",
"_check_raising_stopiteration_in_generator_next_call",
"(",
"self",
",",
"node",
")",
":",
"def",
"_looks_like_infinite_iterator",
"(",
"param",
")",
":",
"inferred",
"=",
"utils",
".",
"safe_infer",
"(",
"param",
")",
"if",
"inferred",
":",
"return",
"infe... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RefactoringChecker._check_nested_blocks | Update and check the number of nested blocks | pylint/checkers/refactoring.py | def _check_nested_blocks(self, node):
"""Update and check the number of nested blocks
"""
# only check block levels inside functions or methods
if not isinstance(node.scope(), astroid.FunctionDef):
return
# messages are triggered on leaving the nested block. Here we s... | def _check_nested_blocks(self, node):
"""Update and check the number of nested blocks
"""
# only check block levels inside functions or methods
if not isinstance(node.scope(), astroid.FunctionDef):
return
# messages are triggered on leaving the nested block. Here we s... | [
"Update",
"and",
"check",
"the",
"number",
"of",
"nested",
"blocks"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L669-L694 | [
"def",
"_check_nested_blocks",
"(",
"self",
",",
"node",
")",
":",
"# only check block levels inside functions or methods",
"if",
"not",
"isinstance",
"(",
"node",
".",
"scope",
"(",
")",
",",
"astroid",
".",
"FunctionDef",
")",
":",
"return",
"# messages are trigge... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RefactoringChecker._duplicated_isinstance_types | Get the duplicated types from the underlying isinstance calls.
:param astroid.BoolOp node: Node which should contain a bunch of isinstance calls.
:returns: Dictionary of the comparison objects from the isinstance calls,
to duplicate values from consecutive calls.
:rtype: dict | pylint/checkers/refactoring.py | def _duplicated_isinstance_types(node):
"""Get the duplicated types from the underlying isinstance calls.
:param astroid.BoolOp node: Node which should contain a bunch of isinstance calls.
:returns: Dictionary of the comparison objects from the isinstance calls,
to duplicate v... | def _duplicated_isinstance_types(node):
"""Get the duplicated types from the underlying isinstance calls.
:param astroid.BoolOp node: Node which should contain a bunch of isinstance calls.
:returns: Dictionary of the comparison objects from the isinstance calls,
to duplicate v... | [
"Get",
"the",
"duplicated",
"types",
"from",
"the",
"underlying",
"isinstance",
"calls",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L705-L744 | [
"def",
"_duplicated_isinstance_types",
"(",
"node",
")",
":",
"duplicated_objects",
"=",
"set",
"(",
")",
"all_types",
"=",
"collections",
".",
"defaultdict",
"(",
"set",
")",
"for",
"call",
"in",
"node",
".",
"values",
":",
"if",
"not",
"isinstance",
"(",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RefactoringChecker._check_consider_merging_isinstance | Check isinstance calls which can be merged together. | pylint/checkers/refactoring.py | def _check_consider_merging_isinstance(self, node):
"""Check isinstance calls which can be merged together."""
if node.op != "or":
return
first_args = self._duplicated_isinstance_types(node)
for duplicated_name, class_names in first_args.items():
names = sorted(n... | def _check_consider_merging_isinstance(self, node):
"""Check isinstance calls which can be merged together."""
if node.op != "or":
return
first_args = self._duplicated_isinstance_types(node)
for duplicated_name, class_names in first_args.items():
names = sorted(n... | [
"Check",
"isinstance",
"calls",
"which",
"can",
"be",
"merged",
"together",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L746-L758 | [
"def",
"_check_consider_merging_isinstance",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"op",
"!=",
"\"or\"",
":",
"return",
"first_args",
"=",
"self",
".",
"_duplicated_isinstance_types",
"(",
"node",
")",
"for",
"duplicated_name",
",",
"class_names... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RefactoringChecker._check_chained_comparison | Check if there is any chained comparison in the expression.
Add a refactoring message if a boolOp contains comparison like a < b and b < c,
which can be chained as a < b < c.
Care is taken to avoid simplifying a < b < c and b < d. | pylint/checkers/refactoring.py | def _check_chained_comparison(self, node):
"""Check if there is any chained comparison in the expression.
Add a refactoring message if a boolOp contains comparison like a < b and b < c,
which can be chained as a < b < c.
Care is taken to avoid simplifying a < b < c and b < d.
"... | def _check_chained_comparison(self, node):
"""Check if there is any chained comparison in the expression.
Add a refactoring message if a boolOp contains comparison like a < b and b < c,
which can be chained as a < b < c.
Care is taken to avoid simplifying a < b < c and b < d.
"... | [
"Check",
"if",
"there",
"is",
"any",
"chained",
"comparison",
"in",
"the",
"expression",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L803-L852 | [
"def",
"_check_chained_comparison",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
".",
"op",
"!=",
"\"and\"",
"or",
"len",
"(",
"node",
".",
"values",
")",
"<",
"2",
":",
"return",
"def",
"_find_lower_upper_bounds",
"(",
"comparison_node",
",",
"uses",... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RefactoringChecker._check_consider_using_join | We start with the augmented assignment and work our way upwards.
Names of variables for nodes if match successful:
result = '' # assign
for number in ['1', '2', '3'] # for_loop
result += number # aug_assign | pylint/checkers/refactoring.py | def _check_consider_using_join(self, aug_assign):
"""
We start with the augmented assignment and work our way upwards.
Names of variables for nodes if match successful:
result = '' # assign
for number in ['1', '2', '3'] # for_loop
result += number # aug_assign
... | def _check_consider_using_join(self, aug_assign):
"""
We start with the augmented assignment and work our way upwards.
Names of variables for nodes if match successful:
result = '' # assign
for number in ['1', '2', '3'] # for_loop
result += number # aug_assign
... | [
"We",
"start",
"with",
"the",
"augmented",
"assignment",
"and",
"work",
"our",
"way",
"upwards",
".",
"Names",
"of",
"variables",
"for",
"nodes",
"if",
"match",
"successful",
":",
"result",
"=",
"#",
"assign",
"for",
"number",
"in",
"[",
"1",
"2",
"3",
... | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L923-L954 | [
"def",
"_check_consider_using_join",
"(",
"self",
",",
"aug_assign",
")",
":",
"for_loop",
"=",
"aug_assign",
".",
"parent",
"if",
"not",
"isinstance",
"(",
"for_loop",
",",
"astroid",
".",
"For",
")",
"or",
"len",
"(",
"for_loop",
".",
"body",
")",
">",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RefactoringChecker._is_and_or_ternary | Returns true if node is 'condition and true_value or false_value' form.
All of: condition, true_value and false_value should not be a complex boolean expression | pylint/checkers/refactoring.py | def _is_and_or_ternary(node):
"""
Returns true if node is 'condition and true_value or false_value' form.
All of: condition, true_value and false_value should not be a complex boolean expression
"""
return (
isinstance(node, astroid.BoolOp)
and node.op ==... | def _is_and_or_ternary(node):
"""
Returns true if node is 'condition and true_value or false_value' form.
All of: condition, true_value and false_value should not be a complex boolean expression
"""
return (
isinstance(node, astroid.BoolOp)
and node.op ==... | [
"Returns",
"true",
"if",
"node",
"is",
"condition",
"and",
"true_value",
"or",
"false_value",
"form",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L961-L976 | [
"def",
"_is_and_or_ternary",
"(",
"node",
")",
":",
"return",
"(",
"isinstance",
"(",
"node",
",",
"astroid",
".",
"BoolOp",
")",
"and",
"node",
".",
"op",
"==",
"\"or\"",
"and",
"len",
"(",
"node",
".",
"values",
")",
"==",
"2",
"and",
"isinstance",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RefactoringChecker._check_consistent_returns | Check that all return statements inside a function are consistent.
Return statements are consistent if:
- all returns are explicit and if there is no implicit return;
- all returns are empty and if there is, possibly, an implicit return.
Args:
node (astroid.Function... | pylint/checkers/refactoring.py | def _check_consistent_returns(self, node):
"""Check that all return statements inside a function are consistent.
Return statements are consistent if:
- all returns are explicit and if there is no implicit return;
- all returns are empty and if there is, possibly, an implicit ret... | def _check_consistent_returns(self, node):
"""Check that all return statements inside a function are consistent.
Return statements are consistent if:
- all returns are explicit and if there is no implicit return;
- all returns are empty and if there is, possibly, an implicit ret... | [
"Check",
"that",
"all",
"return",
"statements",
"inside",
"a",
"function",
"are",
"consistent",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L989-L1010 | [
"def",
"_check_consistent_returns",
"(",
"self",
",",
"node",
")",
":",
"# explicit return statements are those with a not None value",
"explicit_returns",
"=",
"[",
"_node",
"for",
"_node",
"in",
"self",
".",
"_return_nodes",
"[",
"node",
".",
"name",
"]",
"if",
"_... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RefactoringChecker._is_node_return_ended | Check if the node ends with an explicit return statement.
Args:
node (astroid.NodeNG): node to be checked.
Returns:
bool: True if the node ends with an explicit statement, False otherwise. | pylint/checkers/refactoring.py | def _is_node_return_ended(self, node):
"""Check if the node ends with an explicit return statement.
Args:
node (astroid.NodeNG): node to be checked.
Returns:
bool: True if the node ends with an explicit statement, False otherwise.
"""
# Recursion base ... | def _is_node_return_ended(self, node):
"""Check if the node ends with an explicit return statement.
Args:
node (astroid.NodeNG): node to be checked.
Returns:
bool: True if the node ends with an explicit statement, False otherwise.
"""
# Recursion base ... | [
"Check",
"if",
"the",
"node",
"ends",
"with",
"an",
"explicit",
"return",
"statement",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L1012-L1083 | [
"def",
"_is_node_return_ended",
"(",
"self",
",",
"node",
")",
":",
"# Recursion base case",
"if",
"isinstance",
"(",
"node",
",",
"astroid",
".",
"Return",
")",
":",
"return",
"True",
"if",
"isinstance",
"(",
"node",
",",
"astroid",
".",
"Call",
")",
":"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RefactoringChecker._check_return_at_the_end | Check for presence of a *single* return statement at the end of a
function. "return" or "return None" are useless because None is the
default return type if they are missing.
NOTE: produces a message only if there is a single return statement
in the function body. Otherwise _check_consi... | pylint/checkers/refactoring.py | def _check_return_at_the_end(self, node):
"""Check for presence of a *single* return statement at the end of a
function. "return" or "return None" are useless because None is the
default return type if they are missing.
NOTE: produces a message only if there is a single return statement... | def _check_return_at_the_end(self, node):
"""Check for presence of a *single* return statement at the end of a
function. "return" or "return None" are useless because None is the
default return type if they are missing.
NOTE: produces a message only if there is a single return statement... | [
"Check",
"for",
"presence",
"of",
"a",
"*",
"single",
"*",
"return",
"statement",
"at",
"the",
"end",
"of",
"a",
"function",
".",
"return",
"or",
"return",
"None",
"are",
"useless",
"because",
"None",
"is",
"the",
"default",
"return",
"type",
"if",
"they... | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L1099-L1121 | [
"def",
"_check_return_at_the_end",
"(",
"self",
",",
"node",
")",
":",
"if",
"len",
"(",
"self",
".",
"_return_nodes",
"[",
"node",
".",
"name",
"]",
")",
">",
"1",
":",
"return",
"if",
"len",
"(",
"node",
".",
"body",
")",
"<=",
"1",
":",
"return"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RecommandationChecker.visit_for | Emit a convention whenever range and len are used for indexing. | pylint/checkers/refactoring.py | def visit_for(self, node):
"""Emit a convention whenever range and len are used for indexing."""
# Verify that we have a `range([start], len(...), [stop])` call and
# that the object which is iterated is used as a subscript in the
# body of the for.
# Is it a proper range call?
... | def visit_for(self, node):
"""Emit a convention whenever range and len are used for indexing."""
# Verify that we have a `range([start], len(...), [stop])` call and
# that the object which is iterated is used as a subscript in the
# body of the for.
# Is it a proper range call?
... | [
"Emit",
"a",
"convention",
"whenever",
"range",
"and",
"len",
"are",
"used",
"for",
"indexing",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L1165-L1221 | [
"def",
"visit_for",
"(",
"self",
",",
"node",
")",
":",
"# Verify that we have a `range([start], len(...), [stop])` call and",
"# that the object which is iterated is used as a subscript in the",
"# body of the for.",
"# Is it a proper range call?",
"if",
"not",
"isinstance",
"(",
"n... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | LenChecker.visit_unaryop | `not len(S)` must become `not S` regardless if the parent block
is a test condition or something else (boolean expression)
e.g. `if not len(S):` | pylint/checkers/refactoring.py | def visit_unaryop(self, node):
"""`not len(S)` must become `not S` regardless if the parent block
is a test condition or something else (boolean expression)
e.g. `if not len(S):`"""
if (
isinstance(node, astroid.UnaryOp)
and node.op == "not"
and _is_le... | def visit_unaryop(self, node):
"""`not len(S)` must become `not S` regardless if the parent block
is a test condition or something else (boolean expression)
e.g. `if not len(S):`"""
if (
isinstance(node, astroid.UnaryOp)
and node.op == "not"
and _is_le... | [
"not",
"len",
"(",
"S",
")",
"must",
"become",
"not",
"S",
"regardless",
"if",
"the",
"parent",
"block",
"is",
"a",
"test",
"condition",
"or",
"something",
"else",
"(",
"boolean",
"expression",
")",
"e",
".",
"g",
".",
"if",
"not",
"len",
"(",
"S",
... | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/refactoring.py#L1364-L1373 | [
"def",
"visit_unaryop",
"(",
"self",
",",
"node",
")",
":",
"if",
"(",
"isinstance",
"(",
"node",
",",
"astroid",
".",
"UnaryOp",
")",
"and",
"node",
".",
"op",
"==",
"\"not\"",
"and",
"_is_len_call",
"(",
"node",
".",
"operand",
")",
")",
":",
"self... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | _check_graphviz_available | check if we need graphviz for different output format | pylint/pyreverse/main.py | def _check_graphviz_available(output_format):
"""check if we need graphviz for different output format"""
try:
subprocess.call(["dot", "-V"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except OSError:
print(
"The output format '%s' is currently not available.\n"
... | def _check_graphviz_available(output_format):
"""check if we need graphviz for different output format"""
try:
subprocess.call(["dot", "-V"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except OSError:
print(
"The output format '%s' is currently not available.\n"
... | [
"check",
"if",
"we",
"need",
"graphviz",
"for",
"different",
"output",
"format"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/pyreverse/main.py#L166-L176 | [
"def",
"_check_graphviz_available",
"(",
"output_format",
")",
":",
"try",
":",
"subprocess",
".",
"call",
"(",
"[",
"\"dot\"",
",",
"\"-V\"",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",
"PIPE",
")",
"except",... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | Run.run | checking arguments and run project | pylint/pyreverse/main.py | def run(self, args):
"""checking arguments and run project"""
if not args:
print(self.help())
return 1
# insert current working directory to the python path to recognize
# dependencies to local modules even if cwd is not in the PYTHONPATH
sys.path.insert(0... | def run(self, args):
"""checking arguments and run project"""
if not args:
print(self.help())
return 1
# insert current working directory to the python path to recognize
# dependencies to local modules even if cwd is not in the PYTHONPATH
sys.path.insert(0... | [
"checking",
"arguments",
"and",
"run",
"project"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/pyreverse/main.py#L193-L217 | [
"def",
"run",
"(",
"self",
",",
"args",
")",
":",
"if",
"not",
"args",
":",
"print",
"(",
"self",
".",
"help",
"(",
")",
")",
"return",
"1",
"# insert current working directory to the python path to recognize",
"# dependencies to local modules even if cwd is not in the ... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | OverlappingExceptionsChecker.visit_tryexcept | check for empty except | pylint/extensions/overlapping_exceptions.py | def visit_tryexcept(self, node):
"""check for empty except"""
for handler in node.handlers:
if handler.type is None:
continue
if isinstance(handler.type, astroid.BoolOp):
continue
try:
excs = list(_annotated_unpack_infer... | def visit_tryexcept(self, node):
"""check for empty except"""
for handler in node.handlers:
if handler.type is None:
continue
if isinstance(handler.type, astroid.BoolOp):
continue
try:
excs = list(_annotated_unpack_infer... | [
"check",
"for",
"empty",
"except"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/extensions/overlapping_exceptions.py#L34-L83 | [
"def",
"visit_tryexcept",
"(",
"self",
",",
"node",
")",
":",
"for",
"handler",
"in",
"node",
".",
"handlers",
":",
"if",
"handler",
".",
"type",
"is",
"None",
":",
"continue",
"if",
"isinstance",
"(",
"handler",
".",
"type",
",",
"astroid",
".",
"Bool... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | DiagramWriter.write | write files for <project> according to <diadefs> | pylint/pyreverse/writer.py | def write(self, diadefs):
"""write files for <project> according to <diadefs>
"""
for diagram in diadefs:
basename = diagram.title.strip().replace(" ", "_")
file_name = "%s.%s" % (basename, self.config.output_format)
self.set_printer(file_name, basename)
... | def write(self, diadefs):
"""write files for <project> according to <diadefs>
"""
for diagram in diadefs:
basename = diagram.title.strip().replace(" ", "_")
file_name = "%s.%s" % (basename, self.config.output_format)
self.set_printer(file_name, basename)
... | [
"write",
"files",
"for",
"<project",
">",
"according",
"to",
"<diadefs",
">"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/pyreverse/writer.py#L30-L41 | [
"def",
"write",
"(",
"self",
",",
"diadefs",
")",
":",
"for",
"diagram",
"in",
"diadefs",
":",
"basename",
"=",
"diagram",
".",
"title",
".",
"strip",
"(",
")",
".",
"replace",
"(",
"\" \"",
",",
"\"_\"",
")",
"file_name",
"=",
"\"%s.%s\"",
"%",
"(",... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | DiagramWriter.write_packages | write a package diagram | pylint/pyreverse/writer.py | def write_packages(self, diagram):
"""write a package diagram"""
# sorted to get predictable (hence testable) results
for i, obj in enumerate(sorted(diagram.modules(), key=lambda x: x.title)):
self.printer.emit_node(i, label=self.get_title(obj), shape="box")
obj.fig_id = ... | def write_packages(self, diagram):
"""write a package diagram"""
# sorted to get predictable (hence testable) results
for i, obj in enumerate(sorted(diagram.modules(), key=lambda x: x.title)):
self.printer.emit_node(i, label=self.get_title(obj), shape="box")
obj.fig_id = ... | [
"write",
"a",
"package",
"diagram"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/pyreverse/writer.py#L43-L53 | [
"def",
"write_packages",
"(",
"self",
",",
"diagram",
")",
":",
"# sorted to get predictable (hence testable) results",
"for",
"i",
",",
"obj",
"in",
"enumerate",
"(",
"sorted",
"(",
"diagram",
".",
"modules",
"(",
")",
",",
"key",
"=",
"lambda",
"x",
":",
"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | DiagramWriter.write_classes | write a class diagram | pylint/pyreverse/writer.py | def write_classes(self, diagram):
"""write a class diagram"""
# sorted to get predictable (hence testable) results
for i, obj in enumerate(sorted(diagram.objects, key=lambda x: x.title)):
self.printer.emit_node(i, **self.get_values(obj))
obj.fig_id = i
# inheritan... | def write_classes(self, diagram):
"""write a class diagram"""
# sorted to get predictable (hence testable) results
for i, obj in enumerate(sorted(diagram.objects, key=lambda x: x.title)):
self.printer.emit_node(i, **self.get_values(obj))
obj.fig_id = i
# inheritan... | [
"write",
"a",
"class",
"diagram"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/pyreverse/writer.py#L55-L78 | [
"def",
"write_classes",
"(",
"self",
",",
"diagram",
")",
":",
"# sorted to get predictable (hence testable) results",
"for",
"i",
",",
"obj",
"in",
"enumerate",
"(",
"sorted",
"(",
"diagram",
".",
"objects",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
".",
"t... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | DotWriter.set_printer | initialize DotWriter and add options for layout. | pylint/pyreverse/writer.py | def set_printer(self, file_name, basename):
"""initialize DotWriter and add options for layout.
"""
layout = dict(rankdir="BT")
self.printer = DotBackend(basename, additional_param=layout)
self.file_name = file_name | def set_printer(self, file_name, basename):
"""initialize DotWriter and add options for layout.
"""
layout = dict(rankdir="BT")
self.printer = DotBackend(basename, additional_param=layout)
self.file_name = file_name | [
"initialize",
"DotWriter",
"and",
"add",
"options",
"for",
"layout",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/pyreverse/writer.py#L112-L117 | [
"def",
"set_printer",
"(",
"self",
",",
"file_name",
",",
"basename",
")",
":",
"layout",
"=",
"dict",
"(",
"rankdir",
"=",
"\"BT\"",
")",
"self",
".",
"printer",
"=",
"DotBackend",
"(",
"basename",
",",
"additional_param",
"=",
"layout",
")",
"self",
".... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | DotWriter.get_values | get label and shape for classes.
The label contains all attributes and methods | pylint/pyreverse/writer.py | def get_values(self, obj):
"""get label and shape for classes.
The label contains all attributes and methods
"""
label = obj.title
if obj.shape == "interface":
label = "«interface»\\n%s" % label
if not self.config.only_classnames:
label = r"%s|%s\... | def get_values(self, obj):
"""get label and shape for classes.
The label contains all attributes and methods
"""
label = obj.title
if obj.shape == "interface":
label = "«interface»\\n%s" % label
if not self.config.only_classnames:
label = r"%s|%s\... | [
"get",
"label",
"and",
"shape",
"for",
"classes",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/pyreverse/writer.py#L123-L139 | [
"def",
"get_values",
"(",
"self",
",",
"obj",
")",
":",
"label",
"=",
"obj",
".",
"title",
"if",
"obj",
".",
"shape",
"==",
"\"interface\"",
":",
"label",
"=",
"\"«interface»\\\\n%s\" %",
"l",
"bel",
"if",
"not",
"self",
".",
"config",
".",
"only_classna... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | VCGWriter.set_printer | initialize VCGWriter for a UML graph | pylint/pyreverse/writer.py | def set_printer(self, file_name, basename):
"""initialize VCGWriter for a UML graph"""
self.graph_file = open(file_name, "w+")
self.printer = VCGPrinter(self.graph_file)
self.printer.open_graph(
title=basename,
layoutalgorithm="dfs",
late_edge_labels="... | def set_printer(self, file_name, basename):
"""initialize VCGWriter for a UML graph"""
self.graph_file = open(file_name, "w+")
self.printer = VCGPrinter(self.graph_file)
self.printer.open_graph(
title=basename,
layoutalgorithm="dfs",
late_edge_labels="... | [
"initialize",
"VCGWriter",
"for",
"a",
"UML",
"graph"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/pyreverse/writer.py#L164-L176 | [
"def",
"set_printer",
"(",
"self",
",",
"file_name",
",",
"basename",
")",
":",
"self",
".",
"graph_file",
"=",
"open",
"(",
"file_name",
",",
"\"w+\"",
")",
"self",
".",
"printer",
"=",
"VCGPrinter",
"(",
"self",
".",
"graph_file",
")",
"self",
".",
"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | VCGWriter.get_values | get label and shape for classes.
The label contains all attributes and methods | pylint/pyreverse/writer.py | def get_values(self, obj):
"""get label and shape for classes.
The label contains all attributes and methods
"""
if is_exception(obj.node):
label = r"\fb\f09%s\fn" % obj.title
else:
label = r"\fb%s\fn" % obj.title
if obj.shape == "interface":
... | def get_values(self, obj):
"""get label and shape for classes.
The label contains all attributes and methods
"""
if is_exception(obj.node):
label = r"\fb\f09%s\fn" % obj.title
else:
label = r"\fb%s\fn" % obj.title
if obj.shape == "interface":
... | [
"get",
"label",
"and",
"shape",
"for",
"classes",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/pyreverse/writer.py#L182-L208 | [
"def",
"get_values",
"(",
"self",
",",
"obj",
")",
":",
"if",
"is_exception",
"(",
"obj",
".",
"node",
")",
":",
"label",
"=",
"r\"\\fb\\f09%s\\fn\"",
"%",
"obj",
".",
"title",
"else",
":",
"label",
"=",
"r\"\\fb%s\\fn\"",
"%",
"obj",
".",
"title",
"if... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MessageDefinition.may_be_emitted | return True if message may be emitted using the current interpreter | pylint/message/message_definition.py | def may_be_emitted(self):
"""return True if message may be emitted using the current interpreter"""
if self.minversion is not None and self.minversion > sys.version_info:
return False
if self.maxversion is not None and self.maxversion <= sys.version_info:
return False
... | def may_be_emitted(self):
"""return True if message may be emitted using the current interpreter"""
if self.minversion is not None and self.minversion > sys.version_info:
return False
if self.maxversion is not None and self.maxversion <= sys.version_info:
return False
... | [
"return",
"True",
"if",
"message",
"may",
"be",
"emitted",
"using",
"the",
"current",
"interpreter"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_definition.py#L43-L49 | [
"def",
"may_be_emitted",
"(",
"self",
")",
":",
"if",
"self",
".",
"minversion",
"is",
"not",
"None",
"and",
"self",
".",
"minversion",
">",
"sys",
".",
"version_info",
":",
"return",
"False",
"if",
"self",
".",
"maxversion",
"is",
"not",
"None",
"and",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MessageDefinition.format_help | return the help string for the given message id | pylint/message/message_definition.py | def format_help(self, checkerref=False):
"""return the help string for the given message id"""
desc = self.descr
if checkerref:
desc += " This message belongs to the %s checker." % self.checker.name
title = self.msg
if self.symbol:
msgid = "%s (%s)" % (sel... | def format_help(self, checkerref=False):
"""return the help string for the given message id"""
desc = self.descr
if checkerref:
desc += " This message belongs to the %s checker." % self.checker.name
title = self.msg
if self.symbol:
msgid = "%s (%s)" % (sel... | [
"return",
"the",
"help",
"string",
"for",
"the",
"given",
"message",
"id"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_definition.py#L51-L77 | [
"def",
"format_help",
"(",
"self",
",",
"checkerref",
"=",
"False",
")",
":",
"desc",
"=",
"self",
".",
"descr",
"if",
"checkerref",
":",
"desc",
"+=",
"\" This message belongs to the %s checker.\"",
"%",
"self",
".",
"checker",
".",
"name",
"title",
"=",
"s... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MyRawChecker.process_module | process a module
the module's content is accessible via node.stream() function | examples/custom_raw.py | def process_module(self, node):
"""process a module
the module's content is accessible via node.stream() function
"""
with node.stream() as stream:
for (lineno, line) in enumerate(stream):
if line.rstrip().endswith("\\"):
self.add_message(... | def process_module(self, node):
"""process a module
the module's content is accessible via node.stream() function
"""
with node.stream() as stream:
for (lineno, line) in enumerate(stream):
if line.rstrip().endswith("\\"):
self.add_message(... | [
"process",
"a",
"module"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/examples/custom_raw.py#L25-L33 | [
"def",
"process_module",
"(",
"self",
",",
"node",
")",
":",
"with",
"node",
".",
"stream",
"(",
")",
"as",
"stream",
":",
"for",
"(",
"lineno",
",",
"line",
")",
"in",
"enumerate",
"(",
"stream",
")",
":",
"if",
"line",
".",
"rstrip",
"(",
")",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | _get_env | Extracts the environment PYTHONPATH and appends the current sys.path to
those. | pylint/epylint.py | def _get_env():
"""Extracts the environment PYTHONPATH and appends the current sys.path to
those."""
env = dict(os.environ)
env["PYTHONPATH"] = os.pathsep.join(sys.path)
return env | def _get_env():
"""Extracts the environment PYTHONPATH and appends the current sys.path to
those."""
env = dict(os.environ)
env["PYTHONPATH"] = os.pathsep.join(sys.path)
return env | [
"Extracts",
"the",
"environment",
"PYTHONPATH",
"and",
"appends",
"the",
"current",
"sys",
".",
"path",
"to",
"those",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/epylint.py#L65-L70 | [
"def",
"_get_env",
"(",
")",
":",
"env",
"=",
"dict",
"(",
"os",
".",
"environ",
")",
"env",
"[",
"\"PYTHONPATH\"",
"]",
"=",
"os",
".",
"pathsep",
".",
"join",
"(",
"sys",
".",
"path",
")",
"return",
"env"
] | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | lint | Pylint the given file.
When run from emacs we will be in the directory of a file, and passed its
filename. If this file is part of a package and is trying to import other
modules from within its own package or another package rooted in a directory
below it, pylint will classify it as a failed import.
... | pylint/epylint.py | def lint(filename, options=()):
"""Pylint the given file.
When run from emacs we will be in the directory of a file, and passed its
filename. If this file is part of a package and is trying to import other
modules from within its own package or another package rooted in a directory
below it, pylin... | def lint(filename, options=()):
"""Pylint the given file.
When run from emacs we will be in the directory of a file, and passed its
filename. If this file is part of a package and is trying to import other
modules from within its own package or another package rooted in a directory
below it, pylin... | [
"Pylint",
"the",
"given",
"file",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/epylint.py#L73-L128 | [
"def",
"lint",
"(",
"filename",
",",
"options",
"=",
"(",
")",
")",
":",
"# traverse downwards until we are out of a python package",
"full_path",
"=",
"osp",
".",
"abspath",
"(",
"filename",
")",
"parent_path",
"=",
"osp",
".",
"dirname",
"(",
"full_path",
")",... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | py_run | Run pylint from python
``command_options`` is a string containing ``pylint`` command line options;
``return_std`` (boolean) indicates return of created standard output
and error (see below);
``stdout`` and ``stderr`` are 'file-like' objects in which standard output
could be written.
Calling ag... | pylint/epylint.py | def py_run(command_options="", return_std=False, stdout=None, stderr=None):
"""Run pylint from python
``command_options`` is a string containing ``pylint`` command line options;
``return_std`` (boolean) indicates return of created standard output
and error (see below);
``stdout`` and ``stderr`` are... | def py_run(command_options="", return_std=False, stdout=None, stderr=None):
"""Run pylint from python
``command_options`` is a string containing ``pylint`` command line options;
``return_std`` (boolean) indicates return of created standard output
and error (see below);
``stdout`` and ``stderr`` are... | [
"Run",
"pylint",
"from",
"python"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/epylint.py#L131-L184 | [
"def",
"py_run",
"(",
"command_options",
"=",
"\"\"",
",",
"return_std",
"=",
"False",
",",
"stdout",
"=",
"None",
",",
"stderr",
"=",
"None",
")",
":",
"# Detect if we use Python as executable or not, else default to `python`",
"executable",
"=",
"sys",
".",
"execu... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | target_info_from_filename | Transforms /some/path/foo.png into ('/some/path', 'foo.png', 'png'). | pylint/graph.py | def target_info_from_filename(filename):
"""Transforms /some/path/foo.png into ('/some/path', 'foo.png', 'png')."""
basename = osp.basename(filename)
storedir = osp.dirname(osp.abspath(filename))
target = filename.split(".")[-1]
return storedir, basename, target | def target_info_from_filename(filename):
"""Transforms /some/path/foo.png into ('/some/path', 'foo.png', 'png')."""
basename = osp.basename(filename)
storedir = osp.dirname(osp.abspath(filename))
target = filename.split(".")[-1]
return storedir, basename, target | [
"Transforms",
"/",
"some",
"/",
"path",
"/",
"foo",
".",
"png",
"into",
"(",
"/",
"some",
"/",
"path",
"foo",
".",
"png",
"png",
")",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/graph.py#L21-L26 | [
"def",
"target_info_from_filename",
"(",
"filename",
")",
":",
"basename",
"=",
"osp",
".",
"basename",
"(",
"filename",
")",
"storedir",
"=",
"osp",
".",
"dirname",
"(",
"osp",
".",
"abspath",
"(",
"filename",
")",
")",
"target",
"=",
"filename",
".",
"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | get_cycles | given a dictionary representing an ordered graph (i.e. key are vertices
and values is a list of destination vertices representing edges), return a
list of detected cycles | pylint/graph.py | def get_cycles(graph_dict, vertices=None):
"""given a dictionary representing an ordered graph (i.e. key are vertices
and values is a list of destination vertices representing edges), return a
list of detected cycles
"""
if not graph_dict:
return ()
result = []
if vertices is None:
... | def get_cycles(graph_dict, vertices=None):
"""given a dictionary representing an ordered graph (i.e. key are vertices
and values is a list of destination vertices representing edges), return a
list of detected cycles
"""
if not graph_dict:
return ()
result = []
if vertices is None:
... | [
"given",
"a",
"dictionary",
"representing",
"an",
"ordered",
"graph",
"(",
"i",
".",
"e",
".",
"key",
"are",
"vertices",
"and",
"values",
"is",
"a",
"list",
"of",
"destination",
"vertices",
"representing",
"edges",
")",
"return",
"a",
"list",
"of",
"detect... | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/graph.py#L158-L170 | [
"def",
"get_cycles",
"(",
"graph_dict",
",",
"vertices",
"=",
"None",
")",
":",
"if",
"not",
"graph_dict",
":",
"return",
"(",
")",
"result",
"=",
"[",
"]",
"if",
"vertices",
"is",
"None",
":",
"vertices",
"=",
"graph_dict",
".",
"keys",
"(",
")",
"f... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | _get_cycles | recursive function doing the real work for get_cycles | pylint/graph.py | def _get_cycles(graph_dict, path, visited, result, vertice):
"""recursive function doing the real work for get_cycles"""
if vertice in path:
cycle = [vertice]
for node in path[::-1]:
if node == vertice:
break
cycle.insert(0, node)
# make a canonica... | def _get_cycles(graph_dict, path, visited, result, vertice):
"""recursive function doing the real work for get_cycles"""
if vertice in path:
cycle = [vertice]
for node in path[::-1]:
if node == vertice:
break
cycle.insert(0, node)
# make a canonica... | [
"recursive",
"function",
"doing",
"the",
"real",
"work",
"for",
"get_cycles"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/graph.py#L173-L198 | [
"def",
"_get_cycles",
"(",
"graph_dict",
",",
"path",
",",
"visited",
",",
"result",
",",
"vertice",
")",
":",
"if",
"vertice",
"in",
"path",
":",
"cycle",
"=",
"[",
"vertice",
"]",
"for",
"node",
"in",
"path",
"[",
":",
":",
"-",
"1",
"]",
":",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | DotBackend.get_source | returns self._source | pylint/graph.py | def get_source(self):
"""returns self._source"""
if self._source is None:
self.emit("}\n")
self._source = "\n".join(self.lines)
del self.lines
return self._source | def get_source(self):
"""returns self._source"""
if self._source is None:
self.emit("}\n")
self._source = "\n".join(self.lines)
del self.lines
return self._source | [
"returns",
"self",
".",
"_source"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/graph.py#L63-L69 | [
"def",
"get_source",
"(",
"self",
")",
":",
"if",
"self",
".",
"_source",
"is",
"None",
":",
"self",
".",
"emit",
"(",
"\"}\\n\"",
")",
"self",
".",
"_source",
"=",
"\"\\n\"",
".",
"join",
"(",
"self",
".",
"lines",
")",
"del",
"self",
".",
"lines"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | DotBackend.generate | Generates a graph file.
:param str outputfile: filename and path [defaults to graphname.png]
:param str dotfile: filename and path [defaults to graphname.dot]
:param str mapfile: filename and path
:rtype: str
:return: a path to the generated file | pylint/graph.py | def generate(self, outputfile=None, dotfile=None, mapfile=None):
"""Generates a graph file.
:param str outputfile: filename and path [defaults to graphname.png]
:param str dotfile: filename and path [defaults to graphname.dot]
:param str mapfile: filename and path
:rtype: str
... | def generate(self, outputfile=None, dotfile=None, mapfile=None):
"""Generates a graph file.
:param str outputfile: filename and path [defaults to graphname.png]
:param str dotfile: filename and path [defaults to graphname.dot]
:param str mapfile: filename and path
:rtype: str
... | [
"Generates",
"a",
"graph",
"file",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/graph.py#L73-L131 | [
"def",
"generate",
"(",
"self",
",",
"outputfile",
"=",
"None",
",",
"dotfile",
"=",
"None",
",",
"mapfile",
"=",
"None",
")",
":",
"import",
"subprocess",
"# introduced in py 2.4",
"name",
"=",
"self",
".",
"graphname",
"if",
"not",
"dotfile",
":",
"# if ... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | DotBackend.emit_edge | emit an edge from <name1> to <name2>.
edge properties: see http://www.graphviz.org/doc/info/attrs.html | pylint/graph.py | def emit_edge(self, name1, name2, **props):
"""emit an edge from <name1> to <name2>.
edge properties: see http://www.graphviz.org/doc/info/attrs.html
"""
attrs = ['%s="%s"' % (prop, value) for prop, value in props.items()]
n_from, n_to = normalize_node_id(name1), normalize_node_i... | def emit_edge(self, name1, name2, **props):
"""emit an edge from <name1> to <name2>.
edge properties: see http://www.graphviz.org/doc/info/attrs.html
"""
attrs = ['%s="%s"' % (prop, value) for prop, value in props.items()]
n_from, n_to = normalize_node_id(name1), normalize_node_i... | [
"emit",
"an",
"edge",
"from",
"<name1",
">",
"to",
"<name2",
">",
".",
"edge",
"properties",
":",
"see",
"http",
":",
"//",
"www",
".",
"graphviz",
".",
"org",
"/",
"doc",
"/",
"info",
"/",
"attrs",
".",
"html"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/graph.py#L137-L143 | [
"def",
"emit_edge",
"(",
"self",
",",
"name1",
",",
"name2",
",",
"*",
"*",
"props",
")",
":",
"attrs",
"=",
"[",
"'%s=\"%s\"'",
"%",
"(",
"prop",
",",
"value",
")",
"for",
"prop",
",",
"value",
"in",
"props",
".",
"items",
"(",
")",
"]",
"n_from... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | DotBackend.emit_node | emit a node with given properties.
node properties: see http://www.graphviz.org/doc/info/attrs.html | pylint/graph.py | def emit_node(self, name, **props):
"""emit a node with given properties.
node properties: see http://www.graphviz.org/doc/info/attrs.html
"""
attrs = ['%s="%s"' % (prop, value) for prop, value in props.items()]
self.emit("%s [%s];" % (normalize_node_id(name), ", ".join(sorted(at... | def emit_node(self, name, **props):
"""emit a node with given properties.
node properties: see http://www.graphviz.org/doc/info/attrs.html
"""
attrs = ['%s="%s"' % (prop, value) for prop, value in props.items()]
self.emit("%s [%s];" % (normalize_node_id(name), ", ".join(sorted(at... | [
"emit",
"a",
"node",
"with",
"given",
"properties",
".",
"node",
"properties",
":",
"see",
"http",
":",
"//",
"www",
".",
"graphviz",
".",
"org",
"/",
"doc",
"/",
"info",
"/",
"attrs",
".",
"html"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/graph.py#L145-L150 | [
"def",
"emit_node",
"(",
"self",
",",
"name",
",",
"*",
"*",
"props",
")",
":",
"attrs",
"=",
"[",
"'%s=\"%s\"'",
"%",
"(",
"prop",
",",
"value",
")",
"for",
"prop",
",",
"value",
"in",
"props",
".",
"items",
"(",
")",
"]",
"self",
".",
"emit",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | report_raw_stats | calculate percentage of code / doc / comment / empty | pylint/checkers/raw_metrics.py | def report_raw_stats(sect, stats, _):
"""calculate percentage of code / doc / comment / empty
"""
total_lines = stats["total_lines"]
if not total_lines:
raise EmptyReportError()
sect.description = "%s lines have been analyzed" % total_lines
lines = ("type", "number", "%", "previous", "di... | def report_raw_stats(sect, stats, _):
"""calculate percentage of code / doc / comment / empty
"""
total_lines = stats["total_lines"]
if not total_lines:
raise EmptyReportError()
sect.description = "%s lines have been analyzed" % total_lines
lines = ("type", "number", "%", "previous", "di... | [
"calculate",
"percentage",
"of",
"code",
"/",
"doc",
"/",
"comment",
"/",
"empty"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/raw_metrics.py#L27-L40 | [
"def",
"report_raw_stats",
"(",
"sect",
",",
"stats",
",",
"_",
")",
":",
"total_lines",
"=",
"stats",
"[",
"\"total_lines\"",
"]",
"if",
"not",
"total_lines",
":",
"raise",
"EmptyReportError",
"(",
")",
"sect",
".",
"description",
"=",
"\"%s lines have been a... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | get_type | return the line type : docstring, comment, code, empty | pylint/checkers/raw_metrics.py | def get_type(tokens, start_index):
"""return the line type : docstring, comment, code, empty"""
i = start_index
tok_type = tokens[i][0]
start = tokens[i][2]
pos = start
line_type = None
while i < len(tokens) and tokens[i][2][0] == start[0]:
tok_type = tokens[i][0]
pos = token... | def get_type(tokens, start_index):
"""return the line type : docstring, comment, code, empty"""
i = start_index
tok_type = tokens[i][0]
start = tokens[i][2]
pos = start
line_type = None
while i < len(tokens) and tokens[i][2][0] == start[0]:
tok_type = tokens[i][0]
pos = token... | [
"return",
"the",
"line",
"type",
":",
"docstring",
"comment",
"code",
"empty"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/raw_metrics.py#L90-L114 | [
"def",
"get_type",
"(",
"tokens",
",",
"start_index",
")",
":",
"i",
"=",
"start_index",
"tok_type",
"=",
"tokens",
"[",
"i",
"]",
"[",
"0",
"]",
"start",
"=",
"tokens",
"[",
"i",
"]",
"[",
"2",
"]",
"pos",
"=",
"start",
"line_type",
"=",
"None",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RawMetricsChecker.open | init statistics | pylint/checkers/raw_metrics.py | def open(self):
"""init statistics"""
self.stats = self.linter.add_stats(
total_lines=0,
code_lines=0,
empty_lines=0,
docstring_lines=0,
comment_lines=0,
) | def open(self):
"""init statistics"""
self.stats = self.linter.add_stats(
total_lines=0,
code_lines=0,
empty_lines=0,
docstring_lines=0,
comment_lines=0,
) | [
"init",
"statistics"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/raw_metrics.py#L67-L75 | [
"def",
"open",
"(",
"self",
")",
":",
"self",
".",
"stats",
"=",
"self",
".",
"linter",
".",
"add_stats",
"(",
"total_lines",
"=",
"0",
",",
"code_lines",
"=",
"0",
",",
"empty_lines",
"=",
"0",
",",
"docstring_lines",
"=",
"0",
",",
"comment_lines",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | RawMetricsChecker.process_tokens | update stats | pylint/checkers/raw_metrics.py | def process_tokens(self, tokens):
"""update stats"""
i = 0
tokens = list(tokens)
while i < len(tokens):
i, lines_number, line_type = get_type(tokens, i)
self.stats["total_lines"] += lines_number
self.stats[line_type] += lines_number | def process_tokens(self, tokens):
"""update stats"""
i = 0
tokens = list(tokens)
while i < len(tokens):
i, lines_number, line_type = get_type(tokens, i)
self.stats["total_lines"] += lines_number
self.stats[line_type] += lines_number | [
"update",
"stats"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/raw_metrics.py#L77-L84 | [
"def",
"process_tokens",
"(",
"self",
",",
"tokens",
")",
":",
"i",
"=",
"0",
"tokens",
"=",
"list",
"(",
"tokens",
")",
"while",
"i",
"<",
"len",
"(",
"tokens",
")",
":",
"i",
",",
"lines_number",
",",
"line_type",
"=",
"get_type",
"(",
"tokens",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | _rest_format_section | format an options section using as ReST formatted output | pylint/message/message_handler_mix_in.py | def _rest_format_section(stream, section, options, doc=None):
"""format an options section using as ReST formatted output"""
if section:
print("%s\n%s" % (section, "'" * len(section)), file=stream)
if doc:
print(normalize_text(doc, line_len=79, indent=""), file=stream)
print(file=str... | def _rest_format_section(stream, section, options, doc=None):
"""format an options section using as ReST formatted output"""
if section:
print("%s\n%s" % (section, "'" * len(section)), file=stream)
if doc:
print(normalize_text(doc, line_len=79, indent=""), file=stream)
print(file=str... | [
"format",
"an",
"options",
"section",
"using",
"as",
"ReST",
"formatted",
"output"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_handler_mix_in.py#L33-L49 | [
"def",
"_rest_format_section",
"(",
"stream",
",",
"section",
",",
"options",
",",
"doc",
"=",
"None",
")",
":",
"if",
"section",
":",
"print",
"(",
"\"%s\\n%s\"",
"%",
"(",
"section",
",",
"\"'\"",
"*",
"len",
"(",
"section",
")",
")",
",",
"file",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MessagesHandlerMixIn._register_by_id_managed_msg | If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid. | pylint/message/message_handler_mix_in.py | def _register_by_id_managed_msg(self, msgid, line, is_disabled=True):
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid."""
try:
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_... | def _register_by_id_managed_msg(self, msgid, line, is_disabled=True):
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid."""
try:
message_definitions = self.msgs_store.get_message_definitions(msgid)
for message_... | [
"If",
"the",
"msgid",
"is",
"a",
"numeric",
"one",
"then",
"register",
"it",
"to",
"inform",
"the",
"user",
"it",
"could",
"furnish",
"instead",
"a",
"symbolic",
"msgid",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_handler_mix_in.py#L76-L93 | [
"def",
"_register_by_id_managed_msg",
"(",
"self",
",",
"msgid",
",",
"line",
",",
"is_disabled",
"=",
"True",
")",
":",
"try",
":",
"message_definitions",
"=",
"self",
".",
"msgs_store",
".",
"get_message_definitions",
"(",
"msgid",
")",
"for",
"message_definit... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MessagesHandlerMixIn.disable | don't output message of the given id | pylint/message/message_handler_mix_in.py | def disable(self, msgid, scope="package", line=None, ignore_unknown=False):
"""don't output message of the given id"""
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(self, msgid, scope="package", line=None, ignore_unknown=False):
"""don't output message of the given id"""
self._set_msg_status(
msgid, enable=False, scope=scope, line=line, ignore_unknown=ignore_unknown
)
self._register_by_id_managed_msg(msgid, line) | [
"don",
"t",
"output",
"message",
"of",
"the",
"given",
"id"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_handler_mix_in.py#L95-L100 | [
"def",
"disable",
"(",
"self",
",",
"msgid",
",",
"scope",
"=",
"\"package\"",
",",
"line",
"=",
"None",
",",
"ignore_unknown",
"=",
"False",
")",
":",
"self",
".",
"_set_msg_status",
"(",
"msgid",
",",
"enable",
"=",
"False",
",",
"scope",
"=",
"scope... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MessagesHandlerMixIn.enable | reenable message of the given id | pylint/message/message_handler_mix_in.py | def enable(self, msgid, scope="package", line=None, ignore_unknown=False):
"""reenable message of the given id"""
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) | def enable(self, msgid, scope="package", line=None, ignore_unknown=False):
"""reenable message of the given id"""
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) | [
"reenable",
"message",
"of",
"the",
"given",
"id"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_handler_mix_in.py#L102-L107 | [
"def",
"enable",
"(",
"self",
",",
"msgid",
",",
"scope",
"=",
"\"package\"",
",",
"line",
"=",
"None",
",",
"ignore_unknown",
"=",
"False",
")",
":",
"self",
".",
"_set_msg_status",
"(",
"msgid",
",",
"enable",
"=",
"True",
",",
"scope",
"=",
"scope",... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MessagesHandlerMixIn._message_symbol | Get the message symbol of the given message id
Return the original message id if the message does not
exist. | pylint/message/message_handler_mix_in.py | def _message_symbol(self, msgid):
"""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 UnknownMessageError:
... | def _message_symbol(self, msgid):
"""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 UnknownMessageError:
... | [
"Get",
"the",
"message",
"symbol",
"of",
"the",
"given",
"message",
"id"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_handler_mix_in.py#L176-L185 | [
"def",
"_message_symbol",
"(",
"self",
",",
"msgid",
")",
":",
"try",
":",
"return",
"[",
"md",
".",
"symbol",
"for",
"md",
"in",
"self",
".",
"msgs_store",
".",
"get_message_definitions",
"(",
"msgid",
")",
"]",
"except",
"UnknownMessageError",
":",
"retu... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MessagesHandlerMixIn.get_message_state_scope | Returns the scope at which a message was enabled/disabled. | pylint/message/message_handler_mix_in.py | def get_message_state_scope(self, msgid, line=None, confidence=UNDEFINED):
"""Returns the scope at which a message was enabled/disabled."""
if self.config.confidence and confidence.name not in self.config.confidence:
return MSG_STATE_CONFIDENCE
try:
if line in self.file_s... | def get_message_state_scope(self, msgid, line=None, confidence=UNDEFINED):
"""Returns the scope at which a message was enabled/disabled."""
if self.config.confidence and confidence.name not in self.config.confidence:
return MSG_STATE_CONFIDENCE
try:
if line in self.file_s... | [
"Returns",
"the",
"scope",
"at",
"which",
"a",
"message",
"was",
"enabled",
"/",
"disabled",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_handler_mix_in.py#L187-L196 | [
"def",
"get_message_state_scope",
"(",
"self",
",",
"msgid",
",",
"line",
"=",
"None",
",",
"confidence",
"=",
"UNDEFINED",
")",
":",
"if",
"self",
".",
"config",
".",
"confidence",
"and",
"confidence",
".",
"name",
"not",
"in",
"self",
".",
"config",
".... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MessagesHandlerMixIn.is_message_enabled | return true if the message associated to the given message id is
enabled
msgid may be either a numeric or symbolic message id. | pylint/message/message_handler_mix_in.py | def is_message_enabled(self, msg_descr, line=None, confidence=None):
"""return true if the message associated to the given message id is
enabled
msgid may be either a numeric or symbolic message id.
"""
if self.config.confidence and confidence:
if confidence.name not... | def is_message_enabled(self, msg_descr, line=None, confidence=None):
"""return true if the message associated to the given message id is
enabled
msgid may be either a numeric or symbolic message id.
"""
if self.config.confidence and confidence:
if confidence.name not... | [
"return",
"true",
"if",
"the",
"message",
"associated",
"to",
"the",
"given",
"message",
"id",
"is",
"enabled"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_handler_mix_in.py#L198-L218 | [
"def",
"is_message_enabled",
"(",
"self",
",",
"msg_descr",
",",
"line",
"=",
"None",
",",
"confidence",
"=",
"None",
")",
":",
"if",
"self",
".",
"config",
".",
"confidence",
"and",
"confidence",
":",
"if",
"confidence",
".",
"name",
"not",
"in",
"self"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MessagesHandlerMixIn.add_message | 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. | pylint/message/message_handler_mix_in.py | def add_message(
self,
msg_descr,
line=None,
node=None,
args=None,
confidence=UNDEFINED,
col_offset=None,
):
"""Adds a message given by ID or name.
If provided, the message string is expanded using args.
AST checkers must provide the ... | def add_message(
self,
msg_descr,
line=None,
node=None,
args=None,
confidence=UNDEFINED,
col_offset=None,
):
"""Adds a message given by ID or name.
If provided, the message string is expanded using args.
AST checkers must provide the ... | [
"Adds",
"a",
"message",
"given",
"by",
"ID",
"or",
"name",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_handler_mix_in.py#L251-L272 | [
"def",
"add_message",
"(",
"self",
",",
"msg_descr",
",",
"line",
"=",
"None",
",",
"node",
"=",
"None",
",",
"args",
"=",
"None",
",",
"confidence",
"=",
"UNDEFINED",
",",
"col_offset",
"=",
"None",
",",
")",
":",
"message_definitions",
"=",
"self",
"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MessagesHandlerMixIn.print_full_documentation | output a full documentation in ReST format | pylint/message/message_handler_mix_in.py | def print_full_documentation(self, stream=None):
"""output a full documentation in ReST format"""
if not stream:
stream = sys.stdout
print("Pylint global options and switches", file=stream)
print("----------------------------------", file=stream)
print("", file=strea... | def print_full_documentation(self, stream=None):
"""output a full documentation in ReST format"""
if not stream:
stream = sys.stdout
print("Pylint global options and switches", file=stream)
print("----------------------------------", file=stream)
print("", file=strea... | [
"output",
"a",
"full",
"documentation",
"in",
"ReST",
"format"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_handler_mix_in.py#L350-L400 | [
"def",
"print_full_documentation",
"(",
"self",
",",
"stream",
"=",
"None",
")",
":",
"if",
"not",
"stream",
":",
"stream",
"=",
"sys",
".",
"stdout",
"print",
"(",
"\"Pylint global options and switches\"",
",",
"file",
"=",
"stream",
")",
"print",
"(",
"\"-... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | MessagesHandlerMixIn._print_checker_doc | Helper method for print_full_documentation.
Also used by doc/exts/pylint_extensions.py. | pylint/message/message_handler_mix_in.py | def _print_checker_doc(checker_name, info, stream=None):
"""Helper method for print_full_documentation.
Also used by doc/exts/pylint_extensions.py.
"""
if not stream:
stream = sys.stdout
doc = info.get("doc")
module = info.get("module")
msgs = info.g... | def _print_checker_doc(checker_name, info, stream=None):
"""Helper method for print_full_documentation.
Also used by doc/exts/pylint_extensions.py.
"""
if not stream:
stream = sys.stdout
doc = info.get("doc")
module = info.get("module")
msgs = info.g... | [
"Helper",
"method",
"for",
"print_full_documentation",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/message/message_handler_mix_in.py#L403-L459 | [
"def",
"_print_checker_doc",
"(",
"checker_name",
",",
"info",
",",
"stream",
"=",
"None",
")",
":",
"if",
"not",
"stream",
":",
"stream",
"=",
"sys",
".",
"stdout",
"doc",
"=",
"info",
".",
"get",
"(",
"\"doc\"",
")",
"module",
"=",
"info",
".",
"ge... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | _get_indent_length | Return the length of the indentation on the given token's line. | pylint/checkers/format.py | def _get_indent_length(line):
"""Return the length of the indentation on the given token's line."""
result = 0
for char in line:
if char == " ":
result += 1
elif char == "\t":
result += _TAB_LENGTH
else:
break
return result | def _get_indent_length(line):
"""Return the length of the indentation on the given token's line."""
result = 0
for char in line:
if char == " ":
result += 1
elif char == "\t":
result += _TAB_LENGTH
else:
break
return result | [
"Return",
"the",
"length",
"of",
"the",
"indentation",
"on",
"the",
"given",
"token",
"s",
"line",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/format.py#L260-L270 | [
"def",
"_get_indent_length",
"(",
"line",
")",
":",
"result",
"=",
"0",
"for",
"char",
"in",
"line",
":",
"if",
"char",
"==",
"\" \"",
":",
"result",
"+=",
"1",
"elif",
"char",
"==",
"\"\\t\"",
":",
"result",
"+=",
"_TAB_LENGTH",
"else",
":",
"break",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | _get_indent_hint_line | Return a line with |s for each of the positions in the given lists. | pylint/checkers/format.py | def _get_indent_hint_line(bar_positions, bad_position):
"""Return a line with |s for each of the positions in the given lists."""
if not bar_positions:
return ("", "")
# TODO tabs should not be replaced by some random (8) number of spaces
bar_positions = [_get_indent_length(indent) for indent in... | def _get_indent_hint_line(bar_positions, bad_position):
"""Return a line with |s for each of the positions in the given lists."""
if not bar_positions:
return ("", "")
# TODO tabs should not be replaced by some random (8) number of spaces
bar_positions = [_get_indent_length(indent) for indent in... | [
"Return",
"a",
"line",
"with",
"|s",
"for",
"each",
"of",
"the",
"positions",
"in",
"the",
"given",
"lists",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/format.py#L273-L297 | [
"def",
"_get_indent_hint_line",
"(",
"bar_positions",
",",
"bad_position",
")",
":",
"if",
"not",
"bar_positions",
":",
"return",
"(",
"\"\"",
",",
"\"\"",
")",
"# TODO tabs should not be replaced by some random (8) number of spaces",
"bar_positions",
"=",
"[",
"_get_inde... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | TokenWrapper.token_indent | Get an indentation string for hanging indentation, consisting of the line-indent plus
a number of spaces to fill up to the column of this token.
e.g. the token indent for foo
in "<TAB><TAB>print(foo)"
is "<TAB><TAB> " | pylint/checkers/format.py | def token_indent(self, idx):
"""Get an indentation string for hanging indentation, consisting of the line-indent plus
a number of spaces to fill up to the column of this token.
e.g. the token indent for foo
in "<TAB><TAB>print(foo)"
is "<TAB><TAB> "
"""
line... | def token_indent(self, idx):
"""Get an indentation string for hanging indentation, consisting of the line-indent plus
a number of spaces to fill up to the column of this token.
e.g. the token indent for foo
in "<TAB><TAB>print(foo)"
is "<TAB><TAB> "
"""
line... | [
"Get",
"an",
"indentation",
"string",
"for",
"hanging",
"indentation",
"consisting",
"of",
"the",
"line",
"-",
"indent",
"plus",
"a",
"number",
"of",
"spaces",
"to",
"fill",
"up",
"to",
"the",
"column",
"of",
"this",
"token",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/format.py#L393-L402 | [
"def",
"token_indent",
"(",
"self",
",",
"idx",
")",
":",
"line_indent",
"=",
"self",
".",
"line_indent",
"(",
"idx",
")",
"return",
"line_indent",
"+",
"\" \"",
"*",
"(",
"self",
".",
"start_col",
"(",
"idx",
")",
"-",
"len",
"(",
"line_indent",
")",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | ContinuedLineState.handle_line_start | Record the first non-junk token at the start of a line. | pylint/checkers/format.py | def handle_line_start(self, pos):
"""Record the first non-junk token at the start of a line."""
if self._line_start > -1:
return
check_token_position = pos
if self._tokens.token(pos) == _ASYNC_TOKEN:
check_token_position += 1
self._is_block_opener = (
... | def handle_line_start(self, pos):
"""Record the first non-junk token at the start of a line."""
if self._line_start > -1:
return
check_token_position = pos
if self._tokens.token(pos) == _ASYNC_TOKEN:
check_token_position += 1
self._is_block_opener = (
... | [
"Record",
"the",
"first",
"non",
"-",
"junk",
"token",
"at",
"the",
"start",
"of",
"a",
"line",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/format.py#L432-L443 | [
"def",
"handle_line_start",
"(",
"self",
",",
"pos",
")",
":",
"if",
"self",
".",
"_line_start",
">",
"-",
"1",
":",
"return",
"check_token_position",
"=",
"pos",
"if",
"self",
".",
"_tokens",
".",
"token",
"(",
"pos",
")",
"==",
"_ASYNC_TOKEN",
":",
"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | ContinuedLineState.get_valid_indentations | Returns the valid offsets for the token at the given position. | pylint/checkers/format.py | def get_valid_indentations(self, idx):
"""Returns the valid offsets for the token at the given position."""
# The closing brace on a dict or the 'for' in a dict comprehension may
# reset two indent levels because the dict value is ended implicitly
stack_top = -1
if (
... | def get_valid_indentations(self, idx):
"""Returns the valid offsets for the token at the given position."""
# The closing brace on a dict or the 'for' in a dict comprehension may
# reset two indent levels because the dict value is ended implicitly
stack_top = -1
if (
... | [
"Returns",
"the",
"valid",
"offsets",
"for",
"the",
"token",
"at",
"the",
"given",
"position",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/format.py#L462-L477 | [
"def",
"get_valid_indentations",
"(",
"self",
",",
"idx",
")",
":",
"# The closing brace on a dict or the 'for' in a dict comprehension may",
"# reset two indent levels because the dict value is ended implicitly",
"stack_top",
"=",
"-",
"1",
"if",
"(",
"self",
".",
"_tokens",
"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | ContinuedLineState._hanging_indent_after_bracket | Extracts indentation information for a hanging indent
Case of hanging indent after a bracket (including parenthesis)
:param str bracket: bracket in question
:param int position: Position of bracket in self._tokens
:returns: the state and valid positions for hanging indentation
... | pylint/checkers/format.py | def _hanging_indent_after_bracket(self, bracket, position):
"""Extracts indentation information for a hanging indent
Case of hanging indent after a bracket (including parenthesis)
:param str bracket: bracket in question
:param int position: Position of bracket in self._tokens
... | def _hanging_indent_after_bracket(self, bracket, position):
"""Extracts indentation information for a hanging indent
Case of hanging indent after a bracket (including parenthesis)
:param str bracket: bracket in question
:param int position: Position of bracket in self._tokens
... | [
"Extracts",
"indentation",
"information",
"for",
"a",
"hanging",
"indent"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/format.py#L479-L528 | [
"def",
"_hanging_indent_after_bracket",
"(",
"self",
",",
"bracket",
",",
"position",
")",
":",
"indentation",
"=",
"self",
".",
"_tokens",
".",
"line_indent",
"(",
"position",
")",
"if",
"(",
"self",
".",
"_is_block_opener",
"and",
"self",
".",
"_continuation... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | ContinuedLineState._continuation_inside_bracket | Extracts indentation information for a continued indent. | pylint/checkers/format.py | def _continuation_inside_bracket(self, bracket, position):
"""Extracts indentation information for a continued indent."""
indentation = self._tokens.line_indent(position)
token_indent = self._tokens.token_indent(position)
next_token_indent = self._tokens.token_indent(position + 1)
... | def _continuation_inside_bracket(self, bracket, position):
"""Extracts indentation information for a continued indent."""
indentation = self._tokens.line_indent(position)
token_indent = self._tokens.token_indent(position)
next_token_indent = self._tokens.token_indent(position + 1)
... | [
"Extracts",
"indentation",
"information",
"for",
"a",
"continued",
"indent",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/format.py#L530-L554 | [
"def",
"_continuation_inside_bracket",
"(",
"self",
",",
"bracket",
",",
"position",
")",
":",
"indentation",
"=",
"self",
".",
"_tokens",
".",
"line_indent",
"(",
"position",
")",
"token_indent",
"=",
"self",
".",
"_tokens",
".",
"token_indent",
"(",
"positio... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | ContinuedLineState.push_token | Pushes a new token for continued indentation on the stack.
Tokens that can modify continued indentation offsets are:
* opening brackets
* 'lambda'
* : inside dictionaries
push_token relies on the caller to filter out those
interesting tokens.
:param int t... | pylint/checkers/format.py | def push_token(self, token, position):
"""Pushes a new token for continued indentation on the stack.
Tokens that can modify continued indentation offsets are:
* opening brackets
* 'lambda'
* : inside dictionaries
push_token relies on the caller to filter out those... | def push_token(self, token, position):
"""Pushes a new token for continued indentation on the stack.
Tokens that can modify continued indentation offsets are:
* opening brackets
* 'lambda'
* : inside dictionaries
push_token relies on the caller to filter out those... | [
"Pushes",
"a",
"new",
"token",
"for",
"continued",
"indentation",
"on",
"the",
"stack",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/format.py#L559-L576 | [
"def",
"push_token",
"(",
"self",
",",
"token",
",",
"position",
")",
":",
"if",
"_token_followed_by_eol",
"(",
"self",
".",
"_tokens",
",",
"position",
")",
":",
"self",
".",
"_cont_stack",
".",
"append",
"(",
"self",
".",
"_hanging_indent_after_bracket",
"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | FormatChecker.new_line | a new line has been encountered, process it if necessary | pylint/checkers/format.py | def new_line(self, tokens, line_end, line_start):
"""a new line has been encountered, process it if necessary"""
if _last_token_on_line_is(tokens, line_end, ";"):
self.add_message("unnecessary-semicolon", line=tokens.start_line(line_end))
line_num = tokens.start_line(line_start)
... | def new_line(self, tokens, line_end, line_start):
"""a new line has been encountered, process it if necessary"""
if _last_token_on_line_is(tokens, line_end, ";"):
self.add_message("unnecessary-semicolon", line=tokens.start_line(line_end))
line_num = tokens.start_line(line_start)
... | [
"a",
"new",
"line",
"has",
"been",
"encountered",
"process",
"it",
"if",
"necessary"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/format.py#L716-L725 | [
"def",
"new_line",
"(",
"self",
",",
"tokens",
",",
"line_end",
",",
"line_start",
")",
":",
"if",
"_last_token_on_line_is",
"(",
"tokens",
",",
"line_end",
",",
"\";\"",
")",
":",
"self",
".",
"add_message",
"(",
"\"unnecessary-semicolon\"",
",",
"line",
"=... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | FormatChecker._check_keyword_parentheses | Check that there are not unnecessary parens after a keyword.
Parens are unnecessary if there is exactly one balanced outer pair on a
line, and it is followed by a colon, and contains no commas (i.e. is not a
tuple).
Args:
tokens: list of Tokens; the entire list of Tokens.
... | pylint/checkers/format.py | def _check_keyword_parentheses(self, tokens, start):
"""Check that there are not unnecessary parens after a keyword.
Parens are unnecessary if there is exactly one balanced outer pair on a
line, and it is followed by a colon, and contains no commas (i.e. is not a
tuple).
Args:
... | def _check_keyword_parentheses(self, tokens, start):
"""Check that there are not unnecessary parens after a keyword.
Parens are unnecessary if there is exactly one balanced outer pair on a
line, and it is followed by a colon, and contains no commas (i.e. is not a
tuple).
Args:
... | [
"Check",
"that",
"there",
"are",
"not",
"unnecessary",
"parens",
"after",
"a",
"keyword",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/format.py#L730-L804 | [
"def",
"_check_keyword_parentheses",
"(",
"self",
",",
"tokens",
",",
"start",
")",
":",
"# If the next token is not a paren, we're fine.",
"if",
"self",
".",
"_inside_brackets",
"(",
"\":\"",
")",
"and",
"tokens",
"[",
"start",
"]",
"[",
"1",
"]",
"==",
"\"for\... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | FormatChecker._has_valid_type_annotation | Extended check of PEP-484 type hint presence | pylint/checkers/format.py | def _has_valid_type_annotation(self, tokens, i):
"""Extended check of PEP-484 type hint presence"""
if not self._inside_brackets("("):
return False
# token_info
# type string start end line
# 0 1 2 3 4
bracket_level = 0
for token in tok... | def _has_valid_type_annotation(self, tokens, i):
"""Extended check of PEP-484 type hint presence"""
if not self._inside_brackets("("):
return False
# token_info
# type string start end line
# 0 1 2 3 4
bracket_level = 0
for token in tok... | [
"Extended",
"check",
"of",
"PEP",
"-",
"484",
"type",
"hint",
"presence"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/format.py#L835-L859 | [
"def",
"_has_valid_type_annotation",
"(",
"self",
",",
"tokens",
",",
"i",
")",
":",
"if",
"not",
"self",
".",
"_inside_brackets",
"(",
"\"(\"",
")",
":",
"return",
"False",
"# token_info",
"# type string start end line",
"# 0 1 2 3 4",
"bracket_level"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | FormatChecker._check_equals_spacing | Check the spacing of a single equals sign. | pylint/checkers/format.py | def _check_equals_spacing(self, tokens, i):
"""Check the spacing of a single equals sign."""
if self._has_valid_type_annotation(tokens, i):
self._check_space(tokens, i, (_MUST, _MUST))
elif self._inside_brackets("(") or self._inside_brackets("lambda"):
self._check_space(t... | def _check_equals_spacing(self, tokens, i):
"""Check the spacing of a single equals sign."""
if self._has_valid_type_annotation(tokens, i):
self._check_space(tokens, i, (_MUST, _MUST))
elif self._inside_brackets("(") or self._inside_brackets("lambda"):
self._check_space(t... | [
"Check",
"the",
"spacing",
"of",
"a",
"single",
"equals",
"sign",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/format.py#L861-L868 | [
"def",
"_check_equals_spacing",
"(",
"self",
",",
"tokens",
",",
"i",
")",
":",
"if",
"self",
".",
"_has_valid_type_annotation",
"(",
"tokens",
",",
"i",
")",
":",
"self",
".",
"_check_space",
"(",
"tokens",
",",
"i",
",",
"(",
"_MUST",
",",
"_MUST",
"... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | FormatChecker._check_surrounded_by_space | Check that a binary operator is surrounded by exactly one space. | pylint/checkers/format.py | def _check_surrounded_by_space(self, tokens, i):
"""Check that a binary operator is surrounded by exactly one space."""
self._check_space(tokens, i, (_MUST, _MUST)) | def _check_surrounded_by_space(self, tokens, i):
"""Check that a binary operator is surrounded by exactly one space."""
self._check_space(tokens, i, (_MUST, _MUST)) | [
"Check",
"that",
"a",
"binary",
"operator",
"is",
"surrounded",
"by",
"exactly",
"one",
"space",
"."
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/format.py#L898-L900 | [
"def",
"_check_surrounded_by_space",
"(",
"self",
",",
"tokens",
",",
"i",
")",
":",
"self",
".",
"_check_space",
"(",
"tokens",
",",
"i",
",",
"(",
"_MUST",
",",
"_MUST",
")",
")"
] | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
test | FormatChecker.process_tokens | process tokens and search for :
_ non strict indentation (i.e. not always using the <indent> parameter as
indent unit)
_ too long lines (i.e. longer than <max_chars>)
_ optionally bad construct (if given, bad_construct must be a compiled
regular expression). | pylint/checkers/format.py | def process_tokens(self, tokens):
"""process tokens and search for :
_ non strict indentation (i.e. not always using the <indent> parameter as
indent unit)
_ too long lines (i.e. longer than <max_chars>)
_ optionally bad construct (if given, bad_construct must be a compile... | def process_tokens(self, tokens):
"""process tokens and search for :
_ non strict indentation (i.e. not always using the <indent> parameter as
indent unit)
_ too long lines (i.e. longer than <max_chars>)
_ optionally bad construct (if given, bad_construct must be a compile... | [
"process",
"tokens",
"and",
"search",
"for",
":"
] | PyCQA/pylint | python | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/format.py#L974-L1072 | [
"def",
"process_tokens",
"(",
"self",
",",
"tokens",
")",
":",
"self",
".",
"_bracket_stack",
"=",
"[",
"None",
"]",
"indents",
"=",
"[",
"0",
"]",
"check_equal",
"=",
"False",
"line_num",
"=",
"0",
"self",
".",
"_lines",
"=",
"{",
"}",
"self",
".",
... | 2bf5c61a3ff6ae90613b81679de42c0f19aea600 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.