style: silence tryceratops warning

TRY300 Consider moving this statement to an `else` block
This commit is contained in:
Dimitri Papadopoulos
2024-01-13 11:55:36 +01:00
committed by Adrien Vergé
parent 47bbb26b42
commit f68cae3f1e
2 changed files with 5 additions and 3 deletions

View File

@@ -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():

View File

@@ -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):