stubgen creates duplicate class definitions
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza con stubgen y su gestión de las definiciones condicionales de plataforma en serialposix; el archivo generado stubs/serial/serialposix.pyi muestra las declaraciones duplicadas de PlatformSpecific. Determina cómo deben representarse las definiciones de clases específicas de la plataforma y, a continuación, verifica que el stub generado ya no produzca nombres duplicados y que mypy lo acepte en todas las plataformas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
I need a stub for the serial package, and attempted to use stubgen to create it. The problem arises in the serialposix subpackage, which defines the PlatformSpecific class differently depending upon the platform it's running on. When stubgen processes this code, it discards all the conditional pieces, the end result being multiple definitions of the PlatformSpecific class, which, not surprisingly, mypy is very unhappy about.
Here's what the original code looks like (trimmed for compactness):
plat = sys.platform.lower()
if plat[:5] == 'linux': # Linux (confirmed) # noqa
class PlatformSpecific(PlatformSpecificBase):
…
elif plat == 'cygwin': # cygwin/win32 (confirmed)
class PlatformSpecific(PlatformSpecificBase):
…
elif plat[:6] == 'darwin': # OS X
class PlatformSpecific(PlatformSpecificBase):
…
and so on. You get the picture.
Running mypy after generating the stub gives:
stubs/serial/serialposix.pyi:24: error: Name 'PlatformSpecific' already defined on line 20 stubs/serial/serialposix.pyi:29: error: Name 'PlatformSpecific' already defined on line 20 stubs/serial/serialposix.pyi:37: error: Name 'PlatformSpecific' already defined on line 20 stubs/serial/serialposix.pyi:42: error: Name 'PlatformSpecific' already defined on line 20
Now, I can manually go in and edit the generated stub, commenting out the class definitions for platforms other than the one I am running on. But the problem is that I can't then check in that stub and expect mypy to run correctly on other platforms.
I don't think this is a typeshed issue, because I don't see a way that the stub can be written to work across platforms, which seems to be a problem inherent in the way that stubgen, and stubs in general, work. Unless I'm missing something (which is entirely possible), there is nothing in mypy that will allow this type of code to be stubbed successfully.
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Merge medio
- 1 d 18 h
- PR fusionados (30 d)
- 54
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python/mypy
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
bug topic-configuration topic-error-reporting
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Todos los issues de python/mypy
Issues similares
-
area/auth bug comp/agent P3 platform/discord type/security
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
NousResearch/hermes-agent#117848 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
bancolombia/sentinel#23 ·
-
test md AbiertoCI
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100