summaryrefslogtreecommitdiff
path: root/pylint
diff options
context:
space:
mode:
authorOllie <46904826+ollie-iterators@users.noreply.github.com>2023-02-25 16:12:29 -0500
committerGitHub <noreply@github.com>2023-02-25 22:12:29 +0100
commit02030cf52dbbed3a8bb7c14c4d6158427635cee5 (patch)
tree5c1006b9695be3a05870070c30f55784172e068a /pylint
parentc785e3edb82683e50d5d370c1c4e992ebda036a0 (diff)
downloadpylint-git-02030cf52dbbed3a8bb7c14c4d6158427635cee5.tar.gz
Fixing some too long lines (#8339)
* Changing flake8 max-line-length to 120 Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'pylint')
-rw-r--r--pylint/checkers/base/name_checker/naming_style.py5
-rw-r--r--pylint/checkers/classes/class_checker.py6
-rw-r--r--pylint/checkers/refactoring/refactoring_checker.py26
-rw-r--r--pylint/checkers/similar.py6
-rw-r--r--pylint/checkers/unicode.py5
-rw-r--r--pylint/config/config_file_parser.py4
-rw-r--r--pylint/extensions/confusing_elif.py3
-rw-r--r--pylint/extensions/private_import.py9
-rw-r--r--pylint/lint/pylinter.py12
-rw-r--r--pylint/reporters/text.py3
10 files changed, 51 insertions, 28 deletions
diff --git a/pylint/checkers/base/name_checker/naming_style.py b/pylint/checkers/base/name_checker/naming_style.py
index 3b7833049..bfe6f77d3 100644
--- a/pylint/checkers/base/name_checker/naming_style.py
+++ b/pylint/checkers/base/name_checker/naming_style.py
@@ -149,7 +149,10 @@ def _create_naming_options() -> Options:
help_msg = f"Regular expression matching correct {human_readable_name} names. "
if name_type in KNOWN_NAME_TYPES_WITH_STYLE:
help_msg += f"Overrides {name_type_hyphened}-naming-style. "
- help_msg += f"If left empty, {human_readable_name} names will be checked with the set naming style."
+ help_msg += (
+ f"If left empty, {human_readable_name} names will be checked "
+ "with the set naming style."
+ )
# Add style option for names that support it
if name_type in KNOWN_NAME_TYPES_WITH_STYLE:
diff --git a/pylint/checkers/classes/class_checker.py b/pylint/checkers/classes/class_checker.py
index e66e543f2..fe29c9d60 100644
--- a/pylint/checkers/classes/class_checker.py
+++ b/pylint/checkers/classes/class_checker.py
@@ -958,7 +958,8 @@ a metaclass class method.",
):
continue
for child in node.nodes_of_class((nodes.Name, nodes.Attribute)):
- # Check for cases where the functions are used as a variable instead of as a method call
+ # Check for cases where the functions are used as a variable instead of as a
+ # method call
if isinstance(child, nodes.Name) and child.name == function_def.name:
break
if isinstance(child, nodes.Attribute):
@@ -1951,7 +1952,8 @@ a metaclass class method.",
return
self._first_attrs[-1] = None
elif "builtins.staticmethod" in node.decoratornames():
- # Check if there is a decorator which is not named `staticmethod` but is assigned to one.
+ # Check if there is a decorator which is not named `staticmethod`
+ # but is assigned to one.
return
# class / regular method with no args
elif not (
diff --git a/pylint/checkers/refactoring/refactoring_checker.py b/pylint/checkers/refactoring/refactoring_checker.py
index 5aaedf794..b3e48f31e 100644
--- a/pylint/checkers/refactoring/refactoring_checker.py
+++ b/pylint/checkers/refactoring/refactoring_checker.py
@@ -460,8 +460,9 @@ class RefactoringChecker(checkers.BaseTokenChecker):
"R1732": (
"Consider using 'with' for resource-allocating operations",
"consider-using-with",
- "Emitted if a resource-allocating assignment or call may be replaced by a 'with' block. "
- "By using 'with' the release of the allocated resources is ensured even in the case of an exception.",
+ "Emitted if a resource-allocating assignment or call may be replaced by a 'with' block."
+ "By using 'with' the release of the allocated resources is ensured even in the case "
+ "of an exception.",
),
"R1733": (
"Unnecessary dictionary index lookup, use '%s' instead",
@@ -713,8 +714,9 @@ class RefactoringChecker(checkers.BaseTokenChecker):
for var, names in node.items:
if isinstance(var, nodes.Name):
for stack in self._consider_using_with_stack:
- # We don't need to restrict the stacks we search to the current scope and outer scopes,
- # as e.g. the function_scope stack will be empty when we check a ``with`` on the class level.
+ # We don't need to restrict the stacks we search to the current scope and
+ # outer scopes, as e.g. the function_scope stack will be empty when we
+ # check a ``with`` on the class level.
if var.name in stack:
del stack[var.name]
break
@@ -1118,7 +1120,8 @@ class RefactoringChecker(checkers.BaseTokenChecker):
def _check_quit_exit_call(self, node: nodes.Call) -> None:
if isinstance(node.func, nodes.Name) and node.func.name in BUILTIN_EXIT_FUNCS:
- # If we have `exit` imported from `sys` in the current or global scope, exempt this instance.
+ # If we have `exit` imported from `sys` in the current or global scope,
+ # exempt this instance.
local_scope = node.scope()
if self._has_exit_in_scope(local_scope) or self._has_exit_in_scope(
node.root()
@@ -1553,7 +1556,8 @@ class RefactoringChecker(checkers.BaseTokenChecker):
def _append_context_managers_to_stack(self, node: nodes.Assign) -> None:
if _is_inside_context_manager(node):
- # if we are inside a context manager itself, we assume that it will handle the resource management itself.
+ # if we are inside a context manager itself, we assume that it will handle
+ # the resource management itself.
return
if isinstance(node.targets[0], (nodes.Tuple, nodes.List, nodes.Set)):
assignees = node.targets[0].elts
@@ -1600,9 +1604,10 @@ class RefactoringChecker(checkers.BaseTokenChecker):
def _check_consider_using_with(self, node: nodes.Call) -> None:
if _is_inside_context_manager(node) or _is_a_return_statement(node):
- # If we are inside a context manager itself, we assume that it will handle the resource management itself.
- # If the node is a child of a return, we assume that the caller knows he is getting a context manager
- # he should use properly (i.e. in a ``with``).
+ # If we are inside a context manager itself, we assume that it will handle the
+ # resource management itself.
+ # If the node is a child of a return, we assume that the caller knows he is getting
+ # a context manager he should use properly (i.e. in a ``with``).
return
if (
node
@@ -1610,7 +1615,8 @@ class RefactoringChecker(checkers.BaseTokenChecker):
node.frame(future=True)
).values()
):
- # the result of this call was already assigned to a variable and will be checked when leaving the scope.
+ # the result of this call was already assigned to a variable and will be
+ # checked when leaving the scope.
return
inferred = utils.safe_infer(node.func)
if not inferred or not isinstance(
diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py
index bc485a981..2cfba16bf 100644
--- a/pylint/checkers/similar.py
+++ b/pylint/checkers/similar.py
@@ -377,7 +377,8 @@ class Similar:
raise ValueError
readlines = decoding_stream(stream, encoding).readlines
else:
- readlines = stream.readlines # type: ignore[assignment] # hint parameter is incorrectly typed as non-optional
+ # hint parameter is incorrectly typed as non-optional
+ readlines = stream.readlines # type: ignore[assignment]
try:
lines = readlines()
@@ -590,7 +591,8 @@ def stripped_lines(
:param ignore_docstrings: if true, any line that is a docstring is removed from the result
:param ignore_imports: if true, any line that is an import is removed from the result
:param ignore_signatures: if true, any line that is part of a function signature is removed from the result
- :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard the line
+ :param line_enabled_callback: If called with "R0801" and a line number, a return value of False will disregard
+ the line
:return: the collection of line/line number/line type tuples
"""
if ignore_imports or ignore_signatures:
diff --git a/pylint/checkers/unicode.py b/pylint/checkers/unicode.py
index 6d7b25395..3e2bccfa5 100644
--- a/pylint/checkers/unicode.py
+++ b/pylint/checkers/unicode.py
@@ -330,7 +330,7 @@ class UnicodeChecker(checkers.BaseRawFileChecker):
"For compatibility use UTF-8 instead of UTF-16/UTF-32. "
"See also https://bugs.python.org/issue1503789 for a history "
"of this issue. And "
- "https://softwareengineering.stackexchange.com/questions/102205/should-utf-16-be-considered-harmful "
+ "https://softwareengineering.stackexchange.com/questions/102205/"
"for some possible problems when using UTF-16 for instance."
),
),
@@ -347,7 +347,8 @@ class UnicodeChecker(checkers.BaseRawFileChecker):
"So can you trust this code? "
"Are you sure it displayed correctly in all editors? "
"If you did not write it or your language is not RTL,"
- " remove the special characters, as they could be used to trick you into executing code, "
+ " remove the special characters, as they could be used to trick you into "
+ "executing code, "
"that does something else than what it looks like.\n"
"More Information:\n"
"https://en.wikipedia.org/wiki/Bidirectional_text\n"
diff --git a/pylint/config/config_file_parser.py b/pylint/config/config_file_parser.py
index b6809d984..019f9b738 100644
--- a/pylint/config/config_file_parser.py
+++ b/pylint/config/config_file_parser.py
@@ -49,8 +49,8 @@ class _ConfigurationFileParser:
# TODO: 3.0: Remove deprecated handling of master, only allow 'pylint.' sections
warnings.warn(
"The use of 'MASTER' or 'master' as configuration section for pylint "
- "has been deprecated, as it's bad practice to not start sections titles with the "
- "tool name. Please use 'pylint.main' instead.",
+ "has been deprecated, as it's bad practice to not start sections titles "
+ "with the tool name. Please use 'pylint.main' instead.",
UserWarning,
)
else:
diff --git a/pylint/extensions/confusing_elif.py b/pylint/extensions/confusing_elif.py
index 174f464ac..d16d6c60a 100644
--- a/pylint/extensions/confusing_elif.py
+++ b/pylint/extensions/confusing_elif.py
@@ -23,7 +23,8 @@ class ConfusingConsecutiveElifChecker(BaseChecker):
name = "confusing_elif"
msgs = {
"R5601": (
- "Consecutive elif with differing indentation level, consider creating a function to separate the inner elif",
+ "Consecutive elif with differing indentation level, consider creating a function to separate the inner"
+ " elif",
"confusing-consecutive-elif",
"Used when an elif statement follows right after an indented block which itself ends with if or elif. "
"It may not be ovious if the elif statement was willingly or mistakenly unindented. "
diff --git a/pylint/extensions/private_import.py b/pylint/extensions/private_import.py
index fb4458e54..01d800c94 100644
--- a/pylint/extensions/private_import.py
+++ b/pylint/extensions/private_import.py
@@ -64,7 +64,8 @@ class PrivateImportChecker(BaseChecker):
names = [n[0] for n in node.names]
- # Check the imported objects first. If they are all valid type annotations, the package can be private
+ # Check the imported objects first. If they are all valid type annotations,
+ # the package can be private
private_names = self._get_type_annotation_names(node, names)
if not private_names:
return
@@ -139,7 +140,8 @@ class PrivateImportChecker(BaseChecker):
for name in node.locals:
# If we find a private type annotation, make sure we do not mask illegal usages
private_name = None
- # All the assignments using this variable that we might have to check for illegal usages later
+ # All the assignments using this variable that we might have to check for
+ # illegal usages later
name_assignments = []
for usage_node in node.locals[name]:
if isinstance(usage_node, nodes.AssignName) and isinstance(
@@ -205,7 +207,8 @@ class PrivateImportChecker(BaseChecker):
node.value, all_used_type_annotations
)
if isinstance(node, nodes.Attribute):
- # An attribute is a type like `pylint.lint.pylinter`. node.expr is the next level up, could be another attribute
+ # An attribute is a type like `pylint.lint.pylinter`. node.expr is the next level
+ # up, could be another attribute
return self._populate_type_annotations_annotation(
node.expr, all_used_type_annotations
)
diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py
index 5b749d5b2..863076f8f 100644
--- a/pylint/lint/pylinter.py
+++ b/pylint/lint/pylinter.py
@@ -227,7 +227,8 @@ MSGS: dict[str, MessageDefinitionTuple] = {
"E0014": (
"Out-of-place setting encountered in top level configuration-section '%s' : '%s'",
"bad-configuration-section",
- "Used when we detect a setting in the top level of a toml configuration that shouldn't be there.",
+ "Used when we detect a setting in the top level of a toml configuration that"
+ " shouldn't be there.",
{"scope": WarningScope.LINE},
),
"E0015": (
@@ -794,7 +795,8 @@ class PyLinter(
:param FileItem file: data about the file
:param nodes.Module module: the ast module to lint
- :param Callable check_astroid_module: callable checking an AST taking the following arguments
+ :param Callable check_astroid_module: callable checking an AST taking the following
+ arguments
- ast: AST of the module
:raises AstroidError: for any failures stemming from astroid
"""
@@ -826,10 +828,12 @@ class PyLinter(
"""Check a file using the passed utility functions (get_ast and
check_astroid_module).
- :param callable get_ast: callable returning AST from defined file taking the following arguments
+ :param callable get_ast: callable returning AST from defined file taking the
+ following arguments
- filepath: path to the file to check
- name: Python module name
- :param callable check_astroid_module: callable checking an AST taking the following arguments
+ :param callable check_astroid_module: callable checking an AST taking the following
+ arguments
- ast: AST of the module
:param FileItem file: data about the file
:raises AstroidError: for any failures stemming from astroid
diff --git a/pylint/reporters/text.py b/pylint/reporters/text.py
index bc11ac4fa..168bb1496 100644
--- a/pylint/reporters/text.py
+++ b/pylint/reporters/text.py
@@ -273,7 +273,8 @@ class ColorizedTextReporter(TextReporter):
) = None,
) -> None:
super().__init__(output)
- # TODO: 3.0: Remove deprecated typing and only accept ColorMappingDict as color_mapping parameter
+ # TODO: 3.0: Remove deprecated typing and only accept ColorMappingDict as
+ # color_mapping parameter
if color_mapping and not isinstance(
list(color_mapping.values())[0], MessageStyle
):