Skip to content

Commit

Permalink
add low python version compability.
Browse files Browse the repository at this point in the history
  • Loading branch information
Бекчурин Владислав committed Nov 4, 2020
1 parent e166163 commit e5a0a29
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions test_unify.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import contextlib
import io
import sys
import tempfile
from textwrap import dedent

Expand Down Expand Up @@ -131,6 +132,7 @@ def test_backslash_train(self):
self.assertEqual(result, '''"\\\\'a"''')


@unittest.skipIf(sys.version_info < (3, 6), 'Low python version')
class TestUnitsSimpleQuotedFormatString(unittest.TestCase):

def test_no_quote_in_expression_area(self):
Expand Down Expand Up @@ -274,6 +276,7 @@ def test_no_change(self):
self.assertEqual(result, '''b"""foo"""''')


@unittest.skipIf(sys.version_info < (3, 6), 'Low python version')
class TestFstringParser(unittest.TestCase):

def test_find_expression_areas(self):
Expand Down
9 changes: 4 additions & 5 deletions unify.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,10 @@ def get_editable_string(token_type, token_string):
text_has_single = parser.text_has_single_quote()
text_has_double = parser.text_has_double_quote()
if not text_has_single and not text_has_double:
return SimpleEscapeFormatString(
**parsed_string,
parsed_body=parser.parsed_body,
expr_ids=parser.expression_ids
)
params = parsed_string.copy()
params['parsed_body'] = parser.parsed_body
params['expr_ids'] = parser.expression_ids
return SimpleEscapeFormatString(**params)
return ImmutableString(token_string)
if 'f' in parsed_string['prefix'].lower():
parser = FstringParser(parsed_string['body'])
Expand Down

0 comments on commit e5a0a29

Please sign in to comment.