summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-12-21 23:44:51 +0100
committerGitHub <noreply@github.com>2021-12-21 23:44:51 +0100
commitc0fbbb7adbc39cbd67bbd0e0b1ca4e9421c12643 (patch)
tree45cc2ffa41daec92ecd13bbd4edc5c0bd9872bd5
parent29bf25c1e4e93477cc4cf7e1250b007e4a8b07e6 (diff)
downloadpylint-git-c0fbbb7adbc39cbd67bbd0e0b1ca4e9421c12643.tar.gz
Fix typos accross the whole codebase (#5575)
Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
-rw-r--r--pylint/checkers/base.py38
-rw-r--r--pylint/checkers/base_checker.py4
-rw-r--r--pylint/checkers/design_analysis.py5
-rw-r--r--pylint/checkers/exceptions.py42
-rw-r--r--pylint/checkers/format.py4
-rw-r--r--pylint/checkers/refactoring/recommendation_checker.py2
-rw-r--r--pylint/checkers/strings.py11
-rw-r--r--pylint/checkers/typecheck.py13
-rw-r--r--pylint/checkers/utils.py21
-rw-r--r--pylint/checkers/variables.py3
-rw-r--r--pylint/config/configuration_mixin.py2
-rw-r--r--pylint/config/find_default_config_files.py2
-rw-r--r--pylint/config/option_manager_mixin.py10
-rwxr-xr-xpylint/epylint.py4
-rw-r--r--pylint/extensions/_check_docs_utils.py24
-rw-r--r--pylint/extensions/code_style.py2
-rw-r--r--pylint/extensions/comparetozero.py2
-rw-r--r--pylint/extensions/docparams.py7
-rw-r--r--pylint/extensions/emptystring.py2
-rw-r--r--pylint/extensions/redefined_variable_type.py2
-rw-r--r--pylint/extensions/typing.py2
-rw-r--r--pylint/interfaces.py12
-rw-r--r--pylint/lint/parallel.py4
-rw-r--r--pylint/lint/pylinter.py8
-rw-r--r--pylint/lint/run.py6
-rw-r--r--pylint/lint/utils.py4
-rw-r--r--pylint/pyreverse/diadefslib.py2
-rw-r--r--pylint/pyreverse/diagrams.py14
-rw-r--r--pylint/pyreverse/mermaidjs_printer.py2
-rw-r--r--pylint/reporters/multi_reporter.py2
-rw-r--r--pylint/reporters/ureports/base_writer.py4
-rw-r--r--pylint/reporters/ureports/nodes.py2
-rw-r--r--pylint/testutils/configuration_test.py2
-rw-r--r--pylint/testutils/output_line.py4
-rw-r--r--pylint/testutils/primer.py2
-rw-r--r--pylint/testutils/pyreverse.py2
-rw-r--r--pylint/utils/ast_walker.py4
-rw-r--r--pylint/utils/pragma_parser.py2
-rw-r--r--pylint/utils/utils.py8
-rw-r--r--script/fix_documentation.py6
-rw-r--r--tests/checkers/unittest_imports.py5
-rw-r--r--tests/checkers/unittest_spelling.py2
-rw-r--r--tests/checkers/unittest_stdlib.py2
-rw-r--r--tests/checkers/unittest_typecheck.py6
-rw-r--r--tests/config/test_functional_config_loading.py8
-rw-r--r--tests/message/unittest_message.py8
-rw-r--r--tests/primer/test_primer_stdlib.py2
-rw-r--r--tests/pyreverse/test_diadefs.py2
-rw-r--r--tests/test_functional.py4
-rw-r--r--tests/test_regr.py4
-rw-r--r--tests/unittest_reporting.py4
51 files changed, 171 insertions, 168 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py
index 46eb0d17d..652330f11 100644
--- a/pylint/checkers/base.py
+++ b/pylint/checkers/base.py
@@ -298,13 +298,13 @@ def _get_break_loop_node(break_node):
def _loop_exits_early(loop):
"""
- Returns true if a loop may ends up in a break statement.
+ Returns true if a loop may end with a break statement.
Args:
loop (astroid.For, astroid.While): the loop node inspected.
Returns:
- bool: True if the loop may ends up in a break statement, False otherwise.
+ bool: True if the loop may end with a break statement, False otherwise.
"""
loop_nodes = (nodes.For, nodes.While)
definition_nodes = (nodes.FunctionDef, nodes.ClassDef)
@@ -349,7 +349,7 @@ def _get_properties(config):
def _determine_function_name_type(node: nodes.FunctionDef, config=None):
- """Determine the name type whose regex the a function's name should match.
+ """Determine the name type whose regex the function's name should match.
:param node: A function node.
:param config: Configuration from which to pull additional property classes.
@@ -747,7 +747,7 @@ class BasicErrorChecker(_BasicChecker):
@utils.check_messages("nonexistent-operator")
def visit_unaryop(self, node: nodes.UnaryOp) -> None:
- """check use of the non-existent ++ and -- operator operator"""
+ """Check use of the non-existent ++ and -- operators"""
if (
(node.op in "+-")
and isinstance(node.operand, nodes.UnaryOp)
@@ -1244,7 +1244,7 @@ class BasicChecker(_BasicChecker):
@utils.check_messages("unnecessary-lambda")
def visit_lambda(self, node: nodes.Lambda) -> None:
- """check whether or not the lambda is suspicious"""
+ """Check whether the lambda is suspicious"""
# if the body of the lambda is a call expression with the same
# argument list as the lambda itself, then the lambda is
# possibly unnecessary and at least suspicious.
@@ -1357,9 +1357,9 @@ class BasicChecker(_BasicChecker):
@utils.check_messages("unreachable", "lost-exception")
def visit_return(self, node: nodes.Return) -> None:
- """1 - check is the node has a right sibling (if so, that's some
+ """1 - check if the node has a right sibling (if so, that's some
unreachable code)
- 2 - check is the node is inside the finally clause of a try...finally
+ 2 - check if the node is inside the 'finally' clause of a 'try...finally'
block
"""
self._check_unreachable(node)
@@ -1375,9 +1375,9 @@ class BasicChecker(_BasicChecker):
@utils.check_messages("unreachable", "lost-exception")
def visit_break(self, node: nodes.Break) -> None:
- """1 - check is the node has a right sibling (if so, that's some
+ """1 - check if the node has a right sibling (if so, that's some
unreachable code)
- 2 - check is the node is inside the finally clause of a try...finally
+ 2 - check if the node is inside the 'finally' clause of a 'try...finally'
block
"""
# 1 - Is it right sibling ?
@@ -1490,14 +1490,14 @@ class BasicChecker(_BasicChecker):
self.add_message("unreachable", node=unreach_stmt)
def _check_not_in_finally(self, node, node_name, breaker_classes=()):
- """check that a node is not inside a finally clause of a
- try...finally statement.
- If we found before a try...finally block a parent which its type is
- in breaker_classes, we skip the whole check."""
+ """check that a node is not inside a 'finally' clause of a
+ 'try...finally' statement.
+ If we find a parent which type is in breaker_classes before
+ a 'try...finally' block we skip the whole check."""
# if self._tryfinallys is empty, we're not an in try...finally block
if not self._tryfinallys:
return
- # the node could be a grand-grand...-children of the try...finally
+ # the node could be a grand-grand...-child of the 'try...finally'
_parent = node.parent
_node = node
while _parent and not isinstance(_parent, breaker_classes):
@@ -1612,9 +1612,9 @@ class BasicChecker(_BasicChecker):
continue
if not isinstance(target, nodes.AssignName):
continue
+ # Check that the scope is different from a class level, which is usually
+ # a pattern to expose module level attributes as class level ones.
if isinstance(scope, nodes.ClassDef) and target.name in scope_locals:
- # Check that the scope is different than a class level, which is usually
- # a pattern to expose module level attributes as class level ones.
continue
if target.name == lhs_name.name:
self.add_message(
@@ -2218,7 +2218,7 @@ class DocStringChecker(_BasicChecker):
report_missing=True,
confidence=interfaces.HIGH,
):
- """check the node has a non empty docstring"""
+ """Check if the node has a non-empty docstring"""
docstring = node.doc
if docstring is None:
docstring = _infer_dunder_doc_attribute(node)
@@ -2229,7 +2229,7 @@ class DocStringChecker(_BasicChecker):
lines = utils.get_node_last_lineno(node) - node.lineno
if node_type == "module" and not lines:
- # If the module has no body, there's no reason
+ # If the module does not have a body, there's no reason
# to require a docstring.
return
max_lines = self.config.docstring_min_length
@@ -2469,7 +2469,7 @@ class ComparisonChecker(_BasicChecker):
is_const = False
if isinstance(literal, nodes.Const):
if isinstance(literal.value, bool) or literal.value is None:
- # Not interested in this values.
+ # Not interested in these values.
return
is_const = isinstance(literal.value, (bytes, str, int, float))
diff --git a/pylint/checkers/base_checker.py b/pylint/checkers/base_checker.py
index ca1ff39dc..8fe44a2e2 100644
--- a/pylint/checkers/base_checker.py
+++ b/pylint/checkers/base_checker.py
@@ -86,7 +86,7 @@ class BaseChecker(OptionsProviderMixIn):
# Provide anchor to link against
result += get_rst_title(f"{checker_title} Documentation", "^")
result += f"{cleandoc(doc)}\n\n"
- # options might be an empty generator and not be False when casted to boolean
+ # options might be an empty generator and not be False when cast to boolean
options = list(options)
if options:
result += get_rst_title(f"{checker_title} Options", "^")
@@ -186,7 +186,7 @@ class BaseChecker(OptionsProviderMixIn):
raise InvalidMessageError(error_msg)
def open(self):
- """called before visiting project (i.e set of modules)"""
+ """called before visiting project (i.e. set of modules)"""
def close(self):
"""called after visiting project (i.e set of modules)"""
diff --git a/pylint/checkers/design_analysis.py b/pylint/checkers/design_analysis.py
index e6537a417..8a2623486 100644
--- a/pylint/checkers/design_analysis.py
+++ b/pylint/checkers/design_analysis.py
@@ -634,9 +634,8 @@ class MisdesignChecker(BaseChecker):
self._inc_all_stmts(branches)
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
+ """Go through "if" node `node` and count its boolean expressions
+ if the 'if' node test is a BoolOp node
"""
condition = node.test
if not isinstance(condition, astroid.BoolOp):
diff --git a/pylint/checkers/exceptions.py b/pylint/checkers/exceptions.py
index 5af1679f1..b9b6ceb04 100644
--- a/pylint/checkers/exceptions.py
+++ b/pylint/checkers/exceptions.py
@@ -447,7 +447,7 @@ class ExceptionsChecker(checkers.BaseChecker):
bare_raise = False
handler_having_bare_raise = None
- excs_in_bare_handler = []
+ exceptions_in_bare_handler = []
for handler in node.handlers:
if bare_raise:
# check that subsequent handler is not parent of handler which had bare raise.
@@ -457,14 +457,14 @@ class ExceptionsChecker(checkers.BaseChecker):
excs_in_current_handler = gather_exceptions_from_handler(handler)
if not excs_in_current_handler:
break
- if excs_in_bare_handler is None:
+ if exceptions_in_bare_handler is None:
# It can be `None` when the inference failed
break
for exc_in_current_handler in excs_in_current_handler:
inferred_current = utils.safe_infer(exc_in_current_handler)
if any(
utils.is_subclass_of(utils.safe_infer(e), inferred_current)
- for e in excs_in_bare_handler
+ for e in exceptions_in_bare_handler
):
bare_raise = False
break
@@ -475,7 +475,7 @@ class ExceptionsChecker(checkers.BaseChecker):
if handler.body[0].exc is None:
bare_raise = True
handler_having_bare_raise = handler
- excs_in_bare_handler = gather_exceptions_from_handler(handler)
+ exceptions_in_bare_handler = gather_exceptions_from_handler(handler)
else:
if bare_raise:
self.add_message("try-except-raise", node=handler_having_bare_raise)
@@ -525,50 +525,50 @@ class ExceptionsChecker(checkers.BaseChecker):
)
else:
try:
- excs = list(_annotated_unpack_infer(handler.type))
+ exceptions = list(_annotated_unpack_infer(handler.type))
except astroid.InferenceError:
continue
- for part, exc in excs:
- if exc is astroid.Uninferable:
+ for part, exception in exceptions:
+ if exception is astroid.Uninferable:
continue
- if isinstance(exc, astroid.Instance) and utils.inherit_from_std_ex(
- exc
- ):
- exc = exc._proxied
+ if isinstance(
+ exception, astroid.Instance
+ ) and utils.inherit_from_std_ex(exception):
+ exception = exception._proxied
- self._check_catching_non_exception(handler, exc, part)
+ self._check_catching_non_exception(handler, exception, part)
- if not isinstance(exc, nodes.ClassDef):
+ if not isinstance(exception, nodes.ClassDef):
continue
exc_ancestors = [
anc
- for anc in exc.ancestors()
+ for anc in exception.ancestors()
if isinstance(anc, nodes.ClassDef)
]
for previous_exc in exceptions_classes:
if previous_exc in exc_ancestors:
- msg = f"{previous_exc.name} is an ancestor class of {exc.name}"
+ msg = f"{previous_exc.name} is an ancestor class of {exception.name}"
self.add_message(
"bad-except-order", node=handler.type, args=msg
)
if (
- exc.name in self.config.overgeneral_exceptions
- and exc.root().name == utils.EXCEPTIONS_MODULE
+ exception.name in self.config.overgeneral_exceptions
+ and exception.root().name == utils.EXCEPTIONS_MODULE
and not _is_raising(handler.body)
):
self.add_message(
- "broad-except", args=exc.name, node=handler.type
+ "broad-except", args=exception.name, node=handler.type
)
- if exc in exceptions_classes:
+ if exception in exceptions_classes:
self.add_message(
- "duplicate-except", args=exc.name, node=handler.type
+ "duplicate-except", args=exception.name, node=handler.type
)
- exceptions_classes += [exc for _, exc in excs]
+ exceptions_classes += [exc for _, exc in exceptions]
def register(linter):
diff --git a/pylint/checkers/format.py b/pylint/checkers/format.py
index 54e571296..0cee7b90b 100644
--- a/pylint/checkers/format.py
+++ b/pylint/checkers/format.py
@@ -47,7 +47,7 @@
"""Python code format's checker.
-By default try to follow Guido's style guide :
+By default, try to follow Guido's style guide :
https://www.python.org/doc/essays/styleguide/
@@ -594,7 +594,7 @@ class FormatChecker(BaseTokenChecker):
prev_sibl = node.previous_sibling()
if prev_sibl is not None:
prev_line = prev_sibl.fromlineno
- # The line on which a finally: occurs in a try/finally
+ # The line on which a 'finally': occurs in a 'try/finally'
# is not directly represented in the AST. We infer it
# by taking the last line of the body and adding 1, which
# should be the line of finally:
diff --git a/pylint/checkers/refactoring/recommendation_checker.py b/pylint/checkers/refactoring/recommendation_checker.py
index 5424a765c..3094ffd07 100644
--- a/pylint/checkers/refactoring/recommendation_checker.py
+++ b/pylint/checkers/refactoring/recommendation_checker.py
@@ -337,7 +337,7 @@ class RecommendationChecker(checkers.BaseChecker):
def _detect_replacable_format_call(self, node: nodes.Const) -> None:
"""Check whether a string is used in a call to format() or '%' and whether it
- can be replaced by a f-string"""
+ can be replaced by an f-string"""
if (
isinstance(node.parent, nodes.Attribute)
and node.parent.attrname == "format"
diff --git a/pylint/checkers/strings.py b/pylint/checkers/strings.py
index bc573979f..064902b5d 100644
--- a/pylint/checkers/strings.py
+++ b/pylint/checkers/strings.py
@@ -518,7 +518,7 @@ class StringFormatChecker(BaseChecker):
# only if the .format got at least one keyword argument.
# This means that the format strings accepts both
# positional and named fields and we should warn
- # when one of the them is missing or is extra.
+ # when one of them is missing or is extra.
check_args = True
else:
check_args = True
@@ -961,7 +961,7 @@ def _is_long_string(string_token: str) -> bool:
string_token: The string token to be parsed.
Returns:
- A boolean representing whether or not this token matches a longstring
+ A boolean representing whether this token matches a longstring
regex.
"""
return bool(
@@ -973,15 +973,14 @@ def _is_long_string(string_token: str) -> bool:
def _get_quote_delimiter(string_token: str) -> str:
"""Returns the quote character used to delimit this token string.
- This function does little checking for whether the token is a well-formed
- string.
+ This function checks whether the token is a well-formed string.
Args:
string_token: The token to be parsed.
Returns:
- A string containing solely the first quote delimiter character in the passed
- string.
+ A string containing solely the first quote delimiter character in the
+ given string.
Raises:
ValueError: No quote delimiter characters are present.
diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py
index 6885e8cbf..b4f224c06 100644
--- a/pylint/checkers/typecheck.py
+++ b/pylint/checkers/typecheck.py
@@ -161,7 +161,7 @@ def _is_owner_ignored(owner, attrname, ignored_classes, ignored_modules):
if fnmatch.fnmatch(module_qname, ignore):
return True
- # Otherwise we might have a root module name being ignored,
+ # Otherwise, we might have a root module name being ignored,
# and the qualified owner has more levels of depth.
parts = deque(module_name.split("."))
current_module = ""
@@ -1184,14 +1184,14 @@ accessed. Python regular expressions are accepted.",
Check a string is assigned to self.__name__
"""
- # Check the left hand side of the assignment is <something>.__name__
+ # Check the left-hand side of the assignment is <something>.__name__
lhs = node.targets[0]
if not isinstance(lhs, nodes.AssignAttr):
return
if not lhs.attrname == "__name__":
return
- # If the right hand side is not a string
+ # If the right-hand side is not a string
rhs = node.value
if isinstance(rhs, nodes.Const) and isinstance(rhs.value, str):
return
@@ -1271,7 +1271,7 @@ accessed. Python regular expressions are accepted.",
# extract argument names, if they have names
calling_parg_names = [p.name for p in call_site.positional_arguments]
- # Additionally get names of keyword arguments to use in a full match
+ # Additionally, get names of keyword arguments to use in a full match
# against parameters
calling_kwarg_names = [
arg.name for arg in call_site.keyword_arguments.values()
@@ -1664,7 +1664,7 @@ accessed. Python regular expressions are accepted.",
if index_type is None or index_type is astroid.Uninferable:
continue
- # Constants must of type int or None
+ # Constants must be of type int or None
if isinstance(index_type, nodes.Const):
if isinstance(index_type.value, (int, type(None))):
continue
@@ -1733,7 +1733,8 @@ accessed. Python regular expressions are accepted.",
# See the test file for not_context_manager for a couple
# of self explaining tests.
- # Retrieve node from all previusly visited nodes in the the inference history
+ # Retrieve node from all previously visited nodes in the
+ # inference history
context_path_names: Iterator[Any] = filter(
None, _unflatten(context.path)
)
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py
index cb04c2119..d89b39d9f 100644
--- a/pylint/checkers/utils.py
+++ b/pylint/checkers/utils.py
@@ -119,7 +119,7 @@ KEYS_METHOD = "keys"
#
# * None: variable number of parameters
# * number: exactly that number of parameters
-# * tuple: this are the odd ones. Basically it means that the function
+# * tuple: these are the odd ones. Basically it means that the function
# can work with any number of arguments from that tuple,
# although it's best to implement it in order to accept
# all of them.
@@ -400,7 +400,7 @@ def is_defined_before(var_node: nodes.Name) -> bool:
for parent in var_node.node_ancestors():
if is_defined_in_scope(var_node, varname, parent):
return True
- # possibly multiple statements on the same line using semi colon separator
+ # possibly multiple statements on the same line using semicolon separator
stmt = var_node.statement(future=True)
_node = stmt.previous_sibling()
lineno = stmt.fromlineno
@@ -511,11 +511,11 @@ class UnsupportedFormatCharacter(Exception):
def parse_format_string(
format_string: str,
) -> Tuple[Set[str], int, Dict[str, str], List[str]]:
- """Parses a format string, returning a tuple of (keys, num_args), where keys
- is the set of mapping keys in the format string, and num_args is the number
- of arguments required by the format string. Raises
- IncompleteFormatString or UnsupportedFormatCharacter if a
- parse error occurs."""
+ """Parses a format string, returning a tuple of (keys, num_args), where 'keys'
+ is the set of mapping keys in the format string, and 'num_args' is the number
+ of arguments required by the format string. Raises IncompleteFormatString or
+ UnsupportedFormatCharacter if a parse error occurs.
+ """
keys = set()
key_types = {}
pos_types = []
@@ -928,8 +928,7 @@ def unimplemented_abstract_methods(
# Old style class, it will not have a mro.
return {}
except astroid.ResolveError:
- # Probably inconsistent hierarchy, don'try
- # to figure this out here.
+ # Probably inconsistent hierarchy, don't try to figure this out here.
return {}
for ancestor in mro:
for obj in ancestor.values():
@@ -1461,7 +1460,7 @@ def is_subclass_of(child: nodes.ClassDef, parent: nodes.ClassDef) -> bool:
@lru_cache(maxsize=1024)
def is_overload_stub(node: nodes.NodeNG) -> bool:
- """Check if a node if is a function stub decorated with typing.overload.
+ """Check if a node is a function stub decorated with typing.overload.
:param node: Node to check.
:returns: True if node is an overload function stub. False otherwise.
@@ -1680,7 +1679,7 @@ def is_reassigned_after_current(node: nodes.NodeNG, varname: str) -> bool:
def is_function_body_ellipsis(node: nodes.FunctionDef) -> bool:
- """Checks whether a function body only consisst of a single Ellipsis"""
+ """Checks whether a function body only consists of a single Ellipsis"""
return (
len(node.body) == 1
and isinstance(node.body[0], nodes.Expr)
diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
index 8e2f86839..a32099dfd 100644
--- a/pylint/checkers/variables.py
+++ b/pylint/checkers/variables.py
@@ -54,8 +54,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""variables checkers for Python code
-"""
+"""Variables checkers for Python code"""
import collections
import copy
import itertools
diff --git a/pylint/config/configuration_mixin.py b/pylint/config/configuration_mixin.py
index deca7f4bc..2d34933f0 100644
--- a/pylint/config/configuration_mixin.py
+++ b/pylint/config/configuration_mixin.py
@@ -6,7 +6,7 @@ from pylint.config.options_provider_mixin import OptionsProviderMixIn
class ConfigurationMixIn(OptionsManagerMixIn, OptionsProviderMixIn):
- """basic mixin for simple configurations which don't need the
+ """Basic mixin for simple configurations which don't need the
manager / providers model"""
def __init__(self, *args, **kwargs):
diff --git a/pylint/config/find_default_config_files.py b/pylint/config/find_default_config_files.py
index dd051f9c6..36fd351f0 100644
--- a/pylint/config/find_default_config_files.py
+++ b/pylint/config/find_default_config_files.py
@@ -71,7 +71,7 @@ def find_default_config_files() -> Iterator[str]:
def find_pylintrc() -> Optional[str]:
- """search the pylint rc file and return its path if it find it, else None"""
+ """Search the pylint rc file and return its path if it finds it, else return None"""
for config_file in find_default_config_files():
if config_file.endswith("pylintrc"):
return config_file
diff --git a/pylint/config/option_manager_mixin.py b/pylint/config/option_manager_mixin.py
index 13938feae..e6e031e7d 100644
--- a/pylint/config/option_manager_mixin.py
+++ b/pylint/config/option_manager_mixin.py
@@ -212,8 +212,8 @@ class OptionsManagerMixIn:
continue
if section not in sections:
sections.append(section)
- alloptions = options_by_section.setdefault(section, [])
- alloptions += options
+ all_options = options_by_section.setdefault(section, [])
+ all_options += options
stream = stream or sys.stdout
printed = False
for section in sections:
@@ -245,7 +245,7 @@ class OptionsManagerMixIn:
def read_config_file(self, config_file=None, verbose=None):
"""Read the configuration file but do not load it (i.e. dispatching
- values to each options provider)
+ values to each option's provider)
"""
for help_level in range(1, self._maxlevel + 1):
opt = "-".join(["long"] * help_level) + "-help"
@@ -282,7 +282,7 @@ class OptionsManagerMixIn:
# Use this encoding in order to strip the BOM marker, if any.
with open(config_file, encoding="utf_8_sig") as fp:
parser.read_file(fp)
- # normalize sections'title
+ # normalize each section's title
for sect, values in list(parser._sections.items()):
if sect.startswith("pylint."):
sect = sect[len("pylint.") :]
@@ -332,7 +332,7 @@ class OptionsManagerMixIn:
def load_config_file(self):
"""Dispatch values previously read from a configuration file to each
- options provider)"""
+ option's provider"""
parser = self.cfgfile_parser
for section in parser.sections():
for option, value in parser.items(section):
diff --git a/pylint/epylint.py b/pylint/epylint.py
index 09795d639..98b11afd5 100755
--- a/pylint/epylint.py
+++ b/pylint/epylint.py
@@ -67,8 +67,8 @@ from subprocess import PIPE, Popen
def _get_env():
- """Extracts the environment PYTHONPATH and appends the current sys.path to
- those."""
+ """Extracts the environment PYTHONPATH and appends the current 'sys.path'
+ to it."""
env = dict(os.environ)
env["PYTHONPATH"] = os.pathsep.join(sys.path)
return env
diff --git a/pylint/extensions/_check_docs_utils.py b/pylint/extensions/_check_docs_utils.py
index ad4a5bb32..611a04aa2 100644
--- a/pylint/extensions/_check_docs_utils.py
+++ b/pylint/extensions/_check_docs_utils.py
@@ -122,7 +122,7 @@ def _split_multiple_exc_types(target: str) -> List[str]:
def possible_exc_types(node: nodes.NodeNG) -> Set[nodes.ClassDef]:
"""
- Gets all of the possible raised exception types for the given raise node.
+ Gets all the possible raised exception types for the given raise node.
.. note::
@@ -133,11 +133,11 @@ def possible_exc_types(node: nodes.NodeNG) -> Set[nodes.ClassDef]:
:returns: A list of exception types possibly raised by :param:`node`.
"""
- excs = []
+ exceptions = []
if isinstance(node.exc, nodes.Name):
inferred = utils.safe_infer(node.exc)
if inferred:
- excs = [inferred]
+ exceptions = [inferred]
elif node.exc is None:
handler = node.parent
while handler and not isinstance(handler, nodes.ExceptHandler):
@@ -145,15 +145,15 @@ def possible_exc_types(node: nodes.NodeNG) -> Set[nodes.ClassDef]:
if handler and handler.type:
try:
- for exc in astroid.unpack_infer(handler.type):
- if exc is not astroid.Uninferable:
- excs.append(exc)
+ for exception in astroid.unpack_infer(handler.type):
+ if exception is not astroid.Uninferable:
+ exceptions.append(exception)
except astroid.InferenceError:
pass
else:
target = _get_raise_target(node)
if isinstance(target, nodes.ClassDef):
- excs = [target]
+ exceptions = [target]
elif isinstance(target, nodes.FunctionDef):
for ret in target.nodes_of_class(nodes.Return):
if ret.frame() != target:
@@ -163,12 +163,16 @@ def possible_exc_types(node: nodes.NodeNG) -> Set[nodes.ClassDef]:
val = utils.safe_infer(ret.value)
if val and utils.inherit_from_std_ex(val):
if isinstance(val, nodes.ClassDef):
- excs.append(val)
+ exceptions.append(val)
elif isinstance(val, astroid.Instance):
- excs.append(val.getattr("__class__")[0])
+ exceptions.append(val.getattr("__class__")[0])
try:
- return {exc for exc in excs if not utils.node_ignores_exception(node, exc.name)}
+ return {
+ exc
+ for exc in exceptions
+ if not utils.node_ignores_exception(node, exc.name)
+ }
except astroid.InferenceError:
return set()
diff --git a/pylint/extensions/code_style.py b/pylint/extensions/code_style.py
index 8d789720a..332ffaa92 100644
--- a/pylint/extensions/code_style.py
+++ b/pylint/extensions/code_style.py
@@ -274,7 +274,7 @@ class CodeStyleChecker(BaseChecker):
def _check_ignore_assignment_expr_suggestion(
node: nodes.If, name: Optional[str]
) -> bool:
- """Return True if suggestion for assignment expr should be ignore.
+ """Return True if suggestion for assignment expr should be ignored.
E.g., in cases where a match statement would be a better fit
(multiple conditions).
diff --git a/pylint/extensions/comparetozero.py b/pylint/extensions/comparetozero.py
index ced62f0a6..e543f1ccf 100644
--- a/pylint/extensions/comparetozero.py
+++ b/pylint/extensions/comparetozero.py
@@ -28,7 +28,7 @@ def _is_constant_zero(node):
class CompareToZeroChecker(checkers.BaseChecker):
"""Checks for comparisons to zero.
- Most of the times you should use the fact that integers with a value of 0 are false.
+ Most of the time you should use the fact that integers with a value of 0 are false.
An exception to this rule is when 0 is allowed in the program and has a
different meaning than None!
"""
diff --git a/pylint/extensions/docparams.py b/pylint/extensions/docparams.py
index 05c262012..4fadf9458 100644
--- a/pylint/extensions/docparams.py
+++ b/pylint/extensions/docparams.py
@@ -521,9 +521,8 @@ class DocstringParameterChecker(BaseChecker):
:param warning_node: The node to assign the warnings to
:type warning_node: :class:`astroid.scoped_nodes.Node`
- :param accept_no_param_doc: Whether or not to allow no parameters
- to be documented.
- If None then this value is read from the configuration.
+ :param accept_no_param_doc: Whether to allow no parameters to be
+ documented. If None then this value is read from the configuration.
:type accept_no_param_doc: bool or None
"""
# Tolerate missing param or type declarations if there is a link to
@@ -589,7 +588,7 @@ class DocstringParameterChecker(BaseChecker):
):
self.add_message(
"missing-any-param-doc",
- args=warning_node.name,
+ args=(warning_node.name,),
node=warning_node,
)
else:
diff --git a/pylint/extensions/emptystring.py b/pylint/extensions/emptystring.py
index 3e62937db..4e466aca4 100644
--- a/pylint/extensions/emptystring.py
+++ b/pylint/extensions/emptystring.py
@@ -23,7 +23,7 @@ from pylint.checkers import utils
class CompareToEmptyStringChecker(checkers.BaseChecker):
"""Checks for comparisons to empty string.
- Most of the times you should use the fact that empty strings are false.
+ Most of the time you should use the fact that empty strings are false.
An exception to this rule is when an empty string value is allowed in the program
and has a different meaning than None!
"""
diff --git a/pylint/extensions/redefined_variable_type.py b/pylint/extensions/redefined_variable_type.py
index 864c50ddf..a2b5f2a20 100644
--- a/pylint/extensions/redefined_variable_type.py
+++ b/pylint/extensions/redefined_variable_type.py
@@ -30,7 +30,7 @@ class MultipleTypesChecker(BaseChecker):
- Currently, if an attribute is set to different types in 2 methods of a
same class, it won't be detected (see functional test)
- One could improve the support for inference on assignment with tuples,
- ifexpr, etc. Also it would be great to have support for inference on
+ ifexpr, etc. Also, it would be great to have support for inference on
str.split()
"""
diff --git a/pylint/extensions/typing.py b/pylint/extensions/typing.py
index 01bfe1b28..79cb18ed3 100644
--- a/pylint/extensions/typing.py
+++ b/pylint/extensions/typing.py
@@ -218,7 +218,7 @@ class TypingChecker(BaseChecker):
- OR: Python 3.7+ with postponed evaluation in
a type annotation context
- For Python 3.7+: Only emitt message if change doesn't create
+ For Python 3.7+: Only emit message if change doesn't create
any name collisions, only ever used in a type annotation
context, and can safely be replaced.
"""
diff --git a/pylint/interfaces.py b/pylint/interfaces.py
index 8fd61589f..7670ad19a 100644
--- a/pylint/interfaces.py
+++ b/pylint/interfaces.py
@@ -64,15 +64,15 @@ def implements(
obj: "BaseChecker",
interface: Union[Type["Interface"], Tuple[Type["Interface"], ...]],
) -> bool:
- """Does the given object (maybe an instance or class) implements the interface."""
- kimplements = getattr(obj, "__implements__", ())
- if not isinstance(kimplements, (list, tuple)):
- kimplements = (kimplements,)
- return any(issubclass(i, interface) for i in kimplements)
+ """Does the given object (maybe an instance or class) implement the interface."""
+ implements_ = getattr(obj, "__implements__", ())
+ if not isinstance(implements_, (list, tuple)):
+ implements_ = (implements_,)
+ return any(issubclass(i, interface) for i in implements_)
class IChecker(Interface):
- """Base interface, not to be used elsewhere than for sub interfaces definition."""
+ """Base interface, to be used only for sub interfaces definition."""
def open(self):
"""called before visiting project (i.e. set of modules)"""
diff --git a/pylint/lint/parallel.py b/pylint/lint/parallel.py
index 56cee9aa7..eaacb710d 100644
--- a/pylint/lint/parallel.py
+++ b/pylint/lint/parallel.py
@@ -78,7 +78,7 @@ def _worker_check_single_file(
def _merge_mapreduce_data(linter, all_mapreduce_data):
"""Merges map/reduce data across workers, invoking relevant APIs on checkers"""
- # First collate the data, preparing it so we can send it to the checkers for
+ # First collate the data and prepare it, so we can send it to the checkers for
# validation. The intent here is to collect all the mapreduce data for all checker-
# runs across processes - that will then be passed to a static method on the
# checkers to be reduced and further processed.
@@ -113,7 +113,7 @@ def check_parallel(linter, jobs, files: Iterable[FileItem], arguments=None):
pool = multiprocessing.Pool( # pylint: disable=consider-using-with
jobs, initializer=initializer, initargs=[linter]
)
- # ..and now when the workers have inherited the linter, the actual reporter
+ # ...and now when the workers have inherited the linter, the actual reporter
# can be set back here on the parent process so that results get stored into
# correct reporter
linter.set_reporter(original_reporter)
diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py
index 1619159c6..023455f68 100644
--- a/pylint/lint/pylinter.py
+++ b/pylint/lint/pylinter.py
@@ -974,7 +974,7 @@ class PyLinter(
# pylint: disable=unused-argument
@staticmethod
def should_analyze_file(modname, path, is_argument=False):
- """Returns whether or not a module should be checked.
+ """Returns whether a module should be checked.
This implementation returns True for all python source file, indicating
that all files should be linted.
@@ -1059,7 +1059,7 @@ class PyLinter(
The arguments are the same that are documented in _check_files
- The initialize() method should be called before calling this method
+ initialize() should be called before calling this method
"""
with self._astroid_module_checker() as check_astroid_module:
self._check_file(self.get_ast, check_astroid_module, file)
@@ -1408,8 +1408,8 @@ class PyLinter(
fallback = True
lines = self.file_state._raw_module_msgs_state.get(msgid, {})
- # Doesn't consider scopes, as a disable can be in a different scope
- # than that of the current line.
+ # Doesn't consider scopes, as a 'disable' can be in a
+ # different scope than that of the current line.
closest_lines = reversed(
[
(message_line, enable)
diff --git a/pylint/lint/run.py b/pylint/lint/run.py
index d607cfd80..a349298c1 100644
--- a/pylint/lint/run.py
+++ b/pylint/lint/run.py
@@ -46,7 +46,7 @@ def cb_list_confidence_levels(option, optname, value, parser):
def cb_init_hook(optname, value):
- """exec arbitrary code to set sys.path for instance"""
+ """Execute arbitrary code to set 'sys.path' for instance"""
exec(value) # pylint: disable=exec-used
@@ -348,9 +348,9 @@ to search for configuration file.
linter.load_config_file()
if reporter:
- # if a custom reporter is provided as argument, it may be overridden
+ # If a custom reporter is provided as argument, it may be overridden
# by file parameters, so re-set it here, but before command line
- # parsing so it's still overridable by command line option
+ # parsing, so it's still overridable by command line option
linter.set_reporter(reporter)
try:
args = linter.load_command_line_configuration(args)
diff --git a/pylint/lint/utils.py b/pylint/lint/utils.py
index ed0cefb77..fb1093d80 100644
--- a/pylint/lint/utils.py
+++ b/pylint/lint/utils.py
@@ -119,10 +119,10 @@ def _patch_sys_path(args):
@contextlib.contextmanager
def fix_import_path(args):
- """Prepare sys.path for running the linter checks.
+ """Prepare 'sys.path' for running the linter checks.
Within this context, each of the given arguments is importable.
- Paths are added to sys.path in corresponding order to the arguments.
+ Paths are added to 'sys.path' in corresponding order to the arguments.
We avoid adding duplicate directories to sys.path.
`sys.path` is reset to its original value upon exiting this context.
"""
diff --git a/pylint/pyreverse/diadefslib.py b/pylint/pyreverse/diadefslib.py
index d8192946a..aee686da5 100644
--- a/pylint/pyreverse/diadefslib.py
+++ b/pylint/pyreverse/diadefslib.py
@@ -220,7 +220,7 @@ class DiadefsHandler:
self.config = config
def get_diadefs(self, project, linker):
- """Get the diagrams configuration data
+ """Get the diagram's configuration data
:param project:The pyreverse project
:type project: pyreverse.utils.Project
diff --git a/pylint/pyreverse/diagrams.py b/pylint/pyreverse/diagrams.py
index 93ccf8ae8..5fb7cb9dd 100644
--- a/pylint/pyreverse/diagrams.py
+++ b/pylint/pyreverse/diagrams.py
@@ -16,9 +16,7 @@
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-"""diagram objects
-"""
-
+"""diagram objects"""
import astroid
from astroid import nodes
@@ -31,7 +29,7 @@ class Figure:
class Relationship(Figure):
- """a relation ship from an object in the diagram to another"""
+ """A relationship from an object in the diagram to another"""
def __init__(self, from_object, to_object, relation_type, name=None):
super().__init__()
@@ -85,12 +83,12 @@ class ClassDiagram(Figure, FilterMixIn):
)
def add_relationship(self, from_object, to_object, relation_type, name=None):
- """create a relation ship"""
+ """create a relationship"""
rel = Relationship(from_object, to_object, relation_type, name)
self.relationships.setdefault(relation_type, []).append(rel)
def get_relationship(self, from_object, relation_type):
- """return a relation ship or None"""
+ """return a relationship or None"""
for rel in self.relationships.get(relation_type, ()):
if rel.from_object is from_object:
return rel
@@ -176,7 +174,7 @@ class ClassDiagram(Figure, FilterMixIn):
raise KeyError(name)
def extract_relationships(self):
- """extract relation ships between nodes in the diagram"""
+ """Extract relationships between nodes in the diagram"""
for obj in self.classes():
node = obj.node
obj.attrs = self.get_attrs(node)
@@ -256,7 +254,7 @@ class PackageDiagram(ClassDiagram):
obj.node.depends.append(from_module)
def extract_relationships(self):
- """extract relation ships between nodes in the diagram"""
+ """Extract relationships between nodes in the diagram"""
super().extract_relationships()
for obj in self.classes():
# ownership
diff --git a/pylint/pyreverse/mermaidjs_printer.py b/pylint/pyreverse/mermaidjs_printer.py
index c8214ab8e..d215b559d 100644
--- a/pylint/pyreverse/mermaidjs_printer.py
+++ b/pylint/pyreverse/mermaidjs_printer.py
@@ -84,7 +84,7 @@ class MermaidJSPrinter(Printer):
class HTMLMermaidJSPrinter(MermaidJSPrinter):
- """Printer for MermaidJS diagrams wrapped in an html boilerplate"""
+ """Printer for MermaidJS diagrams wrapped in a html boilerplate"""
HTML_OPEN_BOILERPLATE = """<html>
<body>
diff --git a/pylint/reporters/multi_reporter.py b/pylint/reporters/multi_reporter.py
index cbdc36962..3eb75181e 100644
--- a/pylint/reporters/multi_reporter.py
+++ b/pylint/reporters/multi_reporter.py
@@ -50,7 +50,7 @@ class MultiReporter:
@out.setter
def out(self, output: Optional[AnyFile] = None):
"""
- MultiReporter doesn't have it's own output. This method is only
+ MultiReporter doesn't have its own output. This method is only
provided for API parity with BaseReporter and should not be called
with non-None values for 'output'.
"""
diff --git a/pylint/reporters/ureports/base_writer.py b/pylint/reporters/ureports/base_writer.py
index edf588527..e87acd7ea 100644
--- a/pylint/reporters/ureports/base_writer.py
+++ b/pylint/reporters/ureports/base_writer.py
@@ -36,7 +36,7 @@ class BaseWriter:
"""format and write the given layout into the stream object
unicode policy: unicode strings may be found in the layout;
- try to call stream.write with it, but give it back encoded using
+ try to call 'stream.write' with it, but give it back encoded using
the given encoding if it fails
"""
if not encoding:
@@ -69,7 +69,7 @@ class BaseWriter:
self.section = 0
def end_format(self) -> None:
- """finished to format a layout"""
+ """Finished formatting a layout"""
def get_table_content(self, table: "Table") -> List[List[str]]:
"""trick to get table content without actually writing it
diff --git a/pylint/reporters/ureports/nodes.py b/pylint/reporters/ureports/nodes.py
index 4f7cde24d..280f97528 100644
--- a/pylint/reporters/ureports/nodes.py
+++ b/pylint/reporters/ureports/nodes.py
@@ -148,7 +148,7 @@ class Title(BaseLayout):
attributes :
* BaseLayout attributes
- A title must not contains a section nor a paragraph!
+ A title must not contain a section nor a paragraph!
"""
diff --git a/pylint/testutils/configuration_test.py b/pylint/testutils/configuration_test.py
index b0fd0b140..4e6f265bb 100644
--- a/pylint/testutils/configuration_test.py
+++ b/pylint/testutils/configuration_test.py
@@ -22,7 +22,7 @@ PylintConfiguration = Dict[str, ConfigurationValue]
if not PY38_PLUS:
# We need to deepcopy a compiled regex pattern
- # In python 3.6 and 3.7 this require a hack
+ # In python 3.6 and 3.7 this requires a hack
# See https://stackoverflow.com/a/56935186
copy._deepcopy_dispatch[type(re.compile(""))] = lambda r, _: r # type: ignore[attr-defined]
diff --git a/pylint/testutils/output_line.py b/pylint/testutils/output_line.py
index c3836a763..9c0c76239 100644
--- a/pylint/testutils/output_line.py
+++ b/pylint/testutils/output_line.py
@@ -93,8 +93,8 @@ class OutputLine(NamedTuple):
@staticmethod
def _get_column(column: str) -> int:
- """Handle column numbers with the exception of pylint < 3.8 not having them
- in the ast parser.
+ """Handle column numbers except for python < 3.8. The ast parser in those versions doesn't
+ return them.
"""
if not PY38_PLUS:
# We check the column only for the new better ast parser introduced in python 3.8
diff --git a/pylint/testutils/primer.py b/pylint/testutils/primer.py
index 30fa841ad..b8b33ae3e 100644
--- a/pylint/testutils/primer.py
+++ b/pylint/testutils/primer.py
@@ -65,7 +65,7 @@ class PackageToLint:
def pylint_args(self) -> List[str]:
options: List[str] = []
if self.pylintrc is not None:
- # There is an error if rcfile is given but does not exists
+ # There is an error if rcfile is given but does not exist
options += [f"--rcfile={self.pylintrc}"]
return self.paths_to_lint + options + self.pylint_additional_args
diff --git a/pylint/testutils/pyreverse.py b/pylint/testutils/pyreverse.py
index 15c5de4cb..f70fe540f 100644
--- a/pylint/testutils/pyreverse.py
+++ b/pylint/testutils/pyreverse.py
@@ -8,7 +8,7 @@ from typing import List, Optional, Tuple
# A NamedTuple is not possible as some tests need to modify attributes during the test.
class PyreverseConfig: # pylint: disable=too-many-instance-attributes, too-many-arguments
"""Holds the configuration options for Pyreverse.
- The default values correspond to the defaults of the options parser."""
+ The default values correspond to the defaults of the options' parser."""
def __init__(
self,
diff --git a/pylint/utils/ast_walker.py b/pylint/utils/ast_walker.py
index 4f76a9805..f846c9c21 100644
--- a/pylint/utils/ast_walker.py
+++ b/pylint/utils/ast_walker.py
@@ -49,10 +49,10 @@ class ASTWalker:
cid = cls.__name__.lower()
if cid not in vcids:
visits[cid].append(visit_default)
- # for now we have no "leave_default" method in Pylint
+ # For now, we have no "leave_default" method in Pylint
def walk(self, astroid):
- """call visit events of astroid checkers for the given node, recurse on
+ """Call visit events of astroid checkers for the given node, recurse on
its children, then leave events.
"""
cid = astroid.__class__.__name__.lower()
diff --git a/pylint/utils/pragma_parser.py b/pylint/utils/pragma_parser.py
index 02ad25493..1cd1213a7 100644
--- a/pylint/utils/pragma_parser.py
+++ b/pylint/utils/pragma_parser.py
@@ -9,7 +9,7 @@ from typing import Generator, List, Optional
# so that an option can be continued with the reasons
# why it is active or disabled.
OPTION_RGX = r"""
- \s* # Any number of whithespace
+ \s* # Any number of whitespace
\#? # One or zero hash
.* # Anything (as much as possible)
(\s* # Beginning of first matched group and any number of whitespaces
diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py
index bf37734fd..e84ffa472 100644
--- a/pylint/utils/utils.py
+++ b/pylint/utils/utils.py
@@ -129,7 +129,7 @@ def get_rst_title(title, character):
def get_rst_section(section, options, doc=None):
- """format an options section using as a ReStructuredText formatted output"""
+ """format an option's section using as a ReStructuredText formatted output"""
result = ""
if section:
result += get_rst_title(section, "'")
@@ -350,7 +350,7 @@ def _format_option_value(optdict, value):
def format_section(
stream: TextIO, section: str, options: List[Tuple], doc: Optional[str] = None
) -> None:
- """format an options section using the INI format"""
+ """Format an option's section using the INI format"""
if doc:
print(_comment(doc), file=stream)
print(f"[{section}]", file=stream)
@@ -386,9 +386,9 @@ class IsortDriver:
def __init__(self, config):
if HAS_ISORT_5:
self.isort5_config = isort.api.Config(
- # There is not typo here. EXTRA_standard_library is
+ # There is no typo here. EXTRA_standard_library is
# what most users want. The option has been named
- # KNOWN_standard_library for ages in pylint and we
+ # KNOWN_standard_library for ages in pylint, and we
# don't want to break compatibility.
extra_standard_library=config.known_standard_library,
known_third_party=config.known_third_party,
diff --git a/script/fix_documentation.py b/script/fix_documentation.py
index b03f70ead..36fd931f0 100644
--- a/script/fix_documentation.py
+++ b/script/fix_documentation.py
@@ -83,14 +83,14 @@ def main(argv: Union[List[str], None] = None) -> int:
return_value: int = 0
for file_name in args.filenames:
with open(file_name, encoding="utf-8") as fp:
- orignal_content = fp.read()
- content = orignal_content
+ original_content = fp.read()
+ content = original_content
# Modify files
content = fix_inline_code_blocks(content)
if file_name == args.changelog:
content = changelog_insert_empty_lines(content, args.subtitle_prefix)
# If modified, write changes and eventually return 1
- if orignal_content != content:
+ if original_content != content:
with open(file_name, "w", encoding="utf-8") as fp:
fp.write(content)
return_value |= 1
diff --git a/tests/checkers/unittest_imports.py b/tests/checkers/unittest_imports.py
index 507b0d055..c5285d259 100644
--- a/tests/checkers/unittest_imports.py
+++ b/tests/checkers/unittest_imports.py
@@ -60,8 +60,11 @@ class TestImportsChecker(CheckerTestCase):
f"{os.path.join(REGR_DATA, 'beyond_top_two')} -d all -e relative-beyond-top-level",
return_std=True,
)
+ top_level_function = os.path.join(
+ REGR_DATA, "beyond_top_two/namespace_package/top_level_function.py"
+ )
output2, errors2 = lint.py_run(
- f"{os.path.join(REGR_DATA, 'beyond_top_two/namespace_package/top_level_function.py')} -d all -e relative-beyond-top-level",
+ f"{top_level_function} -d all -e relative-beyond-top-level",
return_std=True,
)
diff --git a/tests/checkers/unittest_spelling.py b/tests/checkers/unittest_spelling.py
index 29bc1bca6..838e4755a 100644
--- a/tests/checkers/unittest_spelling.py
+++ b/tests/checkers/unittest_spelling.py
@@ -75,7 +75,7 @@ class TestSpellingChecker(CheckerTestCase): # pylint:disable=too-many-public-me
@skip_on_missing_package_or_dict
@set_config(spelling_dict=spell_dict)
@set_config(max_spelling_suggestions=2)
- def test_check_bad_coment_custom_suggestion_count(self):
+ def test_check_bad_comment_custom_suggestion_count(self):
with self.assertAddsMessages(
MessageTest(
"wrong-spelling-in-comment",
diff --git a/tests/checkers/unittest_stdlib.py b/tests/checkers/unittest_stdlib.py
index f38d3e89e..9529af3ad 100644
--- a/tests/checkers/unittest_stdlib.py
+++ b/tests/checkers/unittest_stdlib.py
@@ -45,7 +45,7 @@ class TestStdlibChecker(CheckerTestCase):
While this test might seem weird since it uses a transform, it's actually testing a crash
that happened in production, but there was no way to retrieve the code for which this
- occurred (how an AssignAttr got to be the result of a function inference beats me..)"""
+ occurred (how an AssignAttr got to be the result of a function inference beats me...)"""
def infer_func(
node: Name, context: Optional[Any] = None
diff --git a/tests/checkers/unittest_typecheck.py b/tests/checkers/unittest_typecheck.py
index 8411203ae..cafb3b40f 100644
--- a/tests/checkers/unittest_typecheck.py
+++ b/tests/checkers/unittest_typecheck.py
@@ -46,7 +46,8 @@ needs_c_extension = pytest.mark.skipif(
class TestTypeChecker(CheckerTestCase):
- "Tests for pylint.checkers.typecheck"
+ """Tests for pylint.checkers.typecheck"""
+
CHECKER_CLASS = typecheck.TypeChecker
@set_config(suggestion_mode=False)
@@ -95,7 +96,8 @@ class TestTypeChecker(CheckerTestCase):
class TestTypeCheckerOnDecorators(CheckerTestCase):
- "Tests for pylint.checkers.typecheck on decorated functions."
+ """Tests for pylint.checkers.typecheck on decorated functions."""
+
CHECKER_CLASS = typecheck.TypeChecker
def test_issue3882_class_decorators(self) -> None:
diff --git a/tests/config/test_functional_config_loading.py b/tests/config/test_functional_config_loading.py
index 6ee86d679..0dacb6973 100644
--- a/tests/config/test_functional_config_loading.py
+++ b/tests/config/test_functional_config_loading.py
@@ -6,7 +6,7 @@ This launches the configuration functional tests. This permits to test configura
files by providing a file with the appropriate extension in the ``tests/config/functional``
directory.
-Let's say you have a regression_list_crash.toml file to test. Then if there is an error in the conf,
+Let's say you have a regression_list_crash.toml file to test. Then, if there is an error in the conf,
add ``regression_list_crash.out`` alongside your file with the expected output of pylint in it. Use
``{relpath}`` and ``{abspath}`` for the path of the file. The exit code will have to be 2 (error)
if this file exists.
@@ -34,8 +34,8 @@ from pylint.testutils.configuration_test import (
HERE = Path(__file__).parent
USER_SPECIFIC_PATH = HERE.parent.parent
FUNCTIONAL_DIR = HERE / "functional"
-# We use string then recast to path so we can use -k in pytest.
-# Otherwise we get 'configuration_path0' as a test name. The path is relative to the functional
+# We use string then recast to path, so we can use -k in pytest.
+# Otherwise, we get 'configuration_path0' as a test name. The path is relative to the functional
# directory because otherwise the string would be very lengthy.
ACCEPTED_CONFIGURATION_EXTENSIONS = ("toml", "ini", "cfg")
CONFIGURATION_PATHS = [
@@ -83,7 +83,7 @@ def test_functional_config_loading(
)
mock_exit.assert_called_once_with(expected_code)
out, err = capsys.readouterr()
- # rstrip() applied so we can have a final newline in the expected test file
+ # 'rstrip()' applied, so we can have a final newline in the expected test file
assert expected_output.rstrip() == out.rstrip(), msg
assert sorted(expected_loaded_configuration.keys()) == sorted(
runner.linter.config.__dict__.keys()
diff --git a/tests/message/unittest_message.py b/tests/message/unittest_message.py
index 64cadf91a..d402e1d33 100644
--- a/tests/message/unittest_message.py
+++ b/tests/message/unittest_message.py
@@ -11,13 +11,13 @@ from pylint.typing import MessageLocationTuple
def test_new_message(message_definitions: ValuesView[MessageDefinition]) -> None:
def build_message(
- message_definition: MessageDefinition, location_value: MessageLocationTuple
+ message_definition_: MessageDefinition, location_value: MessageLocationTuple
) -> Message:
return Message(
- symbol=message_definition.symbol,
- msg_id=message_definition.msgid,
+ symbol=message_definition_.symbol,
+ msg_id=message_definition_.msgid,
location=location_value,
- msg=message_definition.msg,
+ msg=message_definition_.msg,
confidence=HIGH,
)
diff --git a/tests/primer/test_primer_stdlib.py b/tests/primer/test_primer_stdlib.py
index f403cbbf5..96c847bc8 100644
--- a/tests/primer/test_primer_stdlib.py
+++ b/tests/primer/test_primer_stdlib.py
@@ -46,7 +46,7 @@ MODULES_NAMES = [m[1] for m in MODULES_TO_CHECK]
def test_primer_stdlib_no_crash(
test_module_location: str, test_module_name: str, capsys: CaptureFixture
) -> None:
- """Test that pylint does not produces any crashes or fatal errors on stdlib modules"""
+ """Test that pylint does not produce any crashes or fatal errors on stdlib modules"""
__tracebackhide__ = True # pylint: disable=unused-variable
os.chdir(test_module_location)
with _patch_stdout(io.StringIO()):
diff --git a/tests/pyreverse/test_diadefs.py b/tests/pyreverse/test_diadefs.py
index 0885598e1..b17279280 100644
--- a/tests/pyreverse/test_diadefs.py
+++ b/tests/pyreverse/test_diadefs.py
@@ -130,7 +130,7 @@ class TestDefaultDiadefGenerator:
"""functional test of relations extraction;
different classes possibly in different modules"""
# XXX should be catching pyreverse environment problem but doesn't
- # pyreverse doesn't extracts the relations but this test ok
+ # pyreverse doesn't extract the relations but this test ok
project = get_project("data")
handler = DiadefsHandler(default_config)
diadefs = handler.get_diadefs(project, Linker(project, tag=True))
diff --git a/tests/test_functional.py b/tests/test_functional.py
index eb923401d..27fda0309 100644
--- a/tests/test_functional.py
+++ b/tests/test_functional.py
@@ -74,8 +74,8 @@ def test_functional(
lint_test.runTest()
warning = None
try:
- # Catch <unknown>:x: DeprecationWarning: invalid escape sequence
- # so it's not shown during tests
+ # Catch <unknown>:x: DeprecationWarning: invalid escape sequence,
+ # so, it's not shown during tests
warning = recwarn.pop()
except AssertionError:
pass
diff --git a/tests/test_regr.py b/tests/test_regr.py
index 0936e0d06..99b600275 100644
--- a/tests/test_regr.py
+++ b/tests/test_regr.py
@@ -51,8 +51,8 @@ def disable():
@pytest.fixture
def finalize_linter(linter: PyLinter) -> Iterator[PyLinter]:
- """call reporter.finalize() to cleanup
- pending messages if a test finished badly
+ """Call reporter.finalize() to clean up pending messages if a test
+ finished badly.
"""
yield linter
linter.reporter = cast( # Due to fixture
diff --git a/tests/unittest_reporting.py b/tests/unittest_reporting.py
index c0fe77916..dbf2eb1fd 100644
--- a/tests/unittest_reporting.py
+++ b/tests/unittest_reporting.py
@@ -91,8 +91,8 @@ def test_template_option_end_line(linter) -> None:
assert out_lines[2] == "my_mod:2:0:2:4: C0301: Line too long (3/4) (line-too-long)"
-def test_template_option_non_exisiting(linter) -> None:
- """Test the msg-template option with a non existing options.
+def test_template_option_non_existing(linter) -> None:
+ """Test the msg-template option with non-existent options.
This makes sure that this option remains backwards compatible as new
parameters do not break on previous versions"""
output = StringIO()