vihava/vihava-sweval huggingface dataset:
Repository: pylint-dev/astroid

Issue:
'AsStringVisitor' object has no attribute 'visit_unknown'
```python
>>> import astroid
>>> astroid.nodes.Unknown().as_string()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/tusharsadhwani/code/marvin-python/venv/lib/python3.9/site-packages/astroid/nodes/node_ng.py", line 609, in as_string
    return AsStringVisitor()(self)
  File "/Users/tusharsadhwani/code/marvin-python/venv/lib/python3.9/site-packages/astroid/nodes/as_string.py", line 56, in __call__
    return node.accept(self).replace(DOC_NEWLINE, "\n")
  File "/Users/tusharsadhwani/code/marvin-python/venv/lib/python3.9/site-packages/astroid/nodes/node_ng.py", line 220, in accept
    func = getattr(visitor, "visit_" + self.__class__.__name__.lower())
AttributeError: 'AsStringVisitor' object has no attribute 'visit_unknown'
>>> 
```
### `python -c "from astroid import __pkginfo__; print(__pkginfo__.version)"` output

2.8.6-dev0


Discussion / hints:
Thank you for opening the issue.
I don't believe `Unknown().as_string()` is ever called regularly. AFAIK it's only used during inference. What should the string representation of an `Unknown` node be? So not sure this needs to be addressed.
Probably just `'Unknown'`.
It's mostly only a problem when we do something like this:

```python
inferred = infer(node)
if inferred is not Uninferable:
    if inferred.as_string().contains(some_value):
        ...
```
So for the most part, as long as it doesn't crash we're good.



Fix (patch):
diff --git a/ChangeLog b/ChangeLog
index 0f047d393c..944b76f91c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,10 @@ Release date: TBA
 
 * Always treat ``__class_getitem__`` as a classmethod.
 
+* Add missing ``as_string`` visitor method for ``Unknown`` node.
+
+  Closes #1264
+
 
 What's New in astroid 2.8.6?
 ============================
diff --git a/astroid/nodes/as_string.py b/astroid/nodes/as_string.py
index 427ccc151e..bc8dab1c16 100644
--- a/astroid/nodes/as_string.py
+++ b/astroid/nodes/as_string.py
@@ -36,6 +36,7 @@
         MatchSingleton,
         MatchStar,
         MatchValue,
+        Unknown,
     )
 
 # pylint: disable=unused-argument
@@ -643,6 +644,9 @@ def visit_property(self, node):
     def visit_evaluatedobject(self, node):
         return node.original.accept(self)
 
+    def visit_unknown(self, node: "Unknown") -> str:
+        return str(node)
+
 
 def _import_string(names):
     """return a list of (name, asname) formatted as a string"""


Test changes:
diff --git a/tests/unittest_nodes.py b/tests/unittest_nodes.py
index 7c78cd23ed..8c860eac3a 100644
--- a/tests/unittest_nodes.py
+++ b/tests/unittest_nodes.py
@@ -306,6 +306,11 @@ def test_f_strings(self):
         ast = abuilder.string_build(code)
         self.assertEqual(ast.as_string().strip(), code.strip())
 
+    @staticmethod
+    def test_as_string_unknown() -> None:
+        assert nodes.Unknown().as_string() == "Unknown.Unknown()"
+        assert nodes.Unknown(lineno=1, col_offset=0).as_string() == "Unknown.Unknown()"
+
 
 class _NodeTest(unittest.TestCase):
     """test transformation of If Node"""
Repository: pylint-dev/astroid

Issue:
Infer calls to str.format() on names
Future enhancement could infer this value instead of giving an empty string:

```python
from astroid import extract_node
call = extract_node("""
x = 'python is {}'
x.format('helpful sometimes')
""")
call.inferred()[0].value  # gives ""
```

_Originally posted by @jacobtylerwalls in https://github.com/PyCQA/astroid/pull/1602#discussion_r893423433_


Discussion / hints:

Fix (patch):
diff --git a/ChangeLog b/ChangeLog
index bcf244b1d9..262c3af41d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -24,7 +24,7 @@ Release date: TBA
 
 * Calls to ``str.format`` are now correctly inferred.
 
-  Closes #104
+  Closes #104, Closes #1611
 
 * Adds missing enums from ``ssl`` module.
 
diff --git a/astroid/brain/brain_builtin_inference.py b/astroid/brain/brain_builtin_inference.py
index 00253f243b..af1ddf4d23 100644
--- a/astroid/brain/brain_builtin_inference.py
+++ b/astroid/brain/brain_builtin_inference.py
@@ -913,12 +913,15 @@ def _infer_copy_method(
 
 def _is_str_format_call(node: nodes.Call) -> bool:
     """Catch calls to str.format()."""
-    return (
-        isinstance(node.func, nodes.Attribute)
-        and node.func.attrname == "format"
-        and isinstance(node.func.expr, nodes.Const)
-        and isinstance(node.func.expr.value, str)
-    )
+    if not isinstance(node.func, nodes.Attribute) or not node.func.attrname == "format":
+        return False
+
+    if isinstance(node.func.expr, nodes.Name):
+        value = helpers.safe_infer(node.func.expr)
+    else:
+        value = node.func.expr
+
+    return isinstance(value, nodes.Const) and isinstance(value.value, str)
 
 
 def _infer_str_format_call(
@@ -926,7 +929,12 @@ def _infer_str_format_call(
 ) -> Iterator[nodes.Const | type[util.Uninferable]]:
     """Return a Const node based on the template and passed arguments."""
     call = arguments.CallSite.from_call(node, context=context)
-    format_template: str = node.func.expr.value
+    if isinstance(node.func.expr, nodes.Name):
+        value: nodes.Const = helpers.safe_infer(node.func.expr)
+    else:
+        value = node.func.expr
+
+    format_template = value.value
 
     # Get the positional arguments passed
     inferred_positional = [


Test changes:
diff --git a/tests/unittest_brain_builtin.py b/tests/unittest_brain_builtin.py
index 54e7d2190d..dd99444b1f 100644
--- a/tests/unittest_brain_builtin.py
+++ b/tests/unittest_brain_builtin.py
@@ -66,6 +66,13 @@ class TestStringNodes:
         """,
                 id="mixed-indexes-from-mixed",
             ),
+            pytest.param(
+                """
+        string = "My name is {}, I'm {}"
+        string.format("Daniel", 12)
+        """,
+                id="empty-indexes-on-variable",
+            ),
         ],
     )
     def test_string_format(self, format_string: str) -> None:
Repository: pylint-dev/astroid

Issue:
Incorrect MRO inferred with multiple inheritance from module-qualified classes
### Steps to reproduce

File `other.py`:

    class A:
        pass

    class B:
        pass

Then run:

    import astroid

    class_node = astroid.extract_node("""
    import other

    class Child(other.A, other.B): #@
        pass
    """)

    print([cls.name for cls.name in class_node.mro()])

### Current behavior

    ['Child', 'A', 'object']

### Expected behavior

    ['Child', 'A', 'B', 'object']

### ``python -c "from astroid import __pkginfo__; print(__pkginfo__.version)"`` output

2.5.0


Discussion / hints:

Fix (patch):
diff --git a/ChangeLog b/ChangeLog
index a5a0be55d2..27a61f00ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -53,6 +53,10 @@ Release Date: TBA
 
 * Fixed exception-chaining error messages.
 
+* Fix failure to infer base class type with multiple inheritance and qualified names
+
+  Fixes #843
+
 * Reduce memory usage of astroid's module cache.
 
 What's New in astroid 2.4.3?
diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py
index 5c94196689..a44e6282e3 100644
--- a/astroid/scoped_nodes.py
+++ b/astroid/scoped_nodes.py
@@ -2858,7 +2858,7 @@ def _inferred_bases(self, context=None):
 
         for stmt in self.bases:
             try:
-                baseobj = next(stmt.infer(context=context))
+                baseobj = next(stmt.infer(context=context.clone()))
             except exceptions.InferenceError:
                 continue
             if isinstance(baseobj, bases.Instance):


Test changes:
diff --git a/tests/unittest_scoped_nodes.py b/tests/unittest_scoped_nodes.py
index c4597fa686..aef1a671fe 100644
--- a/tests/unittest_scoped_nodes.py
+++ b/tests/unittest_scoped_nodes.py
@@ -1417,6 +1417,22 @@ def __init__(self):
             ],
         )
 
+    def test_mro_with_attribute_classes(self):
+        cls = builder.extract_node(
+            """
+        class A:
+            pass
+        class B:
+            pass
+        scope = object()
+        scope.A = A
+        scope.B = B
+        class C(scope.A, scope.B):
+            pass
+        """
+        )
+        self.assertEqualMro(cls, ["C", "A", "B", "object"])
+
     def test_generator_from_infer_call_result_parent(self):
         func = builder.extract_node(
             """
Repository: pylint-dev/astroid

Issue:
deque misses __class_getitem__
In `brain_collections.py`, deque misses its `__class_getitem__`, implemented in Python 3.9.

Should it be added with a test version, so astroid "knows" that it's not present in Python 3.8 but is in Python 3.9?

Related to: https://github.com/PyCQA/pylint/issues/3951



Discussion / hints:

Fix (patch):
diff --git a/ChangeLog b/ChangeLog
index 02852c6978..9ff42a6e77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,14 +2,18 @@
 astroid's ChangeLog
 ===================
 
+What's New in astroid 2.5.0?
+============================
+Release Date: TBA
+
+* Enrich the ``brain_collection`` module so that ``__class_getitem__`` method is added to `deque` for
+  ``python`` version above 3.9.
+
 * The ``context.path`` is now a ``dict`` and the ``context.push`` method
   returns ``True`` if the node has been visited a certain amount of times.
 
   Close #669
 
-What's New in astroid 2.5.0?
-============================
-Release Date: TBA
 * Adds a brain for type object so that it is possible to write `type[int]` in annotation.
 
   Fixes PyCQA/pylint#4001
diff --git a/astroid/brain/brain_collections.py b/astroid/brain/brain_collections.py
index 6594e0c7ac..229969c5b0 100644
--- a/astroid/brain/brain_collections.py
+++ b/astroid/brain/brain_collections.py
@@ -4,6 +4,7 @@
 # Copyright (c) 2017 Derek Gustafson <degustaf@gmail.com>
 # Copyright (c) 2018 Ioana Tagirta <ioana.tagirta@gmail.com>
 # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com>
+# Copyright (c) 2021 Julien Palard <julien@palard.fr>
 
 # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
 # For details: https://github.com/PyCQA/astroid/blob/master/COPYING.LESSER
@@ -12,6 +13,9 @@
 import astroid
 
 
+PY39 = sys.version_info >= (3, 9)
+
+
 def _collections_transform():
     return astroid.parse(
         """
@@ -61,6 +65,10 @@ def __iadd__(self, other): pass
         def __mul__(self, other): pass
         def __imul__(self, other): pass
         def __rmul__(self, other): pass"""
+    if PY39:
+        base_deque_class += """
+        @classmethod
+        def __class_getitem__(self, item): pass"""
     return base_deque_class
 
 


Test changes:
diff --git a/tests/unittest_brain.py b/tests/unittest_brain.py
index e6ff69289a..1c004a06cf 100644
--- a/tests/unittest_brain.py
+++ b/tests/unittest_brain.py
@@ -141,6 +141,17 @@ def test_deque_py35methods(self):
         self.assertIn("insert", inferred.locals)
         self.assertIn("index", inferred.locals)
 
+    @test_utils.require_version(maxver="3.8")
+    def test_deque_not_py39methods(self):
+        inferred = self._inferred_queue_instance()
+        with self.assertRaises(astroid.exceptions.AttributeInferenceError):
+            inferred.getattr("__class_getitem__")
+
+    @test_utils.require_version(minver="3.9")
+    def test_deque_py39methods(self):
+        inferred = self._inferred_queue_instance()
+        self.assertTrue(inferred.getattr("__class_getitem__"))
+
 
 class OrderedDictTest(unittest.TestCase):
     def _inferred_ordered_dict_instance(self):