diff mbox series

[meta-python,5/5] python3-pylint: fix crash with astroid >= 4.2

Message ID 20260912235141.2355852-5-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-python,1/5] python3-betamax: skip the live-network hook tests in ptest | expand

Commit Message

Khem Raj Sept. 12, 2026, 11:51 p.m. UTC
pylint 4.0.8 passes asname=False to Import.infer(), a keyword argument
astroid 4.2 removed. With the astroid 4.3.1 in meta-python this makes
pylint crash on any import of a missing submodule:

  TypeError: NodeNG.infer() got an unexpected keyword argument 'asname'

which shows up in ptest as astroid-error in three functional tests:

  FAIL: tests/test_functional.py:test_functional[fallback_import_enabled]
  FAIL: tests/test_functional.py:test_functional[import_error]
  FAIL: tests/test_functional.py:test_functional[no_name_in_module]

Backport the pylint/ part of upstream commit 554b1d192434 ("Bump
astroid to 4.2.0b4"), which drops the argument.

meta-python-image-ptest-python3-pylint on qemux86-64 now passes
872 tests with none failing.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...s-do-not-pass-asname-to-Import.infer.patch | 39 +++++++++++++++++++
 .../python/python3-pylint_4.0.8.bb            |  1 +
 2 files changed, 40 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pylint/0004-checkers-variables-do-not-pass-asname-to-Import.infer.patch
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-pylint/0004-checkers-variables-do-not-pass-asname-to-Import.infer.patch b/meta-python/recipes-devtools/python/python3-pylint/0004-checkers-variables-do-not-pass-asname-to-Import.infer.patch
new file mode 100644
index 0000000000..411ba313fc
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-pylint/0004-checkers-variables-do-not-pass-asname-to-Import.infer.patch
@@ -0,0 +1,39 @@ 
+From 554b1d1924342ce2e5b4d8f79dd62eab7cd67501 Mon Sep 17 00:00:00 2001
+From: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
+Date: Sat, 4 Jul 2026 23:17:33 +0200
+Subject: [PATCH] checkers/variables: do not pass asname to Import.infer()
+
+astroid 4.2 removed the asname keyword argument from Import/ImportFrom
+inference (astroid commit fe29fb1f7e3e, "Remove `asname` kwarg from
+Import/ImportFrom `_infer`"). With astroid >= 4.2, pylint 4.0.8 then
+crashes on any module that imports a missing submodule of a package:
+
+  TypeError: NodeNG.infer() got an unexpected keyword argument 'asname'
+  ... (astroid-error)
+
+which breaks the fallback_import_enabled, import_error and
+no_name_in_module functional tests with the astroid 4.3.1 in meta-python.
+
+This is the pylint/ part of upstream commit 554b1d192434
+("Bump `astroid` to `4.2.0b4` (#11153)"); the astroid version pin
+changes in pyproject.toml and requirements_test_min.txt are left out.
+
+Upstream-Status: Backport [https://github.com/pylint-dev/pylint/commit/554b1d192434]
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ pylint/checkers/variables.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
+index 3ce7dc63410..7e5f27b70ef 100644
+--- a/pylint/checkers/variables.py
++++ b/pylint/checkers/variables.py
+@@ -217,7 +217,7 @@ class C: ...
+ def _infer_name_module(node: nodes.Import, name: str) -> Generator[InferenceResult]:
+     context = astroid.context.InferenceContext()
+     context.lookupname = name
+-    return node.infer(context, asname=False)  # type: ignore[no-any-return]
++    return node.infer(context)  # type: ignore[no-any-return]
+ 
+ 
+ def _fix_dot_imports(
diff --git a/meta-python/recipes-devtools/python/python3-pylint_4.0.8.bb b/meta-python/recipes-devtools/python/python3-pylint_4.0.8.bb
index 90ee93e4f9..9ae03295e7 100644
--- a/meta-python/recipes-devtools/python/python3-pylint_4.0.8.bb
+++ b/meta-python/recipes-devtools/python/python3-pylint_4.0.8.bb
@@ -8,6 +8,7 @@  SRC_URI += "git://github.com/pylint-dev/pylint;branch=main;protocol=https;tag=v$
            file://0001-Adjust-test-expectations-for-ptest.patch \
            file://0002-pyproject.toml-Keep-tool.setuptools.license-files.patch \
            file://0003-astroid-4.1.2-endlineno.patch \
+           file://0004-checkers-variables-do-not-pass-asname-to-Import.infer.patch \
            file://run-ptest \
            "