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
i'm pretty sure this can be fixed on pyrefly's side, but i'm also opening an issue here because i think there are also improvements that can be made on the typeshed side:
is there a reason why the default value for _TzInfoT is Any? can it be tzinfo | None or just None instead?
the # type: ignore comments on the datetime.__sub__ overload have no comments explaining why they're there (or even what type checker they're for). this is probably a broader issue with typeshed in general, but i think all # type: ignore comments need an accompanying comment explaining why it's there and/or a link to a relevant issue
I don't remember exactly why Any was used as default. Possibly to reduce the churn or number of new false positives, possibly because there were problems with tzinfo | Any. But I agree that the latter would be a more desirable default. An exploratory PR would be welcome.
I agree about the # type: ignore. We also probably have many unnecessary ignores for some old type checker bugs. But generally # type: ignores are for mypy, since we tend to use type-checker specific ignores, and mypy didn't support them until recently. In this case, they are definitely for mypy, since we include the error code.
In this case the overloads are necessary because the datetime.__sub__ violates the LSP and does some shenanigans that mypy supports, but unnecessarily complains about.
@xixi-box opened #16993, which has rather extensive primer output for the default change. Hopefully, we'll be able to change the default at some point in the future if people start to explicitly annotation their datetimes.
Activity
srittau commentedon Dec 4, 2026
I don't remember exactly why
Anywas used as default. Possibly to reduce the churn or number of new false positives, possibly because there were problems withtzinfo | Any. But I agree that the latter would be a more desirable default. An exploratory PR would be welcome.I agree about the
# type: ignore. We also probably have many unnecessary ignores for some old type checker bugs. But generally# type: ignores are for mypy, since we tend to use type-checker specific ignores, and mypy didn't support them until recently. In this case, they are definitely for mypy, since we include the error code.In this case the overloads are necessary because the
datetime.__sub__violates the LSP and does some shenanigans that mypy supports, but unnecessarily complains about.srittau commentedon Dec 4, 2026
@xixi-box opened #16993, which has rather extensive primer output for the default change. Hopefully, we'll be able to change the default at some point in the future if people start to explicitly annotation their
datetimes.kinto0 commentedon Dec 4, 2026
let's see how #17023 looks as an alternative. it looks a lot better on pyrefly/ty so far