context.run prints the codes of unicode chars from the output instead of printing the unicode characters themselves

Abierto
#1,014 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python
Área
cli

Línea de trabajo

Reproduce the issue with the provided task and invoke black, then inspect the output handling used by Context.run. Compare its behavior with direct black src and subprocess.run; done means Unicode characters such as ✨ and 🍰 are printed directly rather than as escape codes.

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

Descripción

Create this simple task:

from invoke.tasks import task
from invoke.context import Context


@task
def black(c: Context) -> None:
    """Formats code with `black`."""
    c.run("black src")

Run the task with invoke:

invoke black

The invoke prints the code of the unicode chars returned by the black in its output:

All done! \u2728 \U0001f370 \u2728
...

However, this is the expected output (the output of running directly black src):

All done! ✨ 🍰 ✨
...

Executing black with subprocess.run produces the expected result:

Python 3.12.6 (tags/v3.12.6:a4a2d2b, Sep  6 2024, 20:11:23) [MSC v.1940 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess   
>>> subprocess.run("black src")
All done! ✨ 🍰 ✨
...
CompletedProcess(args='black src', returncode=0)
>>>
Lenguaje dominante
Python
Estrellas
4.8k
Forks
412
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

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 pyinvoke/invoke

Todos los issues de pyinvoke/invoke

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.