diff --git a/ChangeLog b/ChangeLog index 993426bd98..0308eda295 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,9 @@ What's New in astroid 2.15.5? ============================= Release date: TBA +* Handle ``objects.Super`` in ``helpers.object_type()``. + + Refs pylint-dev/pylint#8554 What's New in astroid 2.15.4? diff --git a/astroid/helpers.py b/astroid/helpers.py index 24dba6d7bc..bb19bbf4bd 100644 --- a/astroid/helpers.py +++ b/astroid/helpers.py @@ -8,7 +8,7 @@ from collections.abc import Generator -from astroid import bases, manager, nodes, raw_building, util +from astroid import bases, manager, nodes, objects, raw_building, util from astroid.context import CallContext, InferenceContext from astroid.exceptions import ( AstroidTypeError, @@ -65,7 +65,7 @@ def _object_type( raise InferenceError elif isinstance(inferred, util.UninferableBase): yield inferred - elif isinstance(inferred, (bases.Proxy, nodes.Slice)): + elif isinstance(inferred, (bases.Proxy, nodes.Slice, objects.Super)): yield inferred._proxied else: # pragma: no cover raise AssertionError(f"We don't handle {type(inferred)} currently") diff --git a/requirements_test_brain.txt b/requirements_test_brain.txt index b4778baea8..2014e07aee 100644 --- a/requirements_test_brain.txt +++ b/requirements_test_brain.txt @@ -8,5 +8,5 @@ regex types-python-dateutil six types-six -urllib3 +urllib3>1,<2 typing_extensions>=4.4.0 diff --git a/tests/test_helpers.py b/tests/test_helpers.py index fe97eb6466..90182a23ee 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -42,6 +42,7 @@ def test_object_type(self) -> None: ("type", self._extract("type")), ("object", self._extract("type")), ("object()", self._extract("object")), + ("super()", self._extract("super")), ("lambda: None", self._build_custom_builtin("function")), ("len", self._build_custom_builtin("builtin_function_or_method")), ("None", self._build_custom_builtin("NoneType")), diff --git a/tests/test_modutils.py b/tests/test_modutils.py index 0c8bee8880..04f5eeed68 100644 --- a/tests/test_modutils.py +++ b/tests/test_modutils.py @@ -28,9 +28,9 @@ try: import urllib3 # pylint: disable=unused-import - HAS_URLLIB3 = True + HAS_URLLIB3_V1 = urllib3.__version__.startswith("1") except ImportError: - HAS_URLLIB3 = False + HAS_URLLIB3_V1 = False def _get_file_from_object(obj) -> str: @@ -547,8 +547,9 @@ def test_is_module_name_part_of_extension_package_whitelist_success(self) -> Non ) -@pytest.mark.skipif(not HAS_URLLIB3, reason="This test requires urllib3.") +@pytest.mark.skipif(not HAS_URLLIB3_V1, reason="This test requires urllib3 < 2.") def test_file_info_from_modpath__SixMetaPathImporter() -> None: + """Six is not backported anymore in urllib3 v2.0.0+""" assert modutils.file_info_from_modpath(["urllib3.packages.six.moves.http_client"])