Skip to content

Commit

Permalink
style: silence tryceratops warning
Browse files Browse the repository at this point in the history
TRY300 Consider moving this statement to an `else` block
  • Loading branch information
DimitriPapadopoulos authored and adrienverge committed Jan 20, 2024
1 parent 47bbb26 commit f68cae3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ def utf8_available():
try:
locale.setlocale(locale.LC_ALL, 'C.UTF-8')
locale.setlocale(locale.LC_ALL, (None, None))
return True
except locale.Error: # pragma: no cover
return False
else:
return True


def setUpModule():
Expand Down
5 changes: 3 additions & 2 deletions yamllint/rules/quoted_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,13 @@ def _quotes_are_needed(string, is_inside_a_flow):
loader.get_token()
try:
a, b = loader.get_token(), loader.get_token()
except yaml.scanner.ScannerError:
return True
else:
if (isinstance(a, yaml.ScalarToken) and a.style is None and
isinstance(b, yaml.BlockEndToken) and a.value == string):
return False
return True
except yaml.scanner.ScannerError:
return True


def _has_quoted_quotes(token):
Expand Down

0 comments on commit f68cae3

Please sign in to comment.