mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-09 14:14:53 +08:00
Whitespace changes
This commit is contained in:
@@ -52,7 +52,7 @@ def _is_future_import(import_from):
|
|||||||
# It looks like a __future__ import that is relative is still a future
|
# It looks like a __future__ import that is relative is still a future
|
||||||
# import. That feels kind of odd, but whatever.
|
# import. That feels kind of odd, but whatever.
|
||||||
# if import_from.level != 0:
|
# if import_from.level != 0:
|
||||||
# return False
|
# return False
|
||||||
from_names = import_from.get_from_names()
|
from_names = import_from.get_from_names()
|
||||||
return [n.value for n in from_names] == ['__future__']
|
return [n.value for n in from_names] == ['__future__']
|
||||||
|
|
||||||
@@ -489,38 +489,38 @@ class _StringChecks(SyntaxRule):
|
|||||||
message = "bytes can only contain ASCII literal characters."
|
message = "bytes can only contain ASCII literal characters."
|
||||||
|
|
||||||
def is_issue(self, leaf):
|
def is_issue(self, leaf):
|
||||||
string_prefix = leaf.string_prefix.lower()
|
string_prefix = leaf.string_prefix.lower()
|
||||||
if 'b' in string_prefix \
|
if 'b' in string_prefix \
|
||||||
and self._normalizer.version >= (3, 0) \
|
and self._normalizer.version >= (3, 0) \
|
||||||
and any(c for c in leaf.value if ord(c) > 127):
|
and any(c for c in leaf.value if ord(c) > 127):
|
||||||
# b'ä'
|
# b'ä'
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if 'r' not in string_prefix:
|
if 'r' not in string_prefix:
|
||||||
# Raw strings don't need to be checked if they have proper
|
# Raw strings don't need to be checked if they have proper
|
||||||
# escaping.
|
# escaping.
|
||||||
is_bytes = self._normalizer.version < (3, 0)
|
is_bytes = self._normalizer.version < (3, 0)
|
||||||
if 'b' in string_prefix:
|
if 'b' in string_prefix:
|
||||||
is_bytes = True
|
is_bytes = True
|
||||||
if 'u' in string_prefix:
|
if 'u' in string_prefix:
|
||||||
is_bytes = False
|
is_bytes = False
|
||||||
|
|
||||||
payload = leaf._get_payload()
|
payload = leaf._get_payload()
|
||||||
if is_bytes:
|
if is_bytes:
|
||||||
payload = payload.encode('utf-8')
|
payload = payload.encode('utf-8')
|
||||||
func = codecs.escape_decode
|
func = codecs.escape_decode
|
||||||
else:
|
else:
|
||||||
func = codecs.unicode_escape_decode
|
func = codecs.unicode_escape_decode
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with warnings.catch_warnings():
|
with warnings.catch_warnings():
|
||||||
# The warnings from parsing strings are not relevant.
|
# The warnings from parsing strings are not relevant.
|
||||||
warnings.filterwarnings('ignore')
|
warnings.filterwarnings('ignore')
|
||||||
func(payload)
|
func(payload)
|
||||||
except UnicodeDecodeError as e:
|
except UnicodeDecodeError as e:
|
||||||
self.add_issue(leaf, message='(unicode error) ' + str(e))
|
self.add_issue(leaf, message='(unicode error) ' + str(e))
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
self.add_issue(leaf, message='(value error) ' + str(e))
|
self.add_issue(leaf, message='(value error) ' + str(e))
|
||||||
|
|
||||||
|
|
||||||
@ErrorFinder.register_rule(value='*')
|
@ErrorFinder.register_rule(value='*')
|
||||||
|
|||||||
Reference in New Issue
Block a user