Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 3, 2025
1 parent b849387 commit 0a2bb62
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 48 deletions.
10 changes: 5 additions & 5 deletions _test/lib/canonical.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ def scan_tag(self):
' ': ' ',
'a': '\x07',
'b': '\x08',
'e': '\x1B',
'f': '\x0C',
'n': '\x0A',
'r': '\x0D',
'e': '\x1b',
'f': '\x0c',
'n': '\x0a',
'r': '\x0d',
't': '\x09',
'v': '\x0B',
'v': '\x0b',
'N': '\u0085',
'L': '\u2028',
'P': '\u2029',
Expand Down
6 changes: 3 additions & 3 deletions lib/ruyaml/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,9 +1105,9 @@ def __init__(self, *args, **kw):
except TypeError:
raise

__delitem__ = (
__setitem__
) = clear = pop = popitem = setdefault = update = raise_immutable
__delitem__ = __setitem__ = clear = pop = popitem = setdefault = update = (
raise_immutable
)

# need to implement __getitem__, __iter__ and __len__
def __getitem__(self, index):
Expand Down
8 changes: 4 additions & 4 deletions lib/ruyaml/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ def fp(self, mode='a'):

def check_namespace_char(ch):
# type: (Any) -> bool
if '\x21' <= ch <= '\x7E': # ! to ~
if '\x21' <= ch <= '\x7e': # ! to ~
return True
if '\xA0' <= ch <= '\uD7FF':
if '\xa0' <= ch <= '\ud7ff':
return True
if ('\uE000' <= ch <= '\uFFFD') and ch != '\uFEFF': # excl. byte order mark
if ('\ue000' <= ch <= '\ufffd') and ch != '\ufeff': # excl. byte order mark
return True
if '\U00010000' <= ch <= '\U0010FFFF':
if '\U00010000' <= ch <= '\U0010ffff':
return True
return False

Expand Down
40 changes: 20 additions & 20 deletions lib/ruyaml/emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1164,16 +1164,16 @@ def analyze_scalar(self, scalar):
# Check for line breaks, special, and unicode characters.
if ch in '\n\x85\u2028\u2029':
line_breaks = True
if not (ch == '\n' or '\x20' <= ch <= '\x7E'):
if not (ch == '\n' or '\x20' <= ch <= '\x7e'):
if (
ch == '\x85'
or '\xA0' <= ch <= '\uD7FF'
or '\uE000' <= ch <= '\uFFFD'
or '\xa0' <= ch <= '\ud7ff'
or '\ue000' <= ch <= '\ufffd'
or (
self.unicode_supplementary
and ('\U00010000' <= ch <= '\U0010FFFF')
and ('\U00010000' <= ch <= '\U0010ffff')
)
) and ch != '\uFEFF':
) and ch != '\ufeff':
# unicode_characters = True
if not self.allow_unicode:
special_characters = True
Expand Down Expand Up @@ -1234,9 +1234,9 @@ def analyze_scalar(self, scalar):
# Spaces followed by breaks, as well as special character are only
# allowed for double quoted scalars.
if special_characters:
allow_flow_plain = (
allow_block_plain
) = allow_single_quoted = allow_block = False
allow_flow_plain = allow_block_plain = allow_single_quoted = allow_block = (
False
)
elif space_break:
allow_flow_plain = allow_block_plain = allow_single_quoted = False
if not self.allow_space_break:
Expand Down Expand Up @@ -1277,7 +1277,7 @@ def write_stream_start(self):
# type: () -> None
# Write BOM if needed.
if self.encoding and self.encoding.startswith('utf-16'):
self.stream.write('\uFEFF'.encode(self.encoding))
self.stream.write('\ufeff'.encode(self.encoding))

def write_stream_end(self):
# type: () -> None
Expand Down Expand Up @@ -1423,15 +1423,15 @@ def write_single_quoted(self, text, split=True):
'\x07': 'a',
'\x08': 'b',
'\x09': 't',
'\x0A': 'n',
'\x0B': 'v',
'\x0C': 'f',
'\x0D': 'r',
'\x1B': 'e',
'\x0a': 'n',
'\x0b': 'v',
'\x0c': 'f',
'\x0d': 'r',
'\x1b': 'e',
'"': '"',
'\\': '\\',
'\x85': 'N',
'\xA0': '_',
'\xa0': '_',
'\u2028': 'L',
'\u2029': 'P',
}
Expand All @@ -1451,12 +1451,12 @@ def write_double_quoted(self, text, split=True):
ch = text[end]
if (
ch is None
or ch in '"\\\x85\u2028\u2029\uFEFF'
or ch in '"\\\x85\u2028\u2029\ufeff'
or not (
'\x20' <= ch <= '\x7E'
'\x20' <= ch <= '\x7e'
or (
self.allow_unicode
and ('\xA0' <= ch <= '\uD7FF' or '\uE000' <= ch <= '\uFFFD')
and ('\xa0' <= ch <= '\ud7ff' or '\ue000' <= ch <= '\ufffd')
)
)
):
Expand All @@ -1470,9 +1470,9 @@ def write_double_quoted(self, text, split=True):
if ch is not None:
if ch in self.ESCAPE_REPLACEMENTS:
data = '\\' + self.ESCAPE_REPLACEMENTS[ch]
elif ch <= '\xFF':
elif ch <= '\xff':
data = _F('\\x{ord_ch:02X}', ord_ch=ord(ch))
elif ch <= '\uFFFF':
elif ch <= '\uffff':
data = _F('\\u{ord_ch:04X}', ord_ch=ord(ch))
else:
data = _F('\\U{ord_ch:08X}', ord_ch=ord(ch))
Expand Down
14 changes: 7 additions & 7 deletions lib/ruyaml/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def forward_1_1(self, length=1):
):
self.line += 1
self.column = 0
elif ch != '\uFEFF':
elif ch != '\ufeff':
self.column += 1
length -= 1

Expand All @@ -173,7 +173,7 @@ def forward(self, length=1):
if ch == '\n' or (ch == '\r' and self.buffer[self.pointer] != '\n'):
self.line += 1
self.column = 0
elif ch != '\uFEFF':
elif ch != '\ufeff':
self.column += 1
length -= 1

Expand Down Expand Up @@ -203,14 +203,14 @@ def determine_encoding(self):
self.update(1)

NON_PRINTABLE = RegExp(
'[^\x09\x0A\x0D\x20-\x7E\x85'
'\xA0-\uD7FF'
'\uE000-\uFFFD'
'\U00010000-\U0010FFFF'
'[^\x09\x0a\x0d\x20-\x7e\x85'
'\xa0-\ud7ff'
'\ue000-\ufffd'
'\U00010000-\U0010ffff'
']'
)

_printable_ascii = ('\x09\x0A\x0D' + "".join(map(chr, range(0x20, 0x7F)))).encode(
_printable_ascii = ('\x09\x0a\x0d' + "".join(map(chr, range(0x20, 0x7F)))).encode(
'ascii'
)

Expand Down
18 changes: 9 additions & 9 deletions lib/ruyaml/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ def scan_to_next_token(self):
# Scanners for block, flow, and plain scalars need to be modified.
srp = self.reader.peek
srf = self.reader.forward
if self.reader.index == 0 and srp() == '\uFEFF':
if self.reader.index == 0 and srp() == '\ufeff':
srf()
found = False
_the_end = _THE_END
Expand Down Expand Up @@ -1431,17 +1431,17 @@ def scan_flow_scalar(self, style):
'b': '\x08',
't': '\x09',
'\t': '\x09',
'n': '\x0A',
'v': '\x0B',
'f': '\x0C',
'r': '\x0D',
'e': '\x1B',
'n': '\x0a',
'v': '\x0b',
'f': '\x0c',
'r': '\x0d',
'e': '\x1b',
' ': '\x20',
'"': '"',
'/': '/', # as per http://www.json.org/
'\\': '\\',
'N': '\x85',
'_': '\xA0',
'_': '\xa0',
'L': '\u2028',
'P': '\u2029',
}
Expand Down Expand Up @@ -1957,7 +1957,7 @@ def scan_to_next_token(self):

srp = self.reader.peek
srf = self.reader.forward
if self.reader.index == 0 and srp() == '\uFEFF':
if self.reader.index == 0 and srp() == '\ufeff':
srf()
found = False
while not found:
Expand Down Expand Up @@ -2356,7 +2356,7 @@ def scan_to_next_token(self):
# type: () -> None
srp = self.reader.peek
srf = self.reader.forward
if self.reader.index == 0 and srp() == '\uFEFF':
if self.reader.index == 0 and srp() == '\ufeff':
srf()
start_mark = self.reader.get_mark()
# xprintf('current_mark', start_mark.line, start_mark.column)
Expand Down

0 comments on commit 0a2bb62

Please sign in to comment.