python / python/typeshed

colorful how to handle dynamic types

Abierto
#15,012 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

stubs: false positive
Lenguaje dominante
Python
Estrellas
5.1k
Forks
2.1k
Merge medio
1 d 19 h
PR fusionados (30 d)
82

Descripción

I played around with the new colorful types and there is a interesting problem.
Colorful takes full advantage of __getattr__ and im a bit out of ideas how to type this.

Common usage is (also seen in the readme):

import colorful as cf
print(cf.bold_white('Hello World'))

Where bold_white is dynamically build with the dynamically loadable color plate and a modifier.

Which makes this valid working python code:

import colorful as cf
print(cf.bold_underlined_struckthrough_italic_bold_red("typeshed"))

where the color from the pallet is red and the modifiers are separated by a _ and need to be out of a list of MODIFIERS but otherwise can be combined in any order and even be repeated.

MODIFIERS = {
    'reset': (0, 0),
    'bold': (1, 22),
    'dimmed': (2, 22),
    'italic': (3, 23),
    'underlined': (4, 24),
    'blinkslow': (5, 25),
    'blinkrapid': (6, 25),
    'inversed': (7, 27),
    'concealed': (8, 28),
    'struckthrough': (9, 29)
}

Is there any good solution to type something this dynamic?
Or is the only way to kinda allow everything after colorful.<anything>

Guía de contribución

Abrir la guía de contribución

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.

Línea de trabajo

Comienza con el uso de colorful en README y el comportamiento dinámico de getattr descrito en el issue; después, examina cómo se forman las combinaciones de MODIFIERS. Se consideraría completado cuando exista un enfoque de tipado acordado para los atributos construidos dinámicamente; el issue no menciona ningún archivo objetivo ni ninguna prueba.

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

Evaluación

Stack tecnológico
python
Área
developer-experience
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.