ParamSpec(bound=None) incorrectly sets __bound__ to NoneType
Aperta
Nessuno ha ancora preso questa issue.
stdlib
topic-typing
type-bug
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug report
Bug description:
When creating a ParamSpec with bound=None, the runtime bound attribute is set to <class 'NoneType'> instead of None.
How to reproduce
from typing import ParamSpec, Callable
P1 = ParamSpec("P")
P2 = ParamSpec("P", bound=None)
P3 = ParamSpec("P", bound=Callable[[int, str], float])
def check_bound(label, p, expected):
got = p.__bound__
ok = (got is expected)
exp_s = repr(expected)
got_s = repr(got)
print(f"{label}.__bound__ should be {exp_s}, got {got_s} -> {'OK' if ok else 'FAIL'}")
check_bound("P1", P1, None)
check_bound("P2", P2, None)
check_bound("P3", P3, Callable[[int, str], float])
Current behavior
d:\MyCode\cpython\PCbuild\amd64>python_d.exe py_bound.py
P1.__bound__ should be None, got <class 'NoneType'> -> FAIL
P2.__bound__ should be None, got <class 'NoneType'> -> FAIL
P3.__bound__ should be typing.Callable[[int, str], float], got typing.Callable[[int, str], float] -> OK
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs
- gh-142751
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con l’implementazione di ParamSpec ed esegui la riproduzione fornita su CPython main. Verifica che un ParamSpec non associato e uno creato con bound=None espongano bound come None, mentre un ParamSpec con un bound esplicito mantenga il proprio bound; l’issue rimanda alla PR gh-142751, quindi esamina prima quel lavoro.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- backend
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 20/100