Skip to content

Commit f68cae3

Browse files
DimitriPapadopoulosadrienverge
authored andcommitted
style: silence tryceratops warning
TRY300 Consider moving this statement to an `else` block
1 parent 47bbb26 commit f68cae3

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

tests/test_cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ def utf8_available():
6060
try:
6161
locale.setlocale(locale.LC_ALL, 'C.UTF-8')
6262
locale.setlocale(locale.LC_ALL, (None, None))
63-
return True
6463
except locale.Error: # pragma: no cover
6564
return False
65+
else:
66+
return True
6667

6768

6869
def setUpModule():

yamllint/rules/quoted_strings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,13 @@ def _quotes_are_needed(string, is_inside_a_flow):
216216
loader.get_token()
217217
try:
218218
a, b = loader.get_token(), loader.get_token()
219+
except yaml.scanner.ScannerError:
220+
return True
221+
else:
219222
if (isinstance(a, yaml.ScalarToken) and a.style is None and
220223
isinstance(b, yaml.BlockEndToken) and a.value == string):
221224
return False
222225
return True
223-
except yaml.scanner.ScannerError:
224-
return True
225226

226227

227228
def _has_quoted_quotes(token):

0 commit comments

Comments
 (0)