Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False type inference: no-member in except* #9056

Open
rkupke opened this issue Sep 22, 2023 · 1 comment
Open

False type inference: no-member in except* #9056

rkupke opened this issue Sep 22, 2023 · 1 comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code inference python 3.11

Comments

@rkupke
Copy link

rkupke commented Sep 22, 2023

Bug description

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 30 11:15:39 2023
"""

# pylint: disable=W0104,W0107,C0115,C0199,C0116,C0103,W0106

import typing


try:
    try:
        ex_list = [ValueError("a"), ValueError("b"),  Exception("c")]
        raise ExceptionGroup("exceptions!", ex_list)
    except* ValueError as exc:
        print(repr(exc))

        typing.reveal_type(exc)
        assert isinstance(exc, ExceptionGroup)
        assert hasattr(exc, "message")
        assert hasattr(exc, "exceptions")

        # E1101:no-member: 25,8: Instance of 'ValueError' has no 'message' member
        exc.message

        # E1101:no-member: 28,8: Instance of 'ValueError' has no 'exceptions' member
        exc.exceptions

        # E1101:no-member: 31,8: Instance of 'ValueError' has no 'message' member
        typing.cast(ExceptionGroup, exc).message

        pass
except ExceptionGroup as exc:
    print(repr(exc))
    exc.message  # this works
    exc.exceptions
    pass

Configuration

No response

Command used

pylint Schreibtisch/test.py

Pylint output

************* Module test
Schreibtisch/test.py:25:8: E1101: Instance of 'ValueError' has no 'message' member (no-member)
Schreibtisch/test.py:28:8: E1101: Instance of 'ValueError' has no 'exceptions' member (no-member)
Schreibtisch/test.py:31:8: E1101: Instance of 'ValueError' has no 'message' member (no-member)

------------------------------------------------------------------
Your code has been rated at 2.50/10 (previous run: 2.50/10, +0.00)

Expected behavior

Type of exc should be inferred as ExceptionGroup

Pylint version

pylint 2.17.4
astroid 2.15.6
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]

OS / Environment

uname -a
Linux odysseus 6.1.0-12-arm64 #1 SMP Debian 6.1.52-1 (2023-09-07) aarch64 GNU/Linux

Additional dependencies

No response

@rkupke rkupke added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Sep 22, 2023
@mbyrnepr2
Copy link
Member

mbyrnepr2 commented Sep 22, 2023

Thank you for reporting the issue. The fix for #8985 will possibly also fix this.

@jacobtylerwalls jacobtylerwalls changed the title False type inference: no-member in exept* False type inference: no-member in except* Sep 22, 2023
@nickdrozd nickdrozd added inference False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code inference python 3.11
Projects
None yet
Development

No branches or pull requests

4 participants