py3.15: error with sentinel + type qualifier (Final / ClassVar)

Aperta
#5,560 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python, rust

Direzione di ricerca

Start with the type-checker handling of sentinel() values in type expressions, then trace how Final and ClassVar annotations affect the two failing examples in the issue. The payload does not name source files or tests, so locate the existing sentinel and qualifier coverage first. Done means both annotated class attributes are accepted in int | MARKER without errors.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the Bug

I didn't expect any errors on this code:

from typing import Final, ClassVar

class Foo:
    MARKER = sentinel("MARKER")
    _value: int | MARKER  # ✅️

class Bar:
    MARKER: ClassVar = sentinel("MARKER")
    _value: int | MARKER  # ❌️

class Baz:
    MARKER: Final = sentinel("MARKER")
    _value: int | MARKER  # ❌️
ERROR sandbox.py:9:13-25: Expected a type form, got instance of `type[int] | UnionType` [not-a-type]
ERROR sandbox.py:13:13-25: Expected a type form, got instance of `type[int] | UnionType` [not-a-type]
Sandbox Link

https://pyrefly.org/sandbox/?project=v2.I6HIhJaMsKISkaHc8vOh4eLrGOTtGgR0aHFqXklmXmqORowSRCxGCRgnICXx0FQNjCpgkoZqUFBWeDSn9f2OfoShTomwGICosYJbTJ7xc3vQjK9CMx7sPYrMBoZ6aUlmTjEkBJUVQoGczJJKeIYGF2LgHJ5flJsILNxLc5NSizQqwCaCswowB8KSHSTzpcUo-YFVWSlUV9RCIx4t2SkrBEAEFKAxCCxwgek1vRRYrANt1YvJUwaW6KkKGSUlBcVW-vow7flF6fqpefop-cnF-ig69EEOVEgsS8wEVxaoxinkg7NJMdBY7OndFOxKfGkOAA

(Only applicable for extension issues) IDE Information

No response

Lingua principale
Rust
Stelle
7.2k
Fork
578
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di facebook/pyrefly

Tutte le issue di facebook/pyrefly

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.