Closed alvesvaren closed 3 years ago
The problem here is with the type stub QtQuick.pyi
. It contains the following:
try:
import typing
except ImportError:
from PySide2.support.signature import typing
Stubs don't execute at runtime, so they should not contain try/except
statements, and they shouldn't conditionally import.
If you replace the above code with import typing
, Pylance will work as expected.
I recommend that you file a bug or a PR against PySide2.
Oh, ok, however adding a row with from typing import overload
in the same try-statement makes it work...
Yeah, if you add that statement only within the try
block, it should work. But if you import the overload
symbol in both the try
and the except
clauses, it will be evaluated by a type checker as a union type, since it will be sourced from two places. That's what's happening with typing
in the current code.
Environment data
Expected behaviour
Overloading a method with
@typing.overload
gives the same result as overloading with@overload
Actual behaviour
Overloading with
@typing.overload
makes the last version of the overloads the only one that works.Logs
Code Snippet / Additional information