using-exception-groups-in-unsupported-version / W2603ΒΆ

Message emitted:

Exception groups are not supported by all versions included in the py-version setting

Description:

Used when the py-version set by the user is lower than 3.11 and pylint encounters ``except*`` or `ExceptionGroup``.

Problematic code:

def f():
    excs = [OSError("error 1"), SystemError("error 2")]
    # +1: [using-exception-groups-in-unsupported-version]
    raise ExceptionGroup("there were problems", excs)


try:  # [using-exception-groups-in-unsupported-version]
    f()
except* OSError as e:
    print("There were OSErrors")
except* SystemError as e:
    print("There were SystemErrors")

Correct code:

def f():
    raise OSError("error 1")


try:
    f()
except OSError as e:
    print("There were OSErrors")
except SystemError as e:
    print("There were SystemErrors")

Configuration file:

[main]
py-version=3.10

Additional details:

Exception groups were introduced in Python 3.11; to use it, please use a more recent version of Python.

Created by the unsupported_version checker.