From 396c5e16c168c93912a547a2eec0f46d7f4ed846 Mon Sep 17 00:00:00 2001 From: Nick Drozd Date: Tue, 22 Nov 2022 16:08:19 -0600 Subject: Fix misc type issues (#1884) --- astroid/inference.py | 3 ++- astroid/interpreter/objectmodel.py | 4 ++-- astroid/nodes/scoped_nodes/mixin.py | 2 +- astroid/test_utils.py | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/astroid/inference.py b/astroid/inference.py index 3d1e6ab4..b9f7b848 100644 --- a/astroid/inference.py +++ b/astroid/inference.py @@ -636,13 +636,14 @@ def _infer_old_style_string_formatting( TODO: Instead of returning Uninferable we should rely on the call to '%' to see if the result is actually uninferable. """ - values = None if isinstance(other, nodes.Tuple): if util.Uninferable in other.elts: return (util.Uninferable,) inferred_positional = [helpers.safe_infer(i, context) for i in other.elts] if all(isinstance(i, nodes.Const) for i in inferred_positional): values = tuple(i.value for i in inferred_positional) + else: + values = None elif isinstance(other, nodes.Dict): values: dict[Any, Any] = {} for pair in other.items: diff --git a/astroid/interpreter/objectmodel.py b/astroid/interpreter/objectmodel.py index 33d4174d..9741db56 100644 --- a/astroid/interpreter/objectmodel.py +++ b/astroid/interpreter/objectmodel.py @@ -142,7 +142,7 @@ class ObjectModel: ) # We set the parent as being the ClassDef of 'object' as that # triggers correct inference as a call to __new__ in bases.py - node.parent: nodes.ClassDef = AstroidManager().builtins_module["object"] + node.parent = AstroidManager().builtins_module["object"] return bases.BoundMethod(proxy=node, bound=_get_bound_node(self)) @@ -157,7 +157,7 @@ class ObjectModel: ) # We set the parent as being the ClassDef of 'object' as that # is where this method originally comes from - node.parent: nodes.ClassDef = AstroidManager().builtins_module["object"] + node.parent = AstroidManager().builtins_module["object"] return bases.BoundMethod(proxy=node, bound=_get_bound_node(self)) diff --git a/astroid/nodes/scoped_nodes/mixin.py b/astroid/nodes/scoped_nodes/mixin.py index 5b971349..ff37994c 100644 --- a/astroid/nodes/scoped_nodes/mixin.py +++ b/astroid/nodes/scoped_nodes/mixin.py @@ -109,7 +109,7 @@ class LocalsDictNodeNG(node_classes.LookupMixIn): # which uses the current class as a mixin or base class. # It's rewritten in 2.0, so it makes no sense for now # to spend development time on it. - self.body.append(child) + self.body.append(child) # type: ignore[attr-defined] child.parent = self @overload diff --git a/astroid/test_utils.py b/astroid/test_utils.py index 80c6614a..c08a4818 100644 --- a/astroid/test_utils.py +++ b/astroid/test_utils.py @@ -75,5 +75,5 @@ def brainless_manager(): m.astroid_cache = {} m._mod_file_cache = {} m._transform = transforms.TransformVisitor() - m.extension_package_whitelist = {} + m.extension_package_whitelist = set() return m -- cgit v1.2.1