summaryrefslogtreecommitdiff
path: root/scanner.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2017-07-12 12:13:34 +0200
committerAnthon van der Neut <anthon@mnt.org>2017-07-12 12:13:34 +0200
commit2ea4de43fe2e0160e27b605f2c65f33c5a2083d7 (patch)
treeddd268394e9fa05011585fd326cb4f635f0510a1 /scanner.py
parentae5b5638efc9f20c027aac28f52dbfe0fc955998 (diff)
downloadruamel.yaml-2ea4de43fe2e0160e27b605f2c65f33c5a2083d7.tar.gz
update to flake8==3.3.0 with --ignore F405
Diffstat (limited to 'scanner.py')
-rw-r--r--scanner.py68
1 files changed, 32 insertions, 36 deletions
diff --git a/scanner.py b/scanner.py
index 3f30157..883ef96 100644
--- a/scanner.py
+++ b/scanner.py
@@ -352,7 +352,7 @@ class Scanner(object):
# position.
if self.allow_simple_key:
self.remove_possible_simple_key()
- token_number = self.tokens_taken+len(self.tokens)
+ token_number = self.tokens_taken + len(self.tokens)
key = SimpleKey(
token_number, required,
self.reader.index, self.reader.line, self.reader.column,
@@ -590,7 +590,7 @@ class Scanner(object):
# Add KEY.
key = self.possible_simple_keys[self.flow_level]
del self.possible_simple_keys[self.flow_level]
- self.tokens.insert(key.token_number-self.tokens_taken,
+ self.tokens.insert(key.token_number - self.tokens_taken,
KeyToken(key.mark, key.mark))
# If this key starts a new block mapping, we need to add
@@ -598,7 +598,7 @@ class Scanner(object):
if not self.flow_level:
if self.add_indent(key.column):
self.tokens.insert(
- key.token_number-self.tokens_taken,
+ key.token_number - self.tokens_taken,
BlockMappingStartToken(key.mark, key.mark))
# There cannot be two simple keys one after another.
@@ -1052,7 +1052,7 @@ class Scanner(object):
self.scan_block_scalar_ignored_line(start_mark)
# Determine the indentation level and go to the first non-empty line.
- min_indent = self.indent+1
+ min_indent = self.indent + 1
if increment is None:
# no increment and top level, min_indent could be 0
if min_indent < 1 and \
@@ -1066,7 +1066,7 @@ class Scanner(object):
else:
if min_indent < 1:
min_indent = 1
- indent = min_indent+increment-1
+ indent = min_indent + increment - 1
breaks, end_mark = self.scan_block_scalar_breaks(indent)
line_break = u''
@@ -1253,30 +1253,30 @@ class Scanner(object):
style)
ESCAPE_REPLACEMENTS = {
- u'0': u'\0',
- u'a': u'\x07',
- u'b': u'\x08',
- u't': u'\x09',
- u'\t': u'\x09',
- u'n': u'\x0A',
- u'v': u'\x0B',
- u'f': u'\x0C',
- u'r': u'\x0D',
- u'e': u'\x1B',
- u' ': u'\x20',
- u'\"': u'\"',
- u'/': u'/', # as per http://www.json.org/
- u'\\': u'\\',
- u'N': u'\x85',
- u'_': u'\xA0',
- u'L': u'\u2028',
- u'P': u'\u2029',
+ u'0': u'\0',
+ u'a': u'\x07',
+ u'b': u'\x08',
+ u't': u'\x09',
+ u'\t': u'\x09',
+ u'n': u'\x0A',
+ u'v': u'\x0B',
+ u'f': u'\x0C',
+ u'r': u'\x0D',
+ u'e': u'\x1B',
+ u' ': u'\x20',
+ u'\"': u'\"',
+ u'/': u'/', # as per http://www.json.org/
+ u'\\': u'\\',
+ u'N': u'\x85',
+ u'_': u'\xA0',
+ u'L': u'\u2028',
+ u'P': u'\u2029',
}
ESCAPE_CODES = {
- u'x': 2,
- u'u': 4,
- u'U': 8,
+ u'x': 2,
+ u'u': 4,
+ u'U': 8,
}
def scan_flow_scalar_non_spaces(self, double, start_mark):
@@ -1386,7 +1386,7 @@ class Scanner(object):
chunks = [] # type: List[Any]
start_mark = self.reader.get_mark()
end_mark = start_mark
- indent = self.indent+1
+ indent = self.indent + 1
# We allow zero indentation for scalars, but then we need to check for
# document separators at the beginning of the line.
# if indent == 0:
@@ -1399,17 +1399,17 @@ class Scanner(object):
while True:
ch = self.reader.peek(length)
if (ch == u':' and
- self.reader.peek(length+1) not in u'\0 \t\r\n\x85\u2028\u2029'):
+ self.reader.peek(length + 1) not in u'\0 \t\r\n\x85\u2028\u2029'):
pass
elif (ch in u'\0 \t\r\n\x85\u2028\u2029' or
(not self.flow_level and ch == u':' and
- self.reader.peek(length+1) in u'\0 \t\r\n\x85\u2028\u2029') or
+ self.reader.peek(length + 1) in u'\0 \t\r\n\x85\u2028\u2029') or
(self.flow_level and ch in u',:?[]{}')):
break
length += 1
# It's not clear what we should do with ':' in the flow context.
if (self.flow_level and ch == u':' and
- self.reader.peek(length+1) not in u'\0 \t\r\n\x85\u2028\u2029,[]{}'):
+ self.reader.peek(length + 1) not in u'\0 \t\r\n\x85\u2028\u2029,[]{}'):
self.reader.forward(length)
raise ScannerError(
"while scanning a plain scalar", start_mark,
@@ -1647,12 +1647,8 @@ class RoundTripScanner(Scanner):
# hidden streamtokens could get them (leave them and they will be
# pre comments for the next map/seq
if len(self.tokens) > 1 and \
- isinstance(self.tokens[0], (
- ScalarToken,
- ValueToken,
- FlowSequenceEndToken,
- FlowMappingEndToken,
- )) and \
+ isinstance(self.tokens[0], (ScalarToken, ValueToken,
+ FlowSequenceEndToken, FlowMappingEndToken, )) and \
isinstance(self.tokens[1], CommentToken) and \
self.tokens[0].end_mark.line == self.tokens[1].start_mark.line:
self.tokens_taken += 1