Search code examples
python-3.xpylint

Pylint: E1131: unsupported operand type(s) for | (unsupported-binary-operation) with python 3.12


Based on PEP 604 The above code should pass the pylint checking:

# test.py
def f1(a: int | str):
    print(a)

But the result I got is:

$ pylint test.py
************* Module test
test.py:3:10: E1131: unsupported operand type(s) for | (unsupported-binary-operation)

-----------------------------------
Your code has been rated at 0.00/10

Import annotations won't met this problem:

# test.py
from __future__ import annotations


def f1(a: int | str):
    print(a)
$ pylint test.py                                                                                                                                                                       TestPlatform [ hero6api/external_device][!?⇡][ v3.12.0(.venv)]

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

[Environment]
python version: 3.12
pylint: 3.03

Is this an issue unsolved yet? Or there're some mistake I did. Appreciate for answering me!


Solution

  • [Closed] I check my workspace and found .pylintrc inside. There's one line with py-version=3.8. Just edit this line.