From 0169677b6a5a1aa126895b0374039e99b54aa09c Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Thu, 29 May 2025 18:59:43 +0200 Subject: [PATCH] MAINT: enforce string quoting style with ruff Alphabetically sort ruff.lint sections in pyproject.toml, and fix a couple of f-string instances using double quotes. --- .pre-commit-config.yaml | 1 - mesonpy/_tags.py | 2 +- pyproject.toml | 12 +++++++++--- tests/test_project.py | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d847989d6..05c42a041 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,6 @@ repos: - id: check-yaml - id: check-toml - id: debug-statements - - id: double-quote-string-fixer - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit diff --git a/mesonpy/_tags.py b/mesonpy/_tags.py index 1dab75410..60edf094d 100644 --- a/mesonpy/_tags.py +++ b/mesonpy/_tags.py @@ -173,7 +173,7 @@ def _get_ios_platform_tag() -> str: # by `packaging` as part of tag determiniation. multiarch = sys.implementation._multiarch.replace('-', '_') - return f"ios_{version[0]}_{version[1]}_{multiarch}" + return f'ios_{version[0]}_{version[1]}_{multiarch}' def get_platform_tag() -> str: diff --git a/pyproject.toml b/pyproject.toml index 8ed15f5a3..5d64c21cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,6 +85,7 @@ lint.select = [ 'E', # pycodestyle 'F', # pyflakes 'I', # isort + 'Q', # flake8-quotes 'W', # pycodestyle 'RUF100', # ruff ] @@ -92,6 +93,14 @@ exclude = [ 'docs/conf.py', ] +[tool.ruff.format] +quote-style = 'single' + +[tool.ruff.lint.flake8-quotes] +avoid-escape = false +inline-quotes = 'single' +multiline-quotes = 'single' + [tool.ruff.lint.isort] lines-between-types = 1 lines-after-imports = 2 @@ -99,9 +108,6 @@ known-first-party = [ 'mesonpy', ] -[tool.ruff.format] -quote-style = 'single' - [tool.coverage.run] disable_warnings = [ diff --git a/tests/test_project.py b/tests/test_project.py index 2f8fe0f47..fb3d08084 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -392,7 +392,7 @@ def test_ios_project(package_simple, monkeypatch, multiarch, tmp_path): # Mock being on iOS monkeypatch.setattr(sys, 'platform', 'ios') monkeypatch.setattr(platform, 'machine', Mock(return_value=arch)) - monkeypatch.setattr(sysconfig, 'get_platform', Mock(return_value=f"ios-13.0-{multiarch}")) + monkeypatch.setattr(sysconfig, 'get_platform', Mock(return_value=f'ios-13.0-{multiarch}')) ios_ver = platform.IOSVersionInfo('iOS', '13.0', 'iPhone', multiarch.endswith('simulator')) monkeypatch.setattr(platform, 'ios_ver', Mock(return_value=ios_ver))