`functools.partialmethod` loses return type and callable signature information
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 48/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- python
- Domínio
- developer-experience
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- Python
- Estrelas
- 5.1k
- Forks
- 2.1k
- Merge médio
- 2d 1h
- PRs com merge (30d)
- 115
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de python/typeshed
-
`networkx.set_edge_attributes` should support scalar value + nameTalvez já em andamento @Fire162 assumiu há 10 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 67/100
Mantenedores costumam responder em até 1 dia
-
false alarm on decode callTalvez já em andamento @jw9829 assumiu há 37 dias. Abertahelp wanted stubs: false positive
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
python/typeshed#16441 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Don't run pyright basic checks on projects with strict pyright settings in CITalvez já em andamento @Mohith1612 assumiu há 74 dias. Abertaproject: infrastructure
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
python/typeshed#16005 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
stubs: improvement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
python/typeshed#15548 · 5 comentários ·
Mantenedores costumam responder em até 1 dia
-
stubs: improvement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
python/typeshed#15529 · 5 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de python/typeshed
Issues semelhantes
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 78/100
521xueweihan/HelloGitHub#4237 ·
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
jejjohnson/gaussx#721 ·
Mantenedores costumam responder em até 1 dia
-
mock-core-configs/etc/mock/rocky-10-riscv64.cfg contains the wrong architecture in config_opts['root']Talvez já em andamento @jasonmontleon assumiu há 4 dias. Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 94/100
rpm-software-management/mock#1834 ·
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 75/100
elastic/elastic-otel-python#683 ·
Mantenedores costumam responder em até 1 dia
-
ci-rerun: collect.py fails a whole pr-babysit cycle on one transient GitHub 5xx and never retriesAbertafollow-up
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 1 dia