Misalignment of first line in multiline show of PyObject
- Dominant language
- Julia
- Stars
- 1.5k
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
PyObjects whose pystring method returns a multiline string have their first row misaligned when shown. For example
```julia
using PyCall
qiskit = pyimport("qiskit")
qc = qiskit.QuantumCircuit(1)
qc.x(0)
qc.draw()
```
gives
```
PyObject ┌───┐
q_0: ┤ X ├
└───┘
```
A fix would be to replace
```julia
function show(io::IO, o::PyObject)
print(io, "PyObject $(pystring(o))")
end
```
with
```julia
function show(io::IO, o::PyObject)
str = pystring(o)
sep = contains(str, "\n") ? "\n" : " " # Avoid misaligning the first line for multiline prints
print(io, "PyObject$sep$str")
end
```
which gives the following print instead.
```
PyObject
┌───┐
q_0: ┤ X ├
└───┘
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.