[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-04-13 00:00:18 +00:00
parent 72ad6dc953
commit f4cd1ba0d6
813 changed files with 66015 additions and 58839 deletions

View file

@ -1,5 +1,7 @@
from functools import lru_cache
from __future__ import annotations
import unicodedata
from functools import lru_cache
@lru_cache(100)
@ -17,25 +19,25 @@ def wcwidth(c: str) -> int:
# Some Cf/Zp/Zl characters which should be zero-width.
if (
o == 0x0000
or 0x200B <= o <= 0x200F
or 0x2028 <= o <= 0x202E
or 0x2060 <= o <= 0x2063
o == 0x0000 or
0x200B <= o <= 0x200F or
0x2028 <= o <= 0x202E or
0x2060 <= o <= 0x2063
):
return 0
category = unicodedata.category(c)
# Control characters.
if category == "Cc":
if category == 'Cc':
return -1
# Combining characters with zero width.
if category in ("Me", "Mn"):
if category in ('Me', 'Mn'):
return 0
# Full/Wide east asian characters.
if unicodedata.east_asian_width(c) in ("F", "W"):
if unicodedata.east_asian_width(c) in ('F', 'W'):
return 2
return 1
@ -47,7 +49,7 @@ def wcswidth(s: str) -> int:
Returns -1 if the string contains non-printable characters.
"""
width = 0
for c in unicodedata.normalize("NFC", s):
for c in unicodedata.normalize('NFC', s):
wc = wcwidth(c)
if wc < 0:
return -1