Skip to content

Commit

Permalink
Merge branch 'master' into pygrep-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienverge authored Jan 20, 2024
2 parents ce818c3 + 329500a commit 6b905b3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
@@ -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"]
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
15 changes: 15 additions & 0 deletions yamllint/__main__.py
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

from yamllint.cli import run

if __name__ == '__main__':
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 6b905b3

Please sign in to comment.