diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2019-05-20 09:39:22 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-05-20 09:39:22 +0200 |
commit | 2c403bbf00a52a7821a7e19cfae1f9c4f092d7da (patch) | |
tree | 9108584283492761a584120cdd2a00edb43071e6 | |
parent | 07d5e37b9d2bded9eb98e47dacd1feff6af0188a (diff) | |
download | pylint-git-2c403bbf00a52a7821a7e19cfae1f9c4f092d7da.tar.gz |
Correct infered to inferred
-rw-r--r-- | pylint/checkers/base.py | 22 | ||||
-rw-r--r-- | pylint/checkers/classes.py | 24 | ||||
-rw-r--r-- | pylint/checkers/exceptions.py | 10 | ||||
-rw-r--r-- | pylint/checkers/newstyle.py | 2 | ||||
-rw-r--r-- | pylint/checkers/stdlib.py | 6 | ||||
-rw-r--r-- | pylint/checkers/strings.py | 2 | ||||
-rw-r--r-- | pylint/checkers/typecheck.py | 36 | ||||
-rw-r--r-- | pylint/checkers/utils.py | 22 | ||||
-rw-r--r-- | pylint/checkers/variables.py | 42 |
9 files changed, 83 insertions, 83 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py index 64ca43f6f..92cd6dfc7 100644 --- a/pylint/checkers/base.py +++ b/pylint/checkers/base.py @@ -327,8 +327,8 @@ def _determine_function_name_type(node, config=None): isinstance(decorator, astroid.Attribute) and decorator.attrname in property_names ): - infered = utils.safe_infer(decorator) - if infered and infered.qname() in property_classes: + inferred = utils.safe_infer(decorator) + if inferred and inferred.qname() in property_classes: return "attr" # If the function is decorated using the prop_method.{setter,getter} # form, treat it like an attribute as well. @@ -759,12 +759,12 @@ class BasicErrorChecker(_BasicChecker): except astroid.InferenceError: return - def _check_inferred_class_is_abstract(self, infered, node): - if not isinstance(infered, astroid.ClassDef): + def _check_inferred_class_is_abstract(self, inferred, node): + if not isinstance(inferred, astroid.ClassDef): return klass = utils.node_frame_class(node) - if klass is infered: + if klass is inferred: # Don't emit the warning if the class is instantiated # in its own body or if the call is not an instance # creation. If the class is instantiated into its own @@ -772,20 +772,20 @@ class BasicErrorChecker(_BasicChecker): return # __init__ was called - abstract_methods = _has_abstract_methods(infered) + abstract_methods = _has_abstract_methods(inferred) if not abstract_methods: return - metaclass = infered.metaclass() + metaclass = inferred.metaclass() if metaclass is None: # Python 3.4 has `abc.ABC`, which won't be detected # by ClassNode.metaclass() - for ancestor in infered.ancestors(): + for ancestor in inferred.ancestors(): if ancestor.qname() == "abc.ABC": self.add_message( - "abstract-class-instantiated", args=(infered.name,), node=node + "abstract-class-instantiated", args=(inferred.name,), node=node ) break @@ -793,7 +793,7 @@ class BasicErrorChecker(_BasicChecker): if metaclass.qname() in ABC_METACLASSES: self.add_message( - "abstract-class-instantiated", args=(infered.name,), node=node + "abstract-class-instantiated", args=(inferred.name,), node=node ) def _check_yield_outside_func(self, node): @@ -1404,7 +1404,7 @@ class BasicChecker(_BasicChecker): if argument is astroid.Uninferable: return if argument is None: - # Nothing was infered. + # Nothing was inferred. # Try to see if we have iter(). if isinstance(node.args[0], astroid.Call): try: diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py index 604b8ef45..ad54bcb48 100644 --- a/pylint/checkers/classes.py +++ b/pylint/checkers/classes.py @@ -346,10 +346,10 @@ def _called_in_methods(func, klass, methods): return False for method in methods: try: - infered = klass.getattr(method) + inferred = klass.getattr(method) except astroid.NotFoundError: continue - for infer_method in infered: + for infer_method in inferred: for call in infer_method.nodes_of_class(astroid.Call): try: bound = next(call.func.infer()) @@ -385,14 +385,14 @@ def _is_attribute_property(name, klass): if attr is astroid.Uninferable: continue try: - infered = next(attr.infer()) + inferred = next(attr.infer()) except astroid.InferenceError: continue - if isinstance(infered, astroid.FunctionDef) and decorated_with_property( - infered + if isinstance(inferred, astroid.FunctionDef) and decorated_with_property( + inferred ): return True - if infered.pytype() == property_name: + if inferred.pytype() == property_name: return True return False @@ -410,7 +410,7 @@ def _safe_infer_call_result(node, caller, context=None): Safely infer the return value of a function. Returns None if inference failed or if there is some ambiguity (more than - one node has been inferred). Otherwise returns infered value. + one node has been inferred). Otherwise returns inferred value. """ try: inferit = node.infer_call_result(caller, context=context) @@ -418,7 +418,7 @@ def _safe_infer_call_result(node, caller, context=None): except astroid.InferenceError: return None # inference failed except StopIteration: - return None # no values infered + return None # no values inferred try: next(inferit) return None # there is ambiguity on the inferred node @@ -1508,7 +1508,7 @@ a metaclass class method.", for klass in expr.expr.infer(): if klass is astroid.Uninferable: continue - # The infered klass can be super(), which was + # The inferred klass can be super(), which was # assigned to a variable and the `__init__` # was called later. # @@ -1730,9 +1730,9 @@ class SpecialMethodsChecker(BaseChecker): return False def _check_iter(self, node): - infered = _safe_infer_call_result(node, node) - if infered is not None: - if not self._is_iterator(infered): + inferred = _safe_infer_call_result(node, node) + if inferred is not None: + if not self._is_iterator(inferred): self.add_message("non-iterator-returned", node=node) def _check_len(self, node): diff --git a/pylint/checkers/exceptions.py b/pylint/checkers/exceptions.py index 85c525e87..0b6827827 100644 --- a/pylint/checkers/exceptions.py +++ b/pylint/checkers/exceptions.py @@ -47,7 +47,7 @@ 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'). + ('original node', 'inferred node'). """ if isinstance(stmt, (astroid.List, astroid.Tuple)): for elt in stmt.elts: @@ -55,10 +55,10 @@ def _annotated_unpack_infer(stmt, context=None): if inferred and inferred is not astroid.Uninferable: yield elt, inferred return - for infered in stmt.infer(context): - if infered is astroid.Uninferable: + for inferred in stmt.infer(context): + if inferred is astroid.Uninferable: continue - yield stmt, infered + yield stmt, inferred def _is_raising(body: typing.List) -> bool: @@ -371,7 +371,7 @@ class ExceptionsChecker(checkers.BaseChecker): return if not isinstance(exc, astroid.ClassDef): - # Don't emit the warning if the infered stmt + # Don't emit the warning if the inferred stmt # is None, but the exception handler is something else, # maybe it was redefined. if isinstance(exc, astroid.Const) and exc.value is None: diff --git a/pylint/checkers/newstyle.py b/pylint/checkers/newstyle.py index 97e2fcb65..bc4947c6e 100644 --- a/pylint/checkers/newstyle.py +++ b/pylint/checkers/newstyle.py @@ -124,7 +124,7 @@ class NewStyleConflictChecker(BaseChecker): if klass is not supcls: name = None - # if supcls is not Uninferable, then supcls was infered + # if supcls is not Uninferable, then supcls was inferred # and use its name. Otherwise, try to look # for call.args[0].name if supcls: diff --git a/pylint/checkers/stdlib.py b/pylint/checkers/stdlib.py index c57f90e57..35f5b4e0b 100644 --- a/pylint/checkers/stdlib.py +++ b/pylint/checkers/stdlib.py @@ -374,14 +374,14 @@ class StdlibChecker(BaseChecker): ) def _check_datetime(self, node): - """ Check that a datetime was infered. + """ Check that a datetime was inferred. If so, emit boolean-datetime warning. """ try: - infered = next(node.infer()) + inferred = next(node.infer()) except astroid.InferenceError: return - if isinstance(infered, Instance) and infered.qname() == "datetime.time": + if isinstance(inferred, Instance) and inferred.qname() == "datetime.time": self.add_message("boolean-datetime", node=node) def _check_open_mode(self, node): diff --git a/pylint/checkers/strings.py b/pylint/checkers/strings.py index 9b22e5244..fd92689f6 100644 --- a/pylint/checkers/strings.py +++ b/pylint/checkers/strings.py @@ -457,7 +457,7 @@ class StringFormatChecker(BaseChecker): """ for key, specifiers in fields: # Obtain the argument. If it can't be obtained - # or infered, skip this check. + # or inferred, skip this check. if key == "": # {[0]} will have an unnamed argument, defaulting # to 0. It will not be present in `named`, so use the value diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py index 1b96d5d26..333f54ace 100644 --- a/pylint/checkers/typecheck.py +++ b/pylint/checkers/typecheck.py @@ -905,7 +905,7 @@ accessed. Python regular expressions are accepted.", break else: # we have not found any node with the attributes, display the - # message for infered nodes + # message for inferred nodes done = set() for owner, name in missingattr: if isinstance(owner, astroid.Instance): @@ -1373,15 +1373,15 @@ accessed. Python regular expressions are accepted.", def visit_with(self, node): for ctx_mgr, _ in node.items: context = astroid.context.InferenceContext() - infered = safe_infer(ctx_mgr, context=context) - if infered is None or infered is astroid.Uninferable: + inferred = safe_infer(ctx_mgr, context=context) + if inferred is None or inferred is astroid.Uninferable: continue - if isinstance(infered, bases.Generator): + if isinstance(inferred, bases.Generator): # Check if we are dealing with a function decorated # with contextlib.contextmanager. if decorated_with( - infered.parent, self.config.contextmanager_decorators + inferred.parent, self.config.contextmanager_decorators ): continue # If the parent of the generator is not the context manager itself, @@ -1410,25 +1410,25 @@ accessed. Python regular expressions are accepted.", break else: self.add_message( - "not-context-manager", node=node, args=(infered.name,) + "not-context-manager", node=node, args=(inferred.name,) ) else: try: - infered.getattr("__enter__") - infered.getattr("__exit__") + inferred.getattr("__enter__") + inferred.getattr("__exit__") except exceptions.NotFoundError: - if isinstance(infered, astroid.Instance): + if isinstance(inferred, astroid.Instance): # If we do not know the bases of this class, # just skip it. - if not has_known_bases(infered): + if not has_known_bases(inferred): continue # Just ignore mixin classes. if self.config.ignore_mixin_members: - if infered.name[-5:].lower() == "mixin": + if inferred.name[-5:].lower() == "mixin": continue self.add_message( - "not-context-manager", node=node, args=(infered.name,) + "not-context-manager", node=node, args=(inferred.name,) ) @check_messages("invalid-unary-operand-type") @@ -1464,10 +1464,10 @@ accessed. Python regular expressions are accepted.", return if is_comprehension(node): return - infered = safe_infer(node) - if infered is None or infered is astroid.Uninferable: + inferred = safe_infer(node) + if inferred is None or inferred is astroid.Uninferable: return - if not supports_membership_test(infered): + if not supports_membership_test(inferred): self.add_message( "unsupported-membership-test", args=node.as_string(), node=node ) @@ -1615,10 +1615,10 @@ class IterableChecker(BaseChecker): return if isinstance(node, astroid.DictComp): return - infered = safe_infer(node) - if infered is None or infered is astroid.Uninferable: + inferred = safe_infer(node) + if inferred is None or inferred is astroid.Uninferable: return - if not is_mapping(infered): + if not is_mapping(inferred): self.add_message("not-a-mapping", args=node.as_string(), node=node) @check_messages("not-an-iterable") diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 352608f37..2bb2d3585 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -722,11 +722,11 @@ def decorated_with_property(node: astroid.FunctionDef) -> bool: def _is_property_decorator(decorator: astroid.Name) -> bool: - for infered in decorator.infer(): - if isinstance(infered, astroid.ClassDef): - if infered.root().name == BUILTINS_NAME and infered.name == "property": + for inferred in decorator.infer(): + if isinstance(inferred, astroid.ClassDef): + if inferred.root().name == BUILTINS_NAME and inferred.name == "property": return True - for ancestor in infered.ancestors(): + for ancestor in inferred.ancestors(): if ( ancestor.name == "property" and ancestor.root().name == BUILTINS_NAME @@ -778,10 +778,10 @@ def unimplemented_abstract_methods( return {} for ancestor in mro: for obj in ancestor.values(): - infered = obj + inferred = obj if isinstance(obj, astroid.AssignName): - infered = safe_infer(obj) - if not infered: + inferred = safe_infer(obj) + if not inferred: # Might be an abstract function, # but since we don't have enough information # in order to take this decision, we're taking @@ -789,10 +789,10 @@ def unimplemented_abstract_methods( if obj.name in visited: del visited[obj.name] continue - if not isinstance(infered, astroid.FunctionDef): + if not isinstance(inferred, astroid.FunctionDef): if obj.name in visited: del visited[obj.name] - if isinstance(infered, astroid.FunctionDef): + if isinstance(inferred, astroid.FunctionDef): # It's critical to use the original name, # since after inferring, an object can be something # else than expected, as in the case of the @@ -801,9 +801,9 @@ def unimplemented_abstract_methods( # class A: # def keys(self): pass # __iter__ = keys - abstract = is_abstract_cb(infered) + abstract = is_abstract_cb(inferred) if abstract: - visited[obj.name] = infered + visited[obj.name] = inferred elif not abstract and obj.name in visited: del visited[obj.name] return visited diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py index 26a7966ef..bc967b360 100644 --- a/pylint/checkers/variables.py +++ b/pylint/checkers/variables.py @@ -159,19 +159,19 @@ def overridden_method(klass, name): return None -def _get_unpacking_extra_info(node, infered): +def _get_unpacking_extra_info(node, inferred): """return extra information to add to the message for unpacking-non-sequence and unbalanced-tuple-unpacking errors """ more = "" - infered_module = infered.root().name - if node.root().name == infered_module: - if node.lineno == infered.lineno: - more = " %s" % infered.as_string() - elif infered.lineno: - more = " defined at line %s" % infered.lineno - elif infered.lineno: - more = " defined at line %s of %s" % (infered.lineno, infered_module) + inferred_module = inferred.root().name + if node.root().name == inferred_module: + if node.lineno == inferred.lineno: + more = " %s" % inferred.as_string() + elif inferred.lineno: + more = " defined at line %s" % inferred.lineno + elif inferred.lineno: + more = " defined at line %s of %s" % (inferred.lineno, inferred_module) return more @@ -1702,9 +1702,9 @@ class VariablesChecker(BaseChecker): targets = node.targets[0].itered() try: - infered = utils.safe_infer(node.value) - if infered is not None: - self._check_unpacking(infered, node, targets) + inferred = utils.safe_infer(node.value) + if inferred is not None: + self._check_unpacking(inferred, node, targets) except astroid.InferenceError: return @@ -1778,7 +1778,7 @@ class VariablesChecker(BaseChecker): if self_cls_name in target_assign_names: self.add_message("self-cls-assignment", node=node, args=(self_cls_name)) - def _check_unpacking(self, infered, node, targets): + def _check_unpacking(self, inferred, node, targets): """ Check for unbalanced tuple unpacking and unpacking non sequences. """ @@ -1786,18 +1786,18 @@ class VariablesChecker(BaseChecker): return if utils.is_comprehension(node): return - if infered is astroid.Uninferable: + if inferred is astroid.Uninferable: return if ( - isinstance(infered.parent, astroid.Arguments) + isinstance(inferred.parent, astroid.Arguments) and isinstance(node.value, astroid.Name) - and node.value.name == infered.parent.vararg + and node.value.name == inferred.parent.vararg ): # Variable-length argument, we can't determine the length. return - if isinstance(infered, (astroid.Tuple, astroid.List)): + if isinstance(inferred, (astroid.Tuple, astroid.List)): # attempt to check unpacking is properly balanced - values = infered.itered() + values = inferred.itered() if len(targets) != len(values): # Check if we have starred nodes. if any(isinstance(target, astroid.Starred) for target in targets): @@ -1806,18 +1806,18 @@ class VariablesChecker(BaseChecker): "unbalanced-tuple-unpacking", node=node, args=( - _get_unpacking_extra_info(node, infered), + _get_unpacking_extra_info(node, inferred), len(targets), len(values), ), ) # attempt to check unpacking may be possible (ie RHS is iterable) else: - if not utils.is_iterable(infered): + if not utils.is_iterable(inferred): self.add_message( "unpacking-non-sequence", node=node, - args=(_get_unpacking_extra_info(node, infered),), + args=(_get_unpacking_extra_info(node, inferred),), ) def _check_module_attrs(self, node, module, module_names): |