Skip to content

Commit c0fbbb7

Browse files
Pierre-SassoulasDanielNoordjacobtylerwalls
authored
Fix typos accross the whole codebase (#5575)
Co-authored-by: Daniël van Noord <[email protected]> Co-authored-by: Jacob Walls <[email protected]>
1 parent 29bf25c commit c0fbbb7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+171
-168
lines changed

pylint/checkers/base.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,13 @@ def _get_break_loop_node(break_node):
298298

299299
def _loop_exits_early(loop):
300300
"""
301-
Returns true if a loop may ends up in a break statement.
301+
Returns true if a loop may end with a break statement.
302302
303303
Args:
304304
loop (astroid.For, astroid.While): the loop node inspected.
305305
306306
Returns:
307-
bool: True if the loop may ends up in a break statement, False otherwise.
307+
bool: True if the loop may end with a break statement, False otherwise.
308308
"""
309309
loop_nodes = (nodes.For, nodes.While)
310310
definition_nodes = (nodes.FunctionDef, nodes.ClassDef)
@@ -349,7 +349,7 @@ def _get_properties(config):
349349

350350

351351
def _determine_function_name_type(node: nodes.FunctionDef, config=None):
352-
"""Determine the name type whose regex the a function's name should match.
352+
"""Determine the name type whose regex the function's name should match.
353353
354354
:param node: A function node.
355355
:param config: Configuration from which to pull additional property classes.
@@ -747,7 +747,7 @@ def visit_while(self, node: nodes.While) -> None:
747747

748748
@utils.check_messages("nonexistent-operator")
749749
def visit_unaryop(self, node: nodes.UnaryOp) -> None:
750-
"""check use of the non-existent ++ and -- operator operator"""
750+
"""Check use of the non-existent ++ and -- operators"""
751751
if (
752752
(node.op in "+-")
753753
and isinstance(node.operand, nodes.UnaryOp)
@@ -1244,7 +1244,7 @@ def _has_variadic_argument(args, variadic_name):
12441244

12451245
@utils.check_messages("unnecessary-lambda")
12461246
def visit_lambda(self, node: nodes.Lambda) -> None:
1247-
"""check whether or not the lambda is suspicious"""
1247+
"""Check whether the lambda is suspicious"""
12481248
# if the body of the lambda is a call expression with the same
12491249
# argument list as the lambda itself, then the lambda is
12501250
# possibly unnecessary and at least suspicious.
@@ -1357,9 +1357,9 @@ def is_iterable(internal_node):
13571357

13581358
@utils.check_messages("unreachable", "lost-exception")
13591359
def visit_return(self, node: nodes.Return) -> None:
1360-
"""1 - check is the node has a right sibling (if so, that's some
1360+
"""1 - check if the node has a right sibling (if so, that's some
13611361
unreachable code)
1362-
2 - check is the node is inside the finally clause of a try...finally
1362+
2 - check if the node is inside the 'finally' clause of a 'try...finally'
13631363
block
13641364
"""
13651365
self._check_unreachable(node)
@@ -1375,9 +1375,9 @@ def visit_continue(self, node: nodes.Continue) -> None:
13751375

13761376
@utils.check_messages("unreachable", "lost-exception")
13771377
def visit_break(self, node: nodes.Break) -> None:
1378-
"""1 - check is the node has a right sibling (if so, that's some
1378+
"""1 - check if the node has a right sibling (if so, that's some
13791379
unreachable code)
1380-
2 - check is the node is inside the finally clause of a try...finally
1380+
2 - check if the node is inside the 'finally' clause of a 'try...finally'
13811381
block
13821382
"""
13831383
# 1 - Is it right sibling ?
@@ -1490,14 +1490,14 @@ def _check_unreachable(self, node):
14901490
self.add_message("unreachable", node=unreach_stmt)
14911491

14921492
def _check_not_in_finally(self, node, node_name, breaker_classes=()):
1493-
"""check that a node is not inside a finally clause of a
1494-
try...finally statement.
1495-
If we found before a try...finally block a parent which its type is
1496-
in breaker_classes, we skip the whole check."""
1493+
"""check that a node is not inside a 'finally' clause of a
1494+
'try...finally' statement.
1495+
If we find a parent which type is in breaker_classes before
1496+
a 'try...finally' block we skip the whole check."""
14971497
# if self._tryfinallys is empty, we're not an in try...finally block
14981498
if not self._tryfinallys:
14991499
return
1500-
# the node could be a grand-grand...-children of the try...finally
1500+
# the node could be a grand-grand...-child of the 'try...finally'
15011501
_parent = node.parent
15021502
_node = node
15031503
while _parent and not isinstance(_parent, breaker_classes):
@@ -1612,9 +1612,9 @@ def _check_self_assigning_variable(self, node):
16121612
continue
16131613
if not isinstance(target, nodes.AssignName):
16141614
continue
1615+
# Check that the scope is different from a class level, which is usually
1616+
# a pattern to expose module level attributes as class level ones.
16151617
if isinstance(scope, nodes.ClassDef) and target.name in scope_locals:
1616-
# Check that the scope is different than a class level, which is usually
1617-
# a pattern to expose module level attributes as class level ones.
16181618
continue
16191619
if target.name == lhs_name.name:
16201620
self.add_message(
@@ -2218,7 +2218,7 @@ def _check_docstring(
22182218
report_missing=True,
22192219
confidence=interfaces.HIGH,
22202220
):
2221-
"""check the node has a non empty docstring"""
2221+
"""Check if the node has a non-empty docstring"""
22222222
docstring = node.doc
22232223
if docstring is None:
22242224
docstring = _infer_dunder_doc_attribute(node)
@@ -2229,7 +2229,7 @@ def _check_docstring(
22292229
lines = utils.get_node_last_lineno(node) - node.lineno
22302230

22312231
if node_type == "module" and not lines:
2232-
# If the module has no body, there's no reason
2232+
# If the module does not have a body, there's no reason
22332233
# to require a docstring.
22342234
return
22352235
max_lines = self.config.docstring_min_length
@@ -2469,7 +2469,7 @@ def _check_literal_comparison(self, literal, node: nodes.Compare):
24692469
is_const = False
24702470
if isinstance(literal, nodes.Const):
24712471
if isinstance(literal.value, bool) or literal.value is None:
2472-
# Not interested in this values.
2472+
# Not interested in these values.
24732473
return
24742474
is_const = isinstance(literal.value, (bytes, str, int, float))
24752475

pylint/checkers/base_checker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def get_full_documentation(self, msgs, options, reports, doc=None, module=None):
8686
# Provide anchor to link against
8787
result += get_rst_title(f"{checker_title} Documentation", "^")
8888
result += f"{cleandoc(doc)}\n\n"
89-
# options might be an empty generator and not be False when casted to boolean
89+
# options might be an empty generator and not be False when cast to boolean
9090
options = list(options)
9191
if options:
9292
result += get_rst_title(f"{checker_title} Options", "^")
@@ -186,7 +186,7 @@ def get_message_definition(self, msgid):
186186
raise InvalidMessageError(error_msg)
187187

188188
def open(self):
189-
"""called before visiting project (i.e set of modules)"""
189+
"""called before visiting project (i.e. set of modules)"""
190190

191191
def close(self):
192192
"""called after visiting project (i.e set of modules)"""

pylint/checkers/design_analysis.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,8 @@ def visit_if(self, node: nodes.If) -> None:
634634
self._inc_all_stmts(branches)
635635

636636
def _check_boolean_expressions(self, node):
637-
"""Go through "if" node `node` and counts its boolean expressions
638-
639-
if the "if" node test is a BoolOp node
637+
"""Go through "if" node `node` and count its boolean expressions
638+
if the 'if' node test is a BoolOp node
640639
"""
641640
condition = node.test
642641
if not isinstance(condition, astroid.BoolOp):

pylint/checkers/exceptions.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def gather_exceptions_from_handler(
447447

448448
bare_raise = False
449449
handler_having_bare_raise = None
450-
excs_in_bare_handler = []
450+
exceptions_in_bare_handler = []
451451
for handler in node.handlers:
452452
if bare_raise:
453453
# check that subsequent handler is not parent of handler which had bare raise.
@@ -457,14 +457,14 @@ def gather_exceptions_from_handler(
457457
excs_in_current_handler = gather_exceptions_from_handler(handler)
458458
if not excs_in_current_handler:
459459
break
460-
if excs_in_bare_handler is None:
460+
if exceptions_in_bare_handler is None:
461461
# It can be `None` when the inference failed
462462
break
463463
for exc_in_current_handler in excs_in_current_handler:
464464
inferred_current = utils.safe_infer(exc_in_current_handler)
465465
if any(
466466
utils.is_subclass_of(utils.safe_infer(e), inferred_current)
467-
for e in excs_in_bare_handler
467+
for e in exceptions_in_bare_handler
468468
):
469469
bare_raise = False
470470
break
@@ -475,7 +475,7 @@ def gather_exceptions_from_handler(
475475
if handler.body[0].exc is None:
476476
bare_raise = True
477477
handler_having_bare_raise = handler
478-
excs_in_bare_handler = gather_exceptions_from_handler(handler)
478+
exceptions_in_bare_handler = gather_exceptions_from_handler(handler)
479479
else:
480480
if bare_raise:
481481
self.add_message("try-except-raise", node=handler_having_bare_raise)
@@ -525,50 +525,50 @@ def visit_tryexcept(self, node: nodes.TryExcept) -> None:
525525
)
526526
else:
527527
try:
528-
excs = list(_annotated_unpack_infer(handler.type))
528+
exceptions = list(_annotated_unpack_infer(handler.type))
529529
except astroid.InferenceError:
530530
continue
531531

532-
for part, exc in excs:
533-
if exc is astroid.Uninferable:
532+
for part, exception in exceptions:
533+
if exception is astroid.Uninferable:
534534
continue
535-
if isinstance(exc, astroid.Instance) and utils.inherit_from_std_ex(
536-
exc
537-
):
538-
exc = exc._proxied
535+
if isinstance(
536+
exception, astroid.Instance
537+
) and utils.inherit_from_std_ex(exception):
538+
exception = exception._proxied
539539

540-
self._check_catching_non_exception(handler, exc, part)
540+
self._check_catching_non_exception(handler, exception, part)
541541

542-
if not isinstance(exc, nodes.ClassDef):
542+
if not isinstance(exception, nodes.ClassDef):
543543
continue
544544

545545
exc_ancestors = [
546546
anc
547-
for anc in exc.ancestors()
547+
for anc in exception.ancestors()
548548
if isinstance(anc, nodes.ClassDef)
549549
]
550550

551551
for previous_exc in exceptions_classes:
552552
if previous_exc in exc_ancestors:
553-
msg = f"{previous_exc.name} is an ancestor class of {exc.name}"
553+
msg = f"{previous_exc.name} is an ancestor class of {exception.name}"
554554
self.add_message(
555555
"bad-except-order", node=handler.type, args=msg
556556
)
557557
if (
558-
exc.name in self.config.overgeneral_exceptions
559-
and exc.root().name == utils.EXCEPTIONS_MODULE
558+
exception.name in self.config.overgeneral_exceptions
559+
and exception.root().name == utils.EXCEPTIONS_MODULE
560560
and not _is_raising(handler.body)
561561
):
562562
self.add_message(
563-
"broad-except", args=exc.name, node=handler.type
563+
"broad-except", args=exception.name, node=handler.type
564564
)
565565

566-
if exc in exceptions_classes:
566+
if exception in exceptions_classes:
567567
self.add_message(
568-
"duplicate-except", args=exc.name, node=handler.type
568+
"duplicate-except", args=exception.name, node=handler.type
569569
)
570570

571-
exceptions_classes += [exc for _, exc in excs]
571+
exceptions_classes += [exc for _, exc in exceptions]
572572

573573

574574
def register(linter):

pylint/checkers/format.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
"""Python code format's checker.
4949
50-
By default try to follow Guido's style guide :
50+
By default, try to follow Guido's style guide :
5151
5252
https://www.python.org/doc/essays/styleguide/
5353
@@ -594,7 +594,7 @@ def visit_default(self, node: nodes.NodeNG) -> None:
594594
prev_sibl = node.previous_sibling()
595595
if prev_sibl is not None:
596596
prev_line = prev_sibl.fromlineno
597-
# The line on which a finally: occurs in a try/finally
597+
# The line on which a 'finally': occurs in a 'try/finally'
598598
# is not directly represented in the AST. We infer it
599599
# by taking the last line of the body and adding 1, which
600600
# should be the line of finally:

pylint/checkers/refactoring/recommendation_checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def visit_const(self, node: nodes.Const) -> None:
337337

338338
def _detect_replacable_format_call(self, node: nodes.Const) -> None:
339339
"""Check whether a string is used in a call to format() or '%' and whether it
340-
can be replaced by a f-string"""
340+
can be replaced by an f-string"""
341341
if (
342342
isinstance(node.parent, nodes.Attribute)
343343
and node.parent.attrname == "format"

pylint/checkers/strings.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def _check_new_format(self, node, func):
518518
# only if the .format got at least one keyword argument.
519519
# This means that the format strings accepts both
520520
# positional and named fields and we should warn
521-
# when one of the them is missing or is extra.
521+
# when one of them is missing or is extra.
522522
check_args = True
523523
else:
524524
check_args = True
@@ -961,7 +961,7 @@ def _is_long_string(string_token: str) -> bool:
961961
string_token: The string token to be parsed.
962962
963963
Returns:
964-
A boolean representing whether or not this token matches a longstring
964+
A boolean representing whether this token matches a longstring
965965
regex.
966966
"""
967967
return bool(
@@ -973,15 +973,14 @@ def _is_long_string(string_token: str) -> bool:
973973
def _get_quote_delimiter(string_token: str) -> str:
974974
"""Returns the quote character used to delimit this token string.
975975
976-
This function does little checking for whether the token is a well-formed
977-
string.
976+
This function checks whether the token is a well-formed string.
978977
979978
Args:
980979
string_token: The token to be parsed.
981980
982981
Returns:
983-
A string containing solely the first quote delimiter character in the passed
984-
string.
982+
A string containing solely the first quote delimiter character in the
983+
given string.
985984
986985
Raises:
987986
ValueError: No quote delimiter characters are present.

pylint/checkers/typecheck.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def _is_owner_ignored(owner, attrname, ignored_classes, ignored_modules):
161161
if fnmatch.fnmatch(module_qname, ignore):
162162
return True
163163

164-
# Otherwise we might have a root module name being ignored,
164+
# Otherwise, we might have a root module name being ignored,
165165
# and the qualified owner has more levels of depth.
166166
parts = deque(module_name.split("."))
167167
current_module = ""
@@ -1184,14 +1184,14 @@ def _check_dundername_is_string(self, node):
11841184
Check a string is assigned to self.__name__
11851185
"""
11861186

1187-
# Check the left hand side of the assignment is <something>.__name__
1187+
# Check the left-hand side of the assignment is <something>.__name__
11881188
lhs = node.targets[0]
11891189
if not isinstance(lhs, nodes.AssignAttr):
11901190
return
11911191
if not lhs.attrname == "__name__":
11921192
return
11931193

1194-
# If the right hand side is not a string
1194+
# If the right-hand side is not a string
11951195
rhs = node.value
11961196
if isinstance(rhs, nodes.Const) and isinstance(rhs.value, str):
11971197
return
@@ -1271,7 +1271,7 @@ def _check_argument_order(self, node, call_site, called, called_param_names):
12711271
# extract argument names, if they have names
12721272
calling_parg_names = [p.name for p in call_site.positional_arguments]
12731273

1274-
# Additionally get names of keyword arguments to use in a full match
1274+
# Additionally, get names of keyword arguments to use in a full match
12751275
# against parameters
12761276
calling_kwarg_names = [
12771277
arg.name for arg in call_site.keyword_arguments.values()
@@ -1664,7 +1664,7 @@ def _check_invalid_slice_index(self, node: nodes.Slice) -> None:
16641664
if index_type is None or index_type is astroid.Uninferable:
16651665
continue
16661666

1667-
# Constants must of type int or None
1667+
# Constants must be of type int or None
16681668
if isinstance(index_type, nodes.Const):
16691669
if isinstance(index_type.value, (int, type(None))):
16701670
continue
@@ -1733,7 +1733,8 @@ def visit_with(self, node: nodes.With) -> None:
17331733
# See the test file for not_context_manager for a couple
17341734
# of self explaining tests.
17351735

1736-
# Retrieve node from all previusly visited nodes in the the inference history
1736+
# Retrieve node from all previously visited nodes in the
1737+
# inference history
17371738
context_path_names: Iterator[Any] = filter(
17381739
None, _unflatten(context.path)
17391740
)

0 commit comments

Comments
 (0)