Skip to content

Commit

Permalink
Fix misc type issues (#1884)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdrozd committed Nov 22, 2022
1 parent 7a0b562 commit 396c5e1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion astroid/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions astroid/interpreter/objectmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def attr___new__(self) -> bases.BoundMethod:
)
# 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))

Expand All @@ -157,7 +157,7 @@ def attr___init__(self) -> bases.BoundMethod:
)
# 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))

Expand Down
2 changes: 1 addition & 1 deletion astroid/nodes/scoped_nodes/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def _append_node(self, child: nodes.NodeNG) -> None:
# 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
Expand Down
2 changes: 1 addition & 1 deletion astroid/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 396c5e1

Please sign in to comment.