Skip to content

Commit

Permalink
Merge pull request #2179 from pylint-dev/backport-2177-to-maintenance…
Browse files Browse the repository at this point in the history
…/2.15.x

[Backport maintenance/2.15.x] Handle `objects.Super` in `helpers.object_type()`
  • Loading branch information
Pierre-Sassoulas authored May 14, 2023
2 parents 420a59a + 554d93e commit 976d50f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
4 changes: 2 additions & 2 deletions astroid/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_brain.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ regex
types-python-dateutil
six
types-six
urllib3
urllib3>1,<2
typing_extensions>=4.4.0
1 change: 1 addition & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Expand Down
7 changes: 4 additions & 3 deletions tests/test_modutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"])


Expand Down

0 comments on commit 976d50f

Please sign in to comment.