Better `repr` for `string.templatelib.Template`.
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 35.9k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Feature or enhancement
Proposal:
Currently the repr output for template strings shows how the data is stored internally, but this is not how the template could be reconstructed via an constructor call and the format is unintuitive since the template parts are not output in the order they appear in the template source. The repr result should output the parts in the order as iterating over the template object does, i.e.
x = 1
y = 2
print(repr(t'{x} + {y}'))
should print
Template(Interpolation(1, 'x', None, ''), ' + ', Interpolation(2, 'y', None, ''))
instead of
Template(strings=('', ' + ', ''), interpolations=(Interpolation(1, 'x', None, ''), Interpolation(2, 'y', None, '')))
This has already been discussed at https://discuss.python.org/t/repr-output-of-t-strings/107653
I'm working on a patch/pull request.
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
https://discuss.python.org/t/repr-output-of-t-strings/107653
Linked PRs
- gh-151104
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.
Línea de trabajo
Comienza con el comportamiento de repr de string.templatelib.Template descrito en el issue y compáralo con la iteración sobre un objeto Template. Verifica que repr genere las partes de Template en el orden de iteración y coincida con el formato propuesto de llamada al constructor; gh-151104 está vinculado, así que revisa ese trabajo antes de comenzar.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- backend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 25/100