`functools.partialmethod` loses return type and callable signature information
I maintainer di solito rispondono entro 1 giorno
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
- Ambito
- developer-experience
Direzione di ricerca
Start by reading the existing functools.partialmethod stub in typeshed and compare its descriptor behavior with the examples in the issue. Check the relevant stub tests for callable and descriptor typing; the issue does not name a test file. Done means preserving return-type and descriptor-binding information as far as current typing support allows, while acknowledging that a fully precise residual signature needs typing-spec support.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
For code of this shape:
from functools import partialmethod
def pprint(arg: object, /, *, options: dict) -> str:
return "dummy"
class Foo: ...
class Bar: ...
Bar.__repr__ = partialmethod(pprint, options={})
it is difficult for type checkers to verify that partialmethod is compatible with the target method since it is currently typed with only a return-type parameter:
class partialmethod(Generic[_T]):
...
def __get__(self, obj: Any, cls: type[Any] | None = None) -> Callable[..., _T]: ...
The current stub does not preserve the wrapped callable’s parameters or receiver type, so type checkers cannot model these class and instance access forms even though this ebhaviour is valid at runtime, and partialmethod is a descriptor:
Bar.__repr__ # T: (self: Bar) -> str
Bar().__repr__ # T: () -> str
This forces Pyrefly and Pyright to reject this valid code. Mypy on the other hand, looks at stub’s descriptor fallback (Any) and infers partialmethod[Any] even when the wrapped callable returns str.
We should preserve descriptor binding and as much callable information as possible, while accepting that a fully precise residual signature needs typing-spec support.
Born from Pyrefly issue, https://github.com/facebook/pyrefly/issues/5138
- Lingua principale
- Python
- Stelle
- 5.1k
- Fork
- 2.1k
- Merge medio
- 2g 1h
- PR unite (30g)
- 115
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi 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.
Altre issue di python/typeshed
-
`networkx.set_edge_attributes` should support scalar value + nameForse già presa @Fire162 l’ha presa 10 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
false alarm on decode callForse già presa @jw9829 l’ha presa 37 giorni fa. Apertahelp wanted stubs: false positive
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
python/typeshed#16441 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Don't run pyright basic checks on projects with strict pyright settings in CIForse già presa @Mohith1612 l’ha presa 74 giorni fa. Apertaproject: infrastructure
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
python/typeshed#16005 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
stubs: improvement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
python/typeshed#15548 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
stubs: improvement
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
python/typeshed#15529 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di python/typeshed
Issue simili
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
QuantConnect/Documentation#2838 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
awslabs/route53-dynamic-dns-with-lambda#67 · 1 commento ·
-
`SubAgents` returns a child run's `DeferredToolRequests` to the parent as a successful tool resultApertabug pkg:harness
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
pydantic/pydantic-ai#12405 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
good first issue help wanted
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100