diff --git a/.ruff.toml b/.ruff.toml index 2629a6b0..c7e7ce97 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -1,5 +1,6 @@ [lint] -extend-select = ["B", "I", "PGH", "UP"] +extend-select = ["B", "I", "PGH", "TRY", "UP"] +ignore = ["TRY003"] [lint.isort] known-third-party = ["tests"] diff --git a/tests/test_cli.py b/tests/test_cli.py index bcdd000b..34dbc5bd 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -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(): diff --git a/yamllint/__main__.py b/yamllint/__main__.py index bc16534e..529ac744 100644 --- a/yamllint/__main__.py +++ b/yamllint/__main__.py @@ -1,3 +1,18 @@ +# Copyright (C) 2016 Adrien Vergé +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + from yamllint.cli import run if __name__ == '__main__': diff --git a/yamllint/rules/quoted_strings.py b/yamllint/rules/quoted_strings.py index 5bfbd7a7..b38f6edf 100644 --- a/yamllint/rules/quoted_strings.py +++ b/yamllint/rules/quoted_strings.py @@ -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):