You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Setting show_none_errors in the config file causes descriptor-based attributes to no longer be detected. Instead, even when called on an instance, they return the type of the property itself.
Minimal code for reproduction:
test.py
from typing import Generic, TypeVar, overload, Any, Union
import datetime as dt
T = TypeVar('T')
class Column(Generic[T]):
@overload
def __get__(self, instance: None, owner: Any) -> "Column[T]": ...
@overload
def __get__(self, instance: object, owner: Any) -> T: ...
def __get__(self, instance: Union[None, object], owner: Any) -> "Union[Column[T], T]": ...
class MyClass:
prop: Column[dt.date] = Column()
reveal_type(MyClass.prop)
reveal_type(MyClass().prop)
That's definitely a bug; when show_none_errors is set, apparently some part of the type analysis is wrongly skipped.
But why are you using that flag? Shouldn't you use strict_optional? IIRC show_none_errors is part of a very old and buggy way to work around the errors caused by introducing strict Optional checking in a code base that was annotated before mypy supported that.
These are somewhat buggy and modern per-module options should be
preferred. I can't find any use of strict_optional_whitelist.
There is some use of show_none_errors, but it's all set to True;
I think people are just worried and cargo culting and want mypy to
really, actually give them all the errors.
Fixespython#6514, fixespython#2396
These are somewhat buggy and modern per-module options should be
preferred. I can't find any use of strict_optional_whitelist.
There is some use of show_none_errors, but it's all set to True;
I think people are just worried and cargo culting and want mypy to
really, actually give them all the errors.
Fixes#6514, fixes#2396
Setting show_none_errors in the config file causes descriptor-based attributes to no longer be detected. Instead, even when called on an instance, they return the type of the property itself.
Minimal code for reproduction:
test.py
mypy.ini:
This yields the following (expected) result:
However, uncommenting the show_none_errors line modifies the output into:
The text was updated successfully, but these errors were encountered: