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
from __future__ import annotations
from typing import TypeAlias
from typing_extensions import Sentinel
AUTO = Sentinel("AUTO")
ToLoopyTypeConvertible: TypeAlias = AUTO
configured with preset = "strict", I get the following error:
ERROR Expected `ToLoopyTypeConvertible` to be a type alias, got `Sentinel` [invalid-type-alias]
--> sent.py:11:37
|
11 | ToLoopyTypeConvertible: TypeAlias = AUTO
| ^^^^
|
INFO 1 error
basedpyright (and pyright configured with experimental features) accepts this code.
This is with pyrefly 1.0.0. The sandbox link reproduces the issue for me.
This is now solved on the latest main branch with the merging of #3575
The only edge-case I could see with the testing of this snippet is that you have to use the sentinel itself, AUTO, in narrowing operations like is AUTO/is not AUTO, you can't use the type alias. So something like this doesn't work:
But I'm not sure if you are supposed to be able to use the type alias for narrowing, I don't think PEP 661 mentioned anything regarding that, so this is probably fine. If not I can take a look at adding support for that as well.
Yeah, I think we can close this issue now. I checked, and pyright allows ToLoopyTypeConvertible to be used in place of AUTO in the type annotation but not for narrowing, so pyrefly's behavior matches pyright there.
Sentinel support will be available in pyrefly version 1.1.0.
Activity
yangdanny97 commentedon May 27, 2026
Thanks for reporting. I'm not clear on the status of sentinel support in Pyrefly ATM, so would need to look into that as a first step
[-]Type aliases of PEP661 sentinels say "Expected ... to be a type alias"[/-][+]PEP 661 sentinel support[/+]yangdanny97 commentedon May 27, 2026
I'm pretty sure we just don't support it yet because it was just accepted
hrolfurgylfa commentedon Jun 13, 2026
This is now solved on the latest main branch with the merging of #3575
The only edge-case I could see with the testing of this snippet is that you have to use the sentinel itself, AUTO, in narrowing operations like
is AUTO/is not AUTO, you can't use the type alias. So something like this doesn't work:But I'm not sure if you are supposed to be able to use the type alias for narrowing, I don't think PEP 661 mentioned anything regarding that, so this is probably fine. If not I can take a look at adding support for that as well.
rchen152 commentedon Jun 13, 2026
Yeah, I think we can close this issue now. I checked, and pyright allows
ToLoopyTypeConvertibleto be used in place ofAUTOin the type annotation but not for narrowing, so pyrefly's behavior matches pyright there.Sentinel support will be available in pyrefly version 1.1.0.