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
{{ message }}
Repository navigation
invalid-sentinel - why does the argument have to be a literal? #4142
I took a quick look, and pyrefly already falls back to the assigned name when sentinel gets a non-literal argument, so I think we can relax this restriction. The discussion on the conformance test is ongoing, but in the current state, we don't need to check that the names match. We can add this error back if that changes.
Activity
yangdanny97 commentedon Jul 21, 2026
I don't think it's a hard constraint, but we can't validate that the variable has the same name as the sentinel if we don't know the name statically
DetachHead commentedon Jul 27, 2026
ah, i must've missed this part of the PEP:
ideally the type checker shouldn't have special-case an error when the argument isn't a
LiteralStringthough. that's typeshed's job. see these PRs:LiteralStringforsentinelname python/typeshed#16094LiteralStringforSentinelname python/typing_extensions#783DetachHead commentedon Jul 27, 2026
looks like pyrefly currently doesn't do that:
sandbox
AlexWaygood commentedon Jul 27, 2026
Note that python/typing#2277 proposes to remove this text when adding this PEP to the spec and conformance suite.
rchen152 commentedon Jul 29, 2026
I took a quick look, and pyrefly already falls back to the assigned name when
sentinelgets a non-literal argument, so I think we can relax this restriction. The discussion on the conformance test is ongoing, but in the current state, we don't need to check that the names match. We can add this error back if that changes.Relax restriction on sentinel names
Relax restriction on sentinel names