Skip to content

Commit 976d50f

Browse files
Merge pull request #2179 from pylint-dev/backport-2177-to-maintenance/2.15.x
[Backport maintenance/2.15.x] Handle `objects.Super` in `helpers.object_type()`
2 parents 420a59a + 554d93e commit 976d50f

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ What's New in astroid 2.15.5?
1212
=============================
1313
Release date: TBA
1414

15+
* Handle ``objects.Super`` in ``helpers.object_type()``.
16+
17+
Refs pylint-dev/pylint#8554
1518

1619

1720
What's New in astroid 2.15.4?

astroid/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from collections.abc import Generator
1010

11-
from astroid import bases, manager, nodes, raw_building, util
11+
from astroid import bases, manager, nodes, objects, raw_building, util
1212
from astroid.context import CallContext, InferenceContext
1313
from astroid.exceptions import (
1414
AstroidTypeError,
@@ -65,7 +65,7 @@ def _object_type(
6565
raise InferenceError
6666
elif isinstance(inferred, util.UninferableBase):
6767
yield inferred
68-
elif isinstance(inferred, (bases.Proxy, nodes.Slice)):
68+
elif isinstance(inferred, (bases.Proxy, nodes.Slice, objects.Super)):
6969
yield inferred._proxied
7070
else: # pragma: no cover
7171
raise AssertionError(f"We don't handle {type(inferred)} currently")

requirements_test_brain.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ regex
88
types-python-dateutil
99
six
1010
types-six
11-
urllib3
11+
urllib3>1,<2
1212
typing_extensions>=4.4.0

tests/test_helpers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def test_object_type(self) -> None:
4242
("type", self._extract("type")),
4343
("object", self._extract("type")),
4444
("object()", self._extract("object")),
45+
("super()", self._extract("super")),
4546
("lambda: None", self._build_custom_builtin("function")),
4647
("len", self._build_custom_builtin("builtin_function_or_method")),
4748
("None", self._build_custom_builtin("NoneType")),

tests/test_modutils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
try:
2929
import urllib3 # pylint: disable=unused-import
3030

31-
HAS_URLLIB3 = True
31+
HAS_URLLIB3_V1 = urllib3.__version__.startswith("1")
3232
except ImportError:
33-
HAS_URLLIB3 = False
33+
HAS_URLLIB3_V1 = False
3434

3535

3636
def _get_file_from_object(obj) -> str:
@@ -547,8 +547,9 @@ def test_is_module_name_part_of_extension_package_whitelist_success(self) -> Non
547547
)
548548

549549

550-
@pytest.mark.skipif(not HAS_URLLIB3, reason="This test requires urllib3.")
550+
@pytest.mark.skipif(not HAS_URLLIB3_V1, reason="This test requires urllib3 < 2.")
551551
def test_file_info_from_modpath__SixMetaPathImporter() -> None:
552+
"""Six is not backported anymore in urllib3 v2.0.0+"""
552553
assert modutils.file_info_from_modpath(["urllib3.packages.six.moves.http_client"])
553554

554555

0 commit comments

Comments
 (0)