From 4060436c3443af8627842d5f79f1446c076e52e4 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Fri, 31 Dec 2021 16:14:52 +0100 Subject: [PATCH] Apply suggestions from code review --- pylint/checkers/utils.py | 10 ++++++---- pylint/checkers/variables.py | 11 +++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 8619c0c686a..1ae6b90c7e8 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -57,7 +57,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 -"""some functions that may be useful for various checkers.""" +"""Some functions that may be useful for various checkers.""" import builtins import itertools import numbers @@ -314,7 +314,7 @@ def get_all_elements( def is_super(node: nodes.NodeNG) -> bool: - """return True if the node is referencing the "super" builtin function.""" + """Return True if the node is referencing the "super" builtin function.""" if getattr(node, "name", None) == "super" and node.root().name == "builtins": return True return False @@ -507,10 +507,12 @@ def __init__(self, index): 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 + """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() diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py index f53e999e2a7..204d1a87494 100644 --- a/pylint/checkers/variables.py +++ b/pylint/checkers/variables.py @@ -186,7 +186,7 @@ def in_for_else_branch(parent, stmt): @lru_cache(maxsize=1000) def overridden_method(klass, name): - """get overridden method if any.""" + """Get overridden method if any.""" try: parent = next(klass.local_attr_ancestors(name)) except (StopIteration, KeyError): @@ -578,8 +578,9 @@ def consumed(self): @property def consumed_uncertain(self) -> DefaultDict[str, List[nodes.NodeNG]]: - """Retrieves nodes filtered out by get_next_to_consume() that may not have - executed, such as statements in except blocks, or statements in try blocks (when + """Retrieves nodes filtered out by get_next_to_consume() + + Those nodes may not have executed, such as statements in except blocks, or statements in try blocks (when evaluating their corresponding except and finally blocks). Checkers that want to treat the statements as executed (e.g. for unused- @@ -1825,9 +1826,7 @@ def _is_first_level_self_reference( def _is_never_evaluated( defnode: nodes.NamedExpr, defnode_parent: nodes.IfExp ) -> bool: - """Check if a NamedExpr is inside a side of if ... - - else that never gets evaluated + """Check if a NamedExpr is inside of an 'if else' that never gets evaluated """ inferred_test = utils.safe_infer(defnode_parent.test) if isinstance(inferred_test, nodes.Const):