Strict type checking like if type(x) is T:
leads to wrong type restrictions
#572
Labels
bug
Something isn't working
fixed in next version (main)
A fix has been implemented and will appear in an upcoming version
Environment data
Actual Behavior
I have written a function to cast instances of any sub-classes of
datetime.date
as direct instances ofdatetime.date
, so they can be used as SQL parameters.The type of argument
date
after the type check is determined as "Never" by Pylance, and as a result, the call ofdate.toordinal()
is regarded problematic. It seems that Pylance treatsif type(x) is T:
just the same asif isinstance(x, T):
, although they are different in some degrees.Code Snippet / Additional Information
As a side note, code like
if type(x) == T
andif T is type(x)
works just fine and can be used as a work-around.The text was updated successfully, but these errors were encountered: