MCPcopy
hub / github.com/pytest-dev/pytest / wcswidth

Function wcswidth

src/_pytest/_io/wcwidth.py:46–57  ·  view source on GitHub ↗

Determine how many columns are needed to display a string in a terminal. Returns -1 if the string contains non-printable characters.

(s: str)

Source from the content-addressed store, hash-verified

44
45
46def wcswidth(s: str) -> int:
47 """Determine how many columns are needed to display a string in a terminal.
48
49 Returns -1 if the string contains non-printable characters.
50 """
51 width = 0
52 for c in unicodedata.normalize("NFC", s):
53 wc = wcwidth(c)
54 if wc < 0:
55 return -1
56 width += wc
57 return width

Callers 5

_format_trimmedFunction · 0.90
checkFunction · 0.90
test_wcswidthFunction · 0.90
width_of_current_lineMethod · 0.85

Calls 1

wcwidthFunction · 0.85

Tested by 2

checkFunction · 0.72
test_wcswidthFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…