False negative when assigning generic function without parameter default to callback protocol

Abierto
#5,713 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
40/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python, rust
Área
devtools

Línea de trabajo

Start by running the snippet in the issue: a generic impl[T] without a default on name is wrongly accepted for the Proto callback protocol. Compare it with the same function without the type variable, which pyrefly already rejects correctly, to find where generic signatures are handled differently during assignability. Done when fn: Proto = impl is reported as an error and the non-generic behaviour is unchanged.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

typechecking
Describe the Bug

In the example below, impl should not be assignable to Proto, because name lacks a default value.

Removing the type-variable makes pyrefly behave as expected. [^1]

from typing import Any, Protocol

class Proto(Protocol):
    def __call__(self, arg: Any, name: str = ...) -> None: ...

def impl[T](arg: T, name: str) -> None: ...

fn: Proto = impl  # ❌️ False Negative
fn(1)  # TypeError at runtime (missing name)
Sandbox Link

https://pyrefly.org/sandbox/?project=v2.lZQ9jsIwEIWvMto03ibWFtvkAJSIAiqgMBCCJZKg2EEgxA2QOAH34DxcgCvwPMbhV0iU_pnxeOZ771vLDL52kxPviLAfAPKyGqNnjaxYCpzEzZmlii_FcXyjxK2CDPDqvN8dCg7r3gW9Xp8WiS8D-VwYUUSnw-583FNLgVnYc6ZcA9xV8ffrzhtsSVmq6sLqPCWRawNZZPwYIEIfa6vnxvckoh4W2q4bibItsWbLKlew6zofpZVYJUDT6x31BpC8nKaDnzbfSmiz2l5H-QRSRB2_QdeZwEJBYFbDqPEq_hzBo1OaWbswiZQhvKwymRZyUo6NfIiQrkBSS6XZ_h_TUcngG6R9T_A_V_mJogs

(Only applicable for extension issues) IDE Information

No response

Lenguaje dominante
Rust
Estrellas
7.2k
Forks
578
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de facebook/pyrefly

Todos los issues de facebook/pyrefly

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.