Skip to content

Add Consider-using-f-string checker (#4796) [coderabbit]#17

Open
kallsyms wants to merge 1 commit into
prefrom
auto-pr-66ffcbc4-coderabbit
Open

Add Consider-using-f-string checker (#4796) [coderabbit]#17
kallsyms wants to merge 1 commit into
prefrom
auto-pr-66ffcbc4-coderabbit

Conversation

@kallsyms

Copy link
Copy Markdown
  • Add consider-using-f-string checker
    This adds a checker for normal strings which are formatted
    with .format() or '%'.
    The message is a convention to nudge users towards using f-strings.
    This closes #3592

  • Update pylint code to use f-strings
    After adding consider-using-f-strings the codebase showed numerous
    cases of formatting which could be f-strings.
    This commit changes most of these to become f-strings, or adds ignores.

  • Apply suggestions from code review

Co-authored-by: Pierre Sassoulas pierre.sassoulas@gmail.com

* Add ``consider-using-f-string`` checker
This adds a checker for normal strings which are formatted
with ``.format()`` or '%'.
The message is a convention to nudge users towards using f-strings.
This closes #3592

* Update pylint code to use f-strings
After adding `consider-using-f-strings` the codebase showed numerous
cases of formatting which could be f-strings.
This commit changes most of these to become f-strings, or adds ignores.

* Apply suggestions from code review

Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
@kallsyms

Copy link
Copy Markdown
Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jun 20, 2025

Copy link
Copy Markdown
✅ Actions performed

Full review triggered.

@coderabbitai

coderabbitai Bot commented Jun 20, 2025

Copy link
Copy Markdown

Walkthrough

This update modernizes string formatting throughout the codebase by replacing old-style % and .format() expressions with Python f-strings. It also introduces a new Pylint checker, consider-using-f-string, which emits warnings when .format() or % formatting is used where f-strings are preferable. Corresponding tests, documentation, and disables for this warning are added or updated.

Changes

File(s) Change Summary
pylint/checkers/strings.py Added "consider-using-f-string" checker, new message, and logic to detect .format() and % formatting.
doc/whatsnew/2.11.rst, ChangeLog Documented new checker and message; changelog updated.
tests/functional/c/consider/consider_using_f_string.py, tests/functional/c/consider/consider_using_f_string.txt Added new functional test and expected output for f-string checker.
pylint/checkers/base.py, pylint/checkers/classes.py, pylint/checkers/exceptions.py, pylint/checkers/imports.py, pylint/checkers/misc.py, pylint/checkers/raw_metrics.py, pylint/checkers/refactoring/not_checker.py, pylint/checkers/refactoring/refactoring_checker.py, pylint/checkers/similar.py, pylint/checkers/spelling.py, pylint/checkers/typecheck.py, pylint/checkers/variables.py, pylint/checkers/__init__.py, pylint/checkers/base_checker.py Refactored string formatting to use f-strings.
pylint/config/__init__.py, pylint/config/man_help_formatter.py, pylint/config/option.py, pylint/config/option_manager_mixin.py Updated error/help messages to use f-strings; added/adjusted linter disables as needed.
pylint/epylint.py, pylint/graph.py, pylint/lint/pylinter.py, pylint/lint/report_functions.py, pylint/lint/run.py, pylint/lint/utils.py Modernized string formatting to f-strings throughout linter/reporting modules.
pylint/message/message_definition.py, pylint/message/message_handler_mix_in.py Updated message formatting and documentation generation to use f-strings.
pylint/pyreverse/diadefslib.py, pylint/pyreverse/diagrams.py, pylint/pyreverse/inspector.py, pylint/pyreverse/utils.py, pylint/pyreverse/vcg_printer.py Refactored string formatting in pyreverse utilities and diagram generation.
pylint/reporters/base_reporter.py, pylint/reporters/reports_handler_mix_in.py, pylint/reporters/text.py, pylint/reporters/ureports/nodes.py, pylint/reporters/ureports/text_writer.py Updated reporter output and formatting logic to use f-strings.
pylint/extensions/_check_docs_utils.py Refactored regex string construction to use f-string raw literals.
pylint/extensions/broad_try_clause.py, pylint/extensions/mccabe.py, pylint/extensions/overlapping_exceptions.py Modernized string formatting in extension checkers.
doc/exts/pylint_extensions.py Updated module name construction to use f-strings.
script/bump_changelog.py Switched to f-string for release date message; added disables for linter warnings.
pylint/utils/utils.py Refactored multiple string formatting cases to use f-strings.
tests/benchmark/test_baseline_benchmarks.py, tests/checkers/unittest_python3.py, tests/checkers/unittest_similar.py, tests/functional/n/new_style_class_py_30.py, tests/functional/s/slots_checks.py, tests/functional/t/too/too_many_return_statements.py, tests/functional/u/unused/unused_argument.py, tests/input/func_w0401_package/thing2.py, tests/profile/test_profile_against_externals.py, tests/pyreverse/test_utils.py, tests/test_check_parallel.py, tests/test_epylint.py, tests/test_func.py, tests/test_self.py, pylint/testutils/lint_module_test.py, pylint/testutils/reporter_for_tests.py Updated test code to use f-strings; added disables for f-string checker where needed.
tests/functional/a/arguments.py, tests/functional/d/docstrings.py, tests/functional/d/duplicate_string_formatting_argument.py, tests/functional/l/logging_format_interpolation.py, tests/functional/l/logging_not_lazy.py, tests/functional/l/logging_not_lazy_with_logger.py, tests/functional/l/logging_not_lazy_with_logger.txt, tests/functional/m/misplaced_format_function.py, tests/functional/r/raise/raising_format_tuple.py, tests/functional/r/renamed_import_logging_not_lazy.py, tests/functional/s/string/string_formatting.py, tests/functional/s/string/string_formatting_error.py, tests/functional/s/string/string_formatting_failed_inference.py, tests/functional/s/string/string_formatting_failed_inference_py35.py, tests/functional/s/string/string_formatting_py3.py, tests/functional/u/undefined/undefined_loop_variable.py, tests/functional/u/use/used_before_assignement.py, tests/functional/u/use/used_before_assignment_issue853.py Added or updated disables for "consider-using-f-string" warning in test files.
pylint/testutils/constants.py, script/bump_changelog.py, tests/test_check_parallel.py, tests/test_epylint.py, pylint/checkers/classes.py Added disables for f-string checker where old formatting is intentionally kept.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Pylint
    participant StringConstantChecker

    User->>Pylint: Analyze Python code
    Pylint->>StringConstantChecker: Visit string constant node
    StringConstantChecker->>StringConstantChecker: Check for .format() or % formatting
    alt Simple formatting detected
        StringConstantChecker->>Pylint: Emit "consider-using-f-string" message
    else Complex formatting or unpacking
        StringConstantChecker->>Pylint: No warning emitted
    end
    Pylint->>User: Report findings (including any f-string suggestions)
Loading
sequenceDiagram
    participant Developer
    participant Codebase

    Developer->>Codebase: Update string formatting expressions
    Codebase->>Codebase: Replace %/.format() with f-strings
    Codebase->>Developer: Modernized code with f-string formatting
Loading
sequenceDiagram
    participant TestRunner
    participant FunctionalTest
    participant Checker

    TestRunner->>FunctionalTest: Run test cases
    FunctionalTest->>Checker: Provide code samples using .format() and %
    Checker->>FunctionalTest: Emit "consider-using-f-string" warnings for simple cases
    FunctionalTest->>TestRunner: Assert warnings match expected output
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai

coderabbitai Bot commented Jun 20, 2025

Copy link
Copy Markdown
✅ Actions performed

Full review triggered.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (9)
pylint/reporters/ureports/text_writer.py (1)

97-97: Consider direct variable write instead of f-string.

Using self.write(f"{layout.data}") works, but an f-string around a single variable is redundant. Consider simplifying to:

-        self.write(f"{layout.data}")
+        self.write(layout.data)
tests/functional/m/misplaced_format_function.py (1)

4-4: Consider merging disable directives for consistency.

You’ve added a separate # pylint: disable=consider-using-f-string line. To reduce duplication and keep disables consolidated, consider appending consider-using-f-string to the existing disable list on line 3 rather than a standalone directive.

tests/functional/s/string/string_formatting_py3.py (1)

1-1: Normalize comma spacing in the disable list.

Current: # pylint: disable=missing-docstring,import-error, consider-using-f-string

For readability and consistency, align with other files by either removing the space after the second comma or adding a space after the first comma:

# pylint: disable=missing-docstring, import-error, consider-using-f-string
tests/functional/u/undefined/undefined_loop_variable.py (1)

1-1: Ensure consistent spacing in disables.

The line reads:

# pylint: disable=missing-docstring,redefined-builtin, consider-using-f-string

Consider uniform spacing after commas:

# pylint: disable=missing-docstring, redefined-builtin, consider-using-f-string
tests/functional/l/logging_format_interpolation.py (1)

2-2: Cleanup comma spacing in the disable directive.

Current directive:

# pylint: disable=invalid-name,missing-docstring,wrong-import-order,wrong-import-position, consider-using-f-string

For consistency, format with spaces after each comma:

# pylint: disable=invalid-name, missing-docstring, wrong-import-order, wrong-import-position, consider-using-f-string
tests/functional/n/new_style_class_py_30.py (1)

17-17: Use f-string for verbose open message.

The f-string correctly interpolates self.name and self.mode. Consider removing the double space after the period for consistency.

pylint/pyreverse/utils.py (1)

260-263: Raw string prefix not needed in f-string
The r in fr"Optional[{label}]" is unnecessary here—there are no escape sequences. Consider using f"Optional[{label}]" for clarity.

pylint/checkers/strings.py (2)

970-971: Simplify nested if statements.

Static analysis correctly identifies that these nested if statements can be combined for better readability.

Apply these diffs to combine the nested conditions:

 # Lines 970-971
-        if isinstance(inferred_value, nodes.Dict):
-            if len(inferred_value.items) > 1 and len(keyword_args) > 1:
-                return
+        if isinstance(inferred_value, nodes.Dict) and len(inferred_value.items) > 1 and len(keyword_args) > 1:
+            return

 # Lines 988-989  
-        if isinstance(inferred_right, nodes.List):
-            if len(inferred_right.elts) > 1:
-                return
+        if isinstance(inferred_right, nodes.List) and len(inferred_right.elts) > 1:
+            return

Also applies to: 988-989


936-998: Consider refactoring for better maintainability.

The method handles two distinct cases (.format() calls and % formatting) and is quite long. Consider splitting it into separate methods for better readability and maintainability.

def _detect_replacable_format_call(self, node: nodes.Const) -> None:
    """Check whether a string is used in a call to format() or '%' and whether it
    can be replaced by a f-string"""
    if isinstance(node.parent, nodes.Attribute) and node.parent.attrname == "format":
        self._check_format_method_call(node)
    elif isinstance(node.parent, nodes.BinOp) and node.parent.op == "%":
        self._check_percent_formatting(node)

def _check_format_method_call(self, node: nodes.Const) -> None:
    # Implementation for .format() calls
    
def _check_percent_formatting(self, node: nodes.Const) -> None:
    # Implementation for % formatting
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a19421 and 049bc9b.

📒 Files selected for processing (84)
  • ChangeLog (1 hunks)
  • doc/exts/pylint_extensions.py (1 hunks)
  • doc/whatsnew/2.11.rst (1 hunks)
  • pylint/checkers/__init__.py (1 hunks)
  • pylint/checkers/base.py (6 hunks)
  • pylint/checkers/base_checker.py (1 hunks)
  • pylint/checkers/classes.py (2 hunks)
  • pylint/checkers/exceptions.py (3 hunks)
  • pylint/checkers/imports.py (5 hunks)
  • pylint/checkers/misc.py (1 hunks)
  • pylint/checkers/raw_metrics.py (2 hunks)
  • pylint/checkers/refactoring/not_checker.py (1 hunks)
  • pylint/checkers/refactoring/refactoring_checker.py (1 hunks)
  • pylint/checkers/similar.py (2 hunks)
  • pylint/checkers/spelling.py (2 hunks)
  • pylint/checkers/strings.py (5 hunks)
  • pylint/checkers/typecheck.py (1 hunks)
  • pylint/checkers/variables.py (4 hunks)
  • pylint/config/__init__.py (1 hunks)
  • pylint/config/man_help_formatter.py (2 hunks)
  • pylint/config/option.py (2 hunks)
  • pylint/config/option_manager_mixin.py (1 hunks)
  • pylint/epylint.py (1 hunks)
  • pylint/extensions/_check_docs_utils.py (10 hunks)
  • pylint/extensions/broad_try_clause.py (1 hunks)
  • pylint/extensions/mccabe.py (3 hunks)
  • pylint/extensions/overlapping_exceptions.py (1 hunks)
  • pylint/graph.py (2 hunks)
  • pylint/lint/pylinter.py (4 hunks)
  • pylint/lint/report_functions.py (1 hunks)
  • pylint/lint/run.py (2 hunks)
  • pylint/lint/utils.py (1 hunks)
  • pylint/message/message_definition.py (1 hunks)
  • pylint/message/message_handler_mix_in.py (2 hunks)
  • pylint/pyreverse/diadefslib.py (1 hunks)
  • pylint/pyreverse/diagrams.py (2 hunks)
  • pylint/pyreverse/inspector.py (2 hunks)
  • pylint/pyreverse/utils.py (3 hunks)
  • pylint/pyreverse/vcg_printer.py (1 hunks)
  • pylint/reporters/base_reporter.py (1 hunks)
  • pylint/reporters/reports_handler_mix_in.py (1 hunks)
  • pylint/reporters/text.py (3 hunks)
  • pylint/reporters/ureports/nodes.py (1 hunks)
  • pylint/reporters/ureports/text_writer.py (1 hunks)
  • pylint/testutils/constants.py (2 hunks)
  • pylint/testutils/lint_module_test.py (4 hunks)
  • pylint/testutils/reporter_for_tests.py (1 hunks)
  • pylint/utils/utils.py (5 hunks)
  • script/bump_changelog.py (2 hunks)
  • tests/benchmark/test_baseline_benchmarks.py (10 hunks)
  • tests/checkers/unittest_python3.py (2 hunks)
  • tests/checkers/unittest_similar.py (11 hunks)
  • tests/functional/a/arguments.py (1 hunks)
  • tests/functional/c/consider/consider_using_f_string.py (1 hunks)
  • tests/functional/c/consider/consider_using_f_string.txt (1 hunks)
  • tests/functional/d/docstrings.py (1 hunks)
  • tests/functional/d/duplicate_string_formatting_argument.py (1 hunks)
  • tests/functional/l/logging_format_interpolation.py (1 hunks)
  • tests/functional/l/logging_not_lazy.py (1 hunks)
  • tests/functional/l/logging_not_lazy_with_logger.py (1 hunks)
  • tests/functional/l/logging_not_lazy_with_logger.txt (1 hunks)
  • tests/functional/m/misplaced_format_function.py (1 hunks)
  • tests/functional/n/new_style_class_py_30.py (2 hunks)
  • tests/functional/n/new_style_class_py_30.txt (1 hunks)
  • tests/functional/r/raise/raising_format_tuple.py (1 hunks)
  • tests/functional/r/renamed_import_logging_not_lazy.py (1 hunks)
  • tests/functional/s/slots_checks.py (1 hunks)
  • tests/functional/s/string/string_formatting.py (1 hunks)
  • tests/functional/s/string/string_formatting_error.py (1 hunks)
  • tests/functional/s/string/string_formatting_failed_inference.py (1 hunks)
  • tests/functional/s/string/string_formatting_failed_inference_py35.py (1 hunks)
  • tests/functional/s/string/string_formatting_py3.py (1 hunks)
  • tests/functional/t/too/too_many_return_statements.py (1 hunks)
  • tests/functional/u/undefined/undefined_loop_variable.py (1 hunks)
  • tests/functional/u/unused/unused_argument.py (1 hunks)
  • tests/functional/u/use/used_before_assignement.py (1 hunks)
  • tests/functional/u/use/used_before_assignment_issue853.py (1 hunks)
  • tests/input/func_w0401_package/thing2.py (1 hunks)
  • tests/profile/test_profile_against_externals.py (2 hunks)
  • tests/pyreverse/test_utils.py (1 hunks)
  • tests/test_check_parallel.py (2 hunks)
  • tests/test_epylint.py (2 hunks)
  • tests/test_func.py (2 hunks)
  • tests/test_self.py (6 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
tests/functional/d/docstrings.py

[error] 1-1: Unrecognized option found: files-output, no-space-check, function-name-hint, variable-name-hint, const-name-hint, attr-name-hint, argument-name-hint, class-attribute-name-hint, inlinevar-name-hint, class-name-hint, module-name-hint, method-name-hint

(E0015)


[refactor] 1-1: Useless option value for 'disable', 'no-self-use' was moved to an optional extension, see https://pylint.readthedocs.io/en/latest/whatsnew/2/2.14/summary.html#removed-checkers.

(R0022)

tests/functional/d/duplicate_string_formatting_argument.py

[error] 1-1: Unrecognized option found: files-output, no-space-check, function-name-hint, variable-name-hint, const-name-hint, attr-name-hint, argument-name-hint, class-attribute-name-hint, inlinevar-name-hint, class-name-hint, module-name-hint, method-name-hint

(E0015)

tests/functional/s/string/string_formatting_py3.py

[error] 1-1: Unrecognized option found: files-output, no-space-check, function-name-hint, variable-name-hint, const-name-hint, attr-name-hint, argument-name-hint, class-attribute-name-hint, inlinevar-name-hint, class-name-hint, module-name-hint, method-name-hint

(E0015)

tests/functional/r/renamed_import_logging_not_lazy.py

[error] 1-1: Unrecognized option found: files-output, no-space-check, function-name-hint, variable-name-hint, const-name-hint, attr-name-hint, argument-name-hint, class-attribute-name-hint, inlinevar-name-hint, class-name-hint, module-name-hint, method-name-hint

(E0015)

tests/functional/l/logging_not_lazy.py

[error] 1-1: Unrecognized option found: files-output, no-space-check, function-name-hint, variable-name-hint, const-name-hint, attr-name-hint, argument-name-hint, class-attribute-name-hint, inlinevar-name-hint, class-name-hint, module-name-hint, method-name-hint

(E0015)

tests/functional/u/undefined/undefined_loop_variable.py

[error] 1-1: Unrecognized option found: files-output, no-space-check, function-name-hint, variable-name-hint, const-name-hint, attr-name-hint, argument-name-hint, class-attribute-name-hint, inlinevar-name-hint, class-name-hint, module-name-hint, method-name-hint

(E0015)

tests/functional/s/string/string_formatting_error.py

[refactor] 2-2: Useless option value for 'disable', 'print-statement' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)

pylint/reporters/reports_handler_mix_in.py

[error] 54-54: Instance of 'ReportsHandlerMixIn' has no 'stats' member

(E1101)

tests/profile/test_profile_against_externals.py

[error] 51-51: Unexpected keyword argument 'do_exit' in constructor call

(E1123)

tests/functional/c/consider/consider_using_f_string.py

[error] 1-1: Unrecognized option found: files-output, no-space-check, function-name-hint, variable-name-hint, const-name-hint, attr-name-hint, argument-name-hint, class-attribute-name-hint, inlinevar-name-hint, class-name-hint, module-name-hint, method-name-hint

(E0015)

🪛 LanguageTool
tests/functional/c/consider/consider_using_f_string.txt

[misspelling] ~1-~1: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~2-~2: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~3-~3: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~4-~4: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~5-~5: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~6-~6: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~7-~7: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~8-~8: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~9-~9: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~10-~10: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~11-~11: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~12-~12: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~13-~13: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~14-~14: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~15-~15: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~16-~16: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~17-~17: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~18-~18: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~19-~19: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~20-~20: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~21-~21: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~22-~22: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~23-~23: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~24-~24: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~25-~25: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~26-~26: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~27-~27: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~28-~28: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~29-~29: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~30-~30: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH

(EN_A_VS_AN)

🪛 Ruff (0.11.9)
pylint/checkers/strings.py

970-971: Use a single if statement instead of nested if statements

(SIM102)


988-989: Use a single if statement instead of nested if statements

(SIM102)

tests/functional/c/consider/consider_using_f_string.py

27-27: Star-arg unpacking after a keyword argument is strongly discouraged

(B026)


55-55: Star-arg unpacking after a keyword argument is strongly discouraged

(B026)


76-76: Found useless expression. Either assign it to a variable or remove it.

(B018)


81-81: Local variable A is assigned to but never used

Remove assignment to unused variable A

(F841)


82-82: Local variable B is assigned to but never used

Remove assignment to unused variable B

(F841)


83-83: Local variable C is assigned to but never used

Remove assignment to unused variable C

(F841)


83-83: Star-arg unpacking after a keyword argument is strongly discouraged

(B026)


84-84: Local variable D is assigned to but never used

Remove assignment to unused variable D

(F841)


85-85: Local variable E is assigned to but never used

Remove assignment to unused variable E

(F841)


86-86: Local variable F is assigned to but never used

Remove assignment to unused variable F

(F841)


87-87: Local variable G is assigned to but never used

Remove assignment to unused variable G

(F841)


88-88: Local variable H is assigned to but never used

Remove assignment to unused variable H

(F841)


89-89: Ambiguous variable name: I

(E741)


89-89: Local variable I is assigned to but never used

Remove assignment to unused variable I

(F841)


90-90: Local variable J is assigned to but never used

Remove assignment to unused variable J

(F841)


91-91: Local variable K is assigned to but never used

Remove assignment to unused variable K

(F841)


92-92: Local variable L is assigned to but never used

Remove assignment to unused variable L

(F841)


93-93: Local variable M is assigned to but never used

Remove assignment to unused variable M

(F841)


94-94: Local variable N is assigned to but never used

Remove assignment to unused variable N

(F841)


98-98: Local variable a is assigned to but never used

Remove assignment to unused variable a

(F841)


99-99: Local variable b is assigned to but never used

Remove assignment to unused variable b

(F841)


100-100: Local variable c is assigned to but never used

Remove assignment to unused variable c

(F841)


101-101: Local variable d is assigned to but never used

Remove assignment to unused variable d

(F841)


102-102: Local variable e is assigned to but never used

Remove assignment to unused variable e

(F841)


103-103: Local variable f is assigned to but never used

Remove assignment to unused variable f

(F841)


104-104: Local variable g is assigned to but never used

Remove assignment to unused variable g

(F841)


105-105: Local variable h is assigned to but never used

Remove assignment to unused variable h

(F841)


106-106: Local variable i is assigned to but never used

Remove assignment to unused variable i

(F841)


107-107: Local variable j is assigned to but never used

Remove assignment to unused variable j

(F841)

🔇 Additional comments (163)
tests/functional/a/arguments.py (1)

2-2: Suppress new f-string checker appropriately.

The added consider-using-f-string disable ensures this test continues to pass despite legacy string formatting.

tests/functional/t/too/too_many_return_statements.py (1)

30-30: Legacy % formatting replaced with f-string.

Refactoring yields equivalent output and aligns with the new consider-using-f-string checker.

tests/profile/test_profile_against_externals.py (2)

21-21: Assertion message updated to f-string.

The refactored assertion uses an f-string for clarity without altering logic.


49-55: Print statements updated to f-strings.

Converted to f-strings for consistency; behavior remains unchanged.

pylint/config/__init__.py (1)

130-130: LGTM: Clean f-string conversion

The conversion from old-style % formatting to f-string is correct and improves readability while maintaining the same functionality.

script/bump_changelog.py (2)

21-21: LGTM: Proper f-string conversion

The conversion from .format() to f-string is correct and improves readability.


131-138: Good use of selective disabling

The pylint: disable-next=consider-using-f-string comments are appropriately used here since these are template strings that get formatted later with .format(), making f-strings unsuitable for this use case.

tests/test_func.py (2)

41-41: LGTM: Correct f-string conversion

The conversion from .format() to f-string maintains the same output while improving readability.


58-58: LGTM: Clean f-string usage in list comprehension

The f-string conversion improves readability while maintaining the same functionality.

pylint/pyreverse/inspector.py (2)

36-36: LGTM: Simple f-string conversion

The conversion from % formatting to f-string in the print statement is correct and improves readability.


285-285: LGTM: Proper f-string conversion for module path construction

The conversion correctly maintains the string interpolation logic while using modern f-string syntax.

pylint/graph.py (6)

57-57: LGTM: Correct f-string conversion

The conversion to f-string for the digraph declaration is correct and improves readability.


59-63: LGTM: Clean graph property formatting

The conversions to f-strings for graph properties (rankdir, ratio, size) are correct and consistent.


65-70: LGTM: Proper charset validation and formatting

The f-string conversions for charset validation and emission are correct. The assertion message and charset emit statement properly use f-string syntax.


155-155: LGTM: Correct edge emission formatting

The f-string conversion for edge emission maintains the proper DOT syntax while improving readability.


162-162: LGTM: Proper node emission formatting

The f-string conversion for node emission is correct and consistent with the edge emission style.


167-167: LGTM: Simple but effective conversion

The f-string conversion in normalize_node_id is straightforward and correct.

pylint/reporters/text.py (1)

150-150: LGTM! Clean f-string modernization.

The conversion from % formatting to f-strings improves readability while maintaining identical functionality. All string interpolations are correctly preserved.

Also applies to: 174-174, 229-229, 232-232

tests/functional/s/slots_checks.py (1)

28-28: LGTM! F-string modernization in generator expression.

The conversion from % formatting to f-string in the generator expression maintains the same functionality while improving readability.

tests/test_check_parallel.py (1)

33-35: LGTM! Thoughtful f-string modernization with selective disabling.

The conversions from % formatting to f-strings improve readability. The strategic use of pylint: disable-next=consider-using-f-string on line 422 shows good judgment in cases where the original formatting might be preferred for dictionary keys.

Also applies to: 301-301, 422-423

pylint/pyreverse/diagrams.py (1)

113-113: LGTM! Clean .format() to f-string conversion.

The conversions from .format() to f-strings improve readability while maintaining identical functionality. String construction logic is correctly preserved.

Also applies to: 243-243

tests/test_self.py (1)

237-237: LGTM! Excellent f-string modernization including raw f-strings.

The conversions from % formatting to f-strings improve readability while maintaining identical functionality. The conversion to fr prefix on line 237 correctly combines raw string and f-string syntax for the regex pattern.

Also applies to: 301-301, 487-487, 503-503, 513-513, 529-529

tests/functional/l/logging_not_lazy_with_logger.py (1)

2-2: Disable new f-string checker for legacy formatting
Suppresses consider-using-f-string in this test to avoid false positives on old-style formatting.

tests/functional/d/duplicate_string_formatting_argument.py (1)

1-1: Extend disable list to include f-string checker
Adding consider-using-f-string alongside existing disables is correct for this test.

tests/functional/d/docstrings.py (1)

1-1: Add f-string checker to disabled warnings
Including consider-using-f-string in the top disable comment aligns with the new checker integration.

tests/functional/s/string/string_formatting_failed_inference_py35.py (1)

2-2: Suppress f-string recommendation in inference test
Disabling consider-using-f-string here prevents noise in format-inference tests.

tests/functional/r/renamed_import_logging_not_lazy.py (1)

1-1: Include f-string checker in disable directive
Extending the disable list to cover consider-using-f-string is appropriate for this legacy test.

tests/functional/s/string/string_formatting_failed_inference.py (1)

2-2: Appropriate disable directive added

Adding consider-using-f-string to suppress the new checker in this test is correct.

tests/functional/l/logging_not_lazy.py (1)

1-1: Suppress f-string preference in logging tests

Extending the disable list to include consider-using-f-string here is correct to avoid noise in legacy-style logging tests.

tests/functional/u/use/used_before_assignement.py (1)

2-2: Suppress f-string preference in this test

Adding consider-using-f-string here correctly prevents warnings in a test targeting legacy behaviors.

tests/functional/s/string/string_formatting.py (1)

4-4: Suppress f-string preference in formatting tests

Adding consider-using-f-string to the disable list is appropriate to avoid noise in these format-focused tests.

doc/whatsnew/2.11.rst (1)

15-18: Docs update correctly reflects the new checker.

The new consider-using-f-string entry and the “Closes #3592” reference are clear and properly formatted in the release notes.

tests/functional/u/use/used_before_assignment_issue853.py (1)

1-1: Suppress new checker in test.

Adding consider-using-f-string to the disable list prevents unwanted warnings in this functional test. This matches the PR objective of updating tests to ignore the new checker.

tests/functional/r/raise/raising_format_tuple.py (1)

7-7: Update disable comment for new checker.

The consider-using-f-string directive is correctly added alongside existing disables to suppress f-string recommendations in this test.

tests/functional/l/logging_not_lazy_with_logger.txt (1)

2-4: Adjust expected line numbers.

The lazy-logging warning line numbers have been updated to reflect code shifts. This maintains test alignment with source changes.

tests/input/func_w0401_package/thing2.py (1)

7-7: Convert to f-string.

Replacing old-style % formatting with an f-string improves readability and consistency with the new checker. The expression correctly interpolates the variables.

pylint/epylint.py (2)

189-189: Use f-string for usage message.

The usage print statement is updated to an f-string, modernizing the code and improving readability.


193-193: Use f-string for missing-file error.

Replacing % formatting with an f-string for the error message is consistent and enhances clarity.

tests/pyreverse/test_utils.py (1)

69-69: Standardize raw f-string prefix ordering
The raw f-string prefix is switched from rf to fr to match the rest of the codebase's convention. Functionality remains unchanged.

pylint/reporters/base_reporter.py (1)

45-45: Replace legacy formatting with f-string
Using an f-string for appending report_id improves readability and aligns with the project's modern string formatting standards.

ChangeLog (1)

13-16: Ensure documentation in doc/whatsnew is updated

This ChangeLog entry correctly documents the new consider-using-f-string checker. Please confirm that the same entry has been added to doc/whatsnew/2.11.rst under the 2.11.0 release notes.

tests/functional/u/unused/unused_argument.py (1)

75-75: LGTM! Clean conversion to f-string.

The change from '%s X' % etype to f'{etype} X' is a correct modernization that improves readability while maintaining identical functionality.

tests/test_epylint.py (1)

23-24: Appropriate use of disable comments for test integrity.

The # pylint: disable-next=consider-using-f-string comments are correctly placed to suppress the new warning for these test cases, where the old-style formatting is intentionally preserved to test epylint functionality.

Also applies to: 41-42

pylint/testutils/reporter_for_tests.py (1)

35-35: Verify that removing the leading space doesn't affect test output.

The conversion from " :%s" % obj to f":{obj}" removes the space before the colon. This could change the formatting of test output messages.

#!/bin/bash
# Description: Check if GenericTestReporter output format is used in tests that might be sensitive to spacing changes
# Test: Search for test assertions that might depend on the specific spacing format

rg -A 3 -B 3 "GenericTestReporter\|handle_message" --type py tests/
pylint/extensions/broad_try_clause.py (1)

64-64: LGTM! Clean conversion to f-string in message construction.

The f-string formatting clearly interpolates the statement counts and improves readability while maintaining the same functionality as the previous .format() approach.

pylint/checkers/__init__.py (1)

68-69: LGTM! Correct conversion of precision formatting to f-strings.

The changes from "%.3f" % value to f"{value:.3f}" correctly preserve the 3 decimal place precision formatting while modernizing to f-string syntax.

tests/functional/n/new_style_class_py_30.txt (3)

2-2: Validate updated warning line for File.write.

The super-with-arguments warning is now reported at line 21:8. Please confirm this matches the write method’s updated position in new_style_class_py_30.py.


3-3: Validate updated warning line for File.writelines.

The super-with-arguments warning is now reported at line 26:8. Ensure this aligns with the writelines method’s new line number.


4-4: Validate updated warning line for File.close.

The super-with-arguments warning is now reported at line 33:8. Confirm this corresponds to the close method in the source.

tests/functional/n/new_style_class_py_30.py (1)

32-32: Use f-string for verbose close message.

The f-string cleanly formats the closing message without altering behavior.

pylint/pyreverse/vcg_printer.py (1)

230-230: Consistent raw f-string prefix ordering.

Switching from rf"..." to fr"..." preserves semantics and aligns with the codebase’s established convention for raw f-strings.

pylint/lint/report_functions.py (1)

68-68: Replace percent formatting with f-string.

The f-string f"{val:.2f}" faithfully replicates the original %.2f formatting, improving clarity.

pylint/reporters/reports_handler_mix_in.py (1)

54-54: Modernize report header to f-string.

The new f-string cleanly embeds the statement count without changing behavior.

pylint/pyreverse/diadefslib.py (1)

142-142: Use f-strings for diagram titles.
Replacing old‐style % formatting with f-strings improves readability without changing behavior.

Also applies to: 145-145

pylint/extensions/overlapping_exceptions.py (1)

69-69: Modernize exception message formatting with f-strings.
The new f-strings correctly interpolate the exception parts for clearer, more consistent messages.

Also applies to: 77-77

pylint/reporters/ureports/nodes.py (1)

53-53: Switch to f-strings for visitor method names.
Using f-strings here cleanly constructs the dynamic method names without altering logic.

Also applies to: 57-57

tests/checkers/unittest_python3.py (1)

503-503: Adopt f-strings in test node extraction.
These f-strings correctly build the code snippets for astroid.extract_node, aligning tests with the new formatting style.

Also applies to: 540-540

pylint/checkers/refactoring/not_checker.py (1)

78-79: Refactor suggestion string to f-string.
The f-string maintains the same suggestion text while eliminating the .format() call.

doc/exts/pylint_extensions.py (1)

40-40: LGTM: String formatting modernization

The conversion from % string formatting to f-string is correctly implemented and improves readability.

pylint/config/option_manager_mixin.py (1)

248-248: LGTM: String formatting modernization

The conversion to f-string correctly preserves the join operation and improves readability.

pylint/message/message_definition.py (4)

67-67: LGTM: String formatting modernization

The conversion from % string formatting to f-string is correctly implemented.


72-74: LGTM: String formatting modernization

The conversion from .format() method to f-string syntax is correctly implemented for both version restrictions.


77-80: LGTM: String formatting modernization

Both conditional string formatting conversions from % operator to f-string are correctly implemented.


86-86: LGTM: String formatting modernization

The conversion from % string formatting to f-string correctly handles multiple variables and preserves the formatting logic.

pylint/checkers/raw_metrics.py (2)

32-32: LGTM: String formatting modernization

The conversion from % string formatting to f-string is correctly implemented.


43-43: LGTM: String formatting modernization

The conversion from % string formatting to f-string correctly preserves the .2f format specifier for the percentage value.

pylint/checkers/refactoring/refactoring_checker.py (1)

1409-1409: LGTM: String formatting modernization

The conversion from .format() method to f-string correctly preserves all method calls and maintains the ternary operator suggestion format.

pylint/testutils/constants.py (2)

10-12: LGTM! Appropriate use of disable comment.

The parentheses and disable comment correctly suppress the f-string warning while maintaining the existing % formatting functionality.


25-27: LGTM! Disable comment appropriately applied.

The disable comment correctly suppresses the f-string warning for this regex pattern where % formatting is intentionally retained.

tests/benchmark/test_baseline_benchmarks.py (1)

134-134: LGTM! Consistent modernization to f-strings.

All assertion error messages have been correctly converted from % formatting to f-strings, maintaining functionality while improving readability and performance.

Also applies to: 156-156, 169-169, 187-187, 206-206, 225-225, 244-244, 269-269, 295-295, 312-312

pylint/config/option.py (3)

94-94: LGTM! Correct f-string conversion.

The exception message has been properly converted from % formatting to f-string syntax.


152-156: LGTM! Appropriate use of disable comment.

The disable comment correctly suppresses the f-string warning while intentionally retaining % formatting for this specific case.


159-159: LGTM! Correct f-string conversion.

The exception message has been properly converted to f-string syntax with correct variable interpolation.

pylint/lint/run.py (1)

353-353: LGTM! Correct f-string conversion.

The error message has been properly converted to f-string syntax with correct variable interpolation.

pylint/message/message_handler_mix_in.py (4)

258-259: LGTM! Correct f-string conversion.

The exception message has been properly converted to f-string syntax with correct variable interpolation.


262-264: LGTM! Correct f-string conversion.

The multi-line exception message has been properly converted to f-string syntax with correct variable interpolation.


269-269: LGTM! Correct f-string conversion.

The exception message has been properly converted to f-string syntax with correct variable interpolation.


373-373: LGTM! Correct f-string conversions.

Both documentation generation statements have been properly converted to f-string syntax while maintaining functionality.

Also applies to: 375-375

pylint/config/man_help_formatter.py (2)

19-19: Modernized format_heading with f-string
The change to return f".SH {heading.upper()}\n" correctly preserves behavior while improving readability.


57-60: Preserve legacy formatting via disable comment
Suppressing the new checker for this %-formatting is reasonable here, as converting the tuple-based date formatting to an f-string would be more verbose.

pylint/pyreverse/utils.py (3)

134-134: Use f-string for error message
Switching to print(f"Unknown filter mode {ex}", file=sys.stderr) is accurate and concise.


180-180: Use f-string for building visit method name
getattr(handler, f"visit_{kid}", …) correctly modernizes the formatting.


183-183: Use f-string for building leave method name
Replacing string concatenation with f"leave_{kid}" is consistent with the project style.

pylint/checkers/typecheck.py (1)

251-251: Use f-string in _missing_member_hint
Updating to f"one of {', '.join(names[:-1])} or {names[-1]}" is correct and improves readability.

tests/functional/c/consider/consider_using_f_string.txt (1)

1-31: Functional test definitions are accurate
The expected warnings for the consider-using-f-string checker are correctly specified.

pylint/extensions/mccabe.py (4)

53-53: Replace % formatting with f-string
bottom = f"{self._bottom_counter}" correctly modernizes the literal conversion without logic changes.


138-138: Replace % formatting with f-string in subgraph parser
Using f"{self._bottom_counter}" is consistent and preserves existing behavior.


184-184: Use f-string for node name in complexity report
node_name = f"'{node.name}'" improves clarity while keeping the same output.


186-186: Use f-string for class name fallback
node_name = f"This '{node.__class__.__name__.lower()}'" accurately replaces the old %-style string.

pylint/testutils/lint_module_test.py (3)

56-56: Excellent f-string modernization in setUp method.

The conversions from old-style string formatting to f-strings are clean and improve readability while maintaining the same functionality.

Also applies to: 65-65, 76-76


195-195: Good f-string conversion for error message construction.

The change from old-style formatting to f-string improves readability and consistency with the modernization effort.


201-207: Appropriate use of pylint disable comments.

The retention of % formatting with pylint: disable=consider-using-f-string comments is appropriate here, likely due to the specific context where these list comprehensions are used for message formatting.

pylint/checkers/misc.py (1)

113-113: Perfect raw f-string usage for regex pattern.

Using fr"#\s*({notes})\b" is the ideal way to construct regex patterns with variable interpolation, combining the benefits of f-strings with raw string literals.

pylint/checkers/spelling.py (3)

236-236: Clean f-string conversion for help text.

The conversion from old-style formatting to f-string improves readability and aligns with the modernization effort.


403-403: Good f-string usage for file writing.

Simple and clean conversion from .format() to f-string for writing words to the private dictionary file.


410-410: Excellent raw f-string for regex construction.

Using fr"(\W|^)({word})(\W|$)" is the proper way to build regex patterns with variable interpolation, maintaining raw string behavior for regex special characters.

pylint/checkers/exceptions.py (2)

274-276: Appropriate retention of old formatting with disable comment.

The pylint disable comment is correctly placed to suppress the new consider-using-f-string warning while maintaining the existing string formatting pattern.


491-491: Excellent f-string conversions for suggestion and error messages.

The conversions properly handle both simple variable interpolation and more complex expressions like ', '.join(operand.as_string() for _, operand in node.ops), improving code readability while maintaining functionality.

Also applies to: 498-498, 558-558

pylint/checkers/similar.py (2)

460-460: Excellent f-string conversion with formatting specifier.

The conversion from .format() to f-string properly maintains the floating-point precision formatting (:.2f) while improving readability and consistency.


675-675: Clean f-string conversion for string representation.

Simple and effective conversion from old-style formatting to f-string for the __str__ method.

pylint/checkers/base_checker.py (3)

73-84: LGTM! Excellent modernization of string formatting.

The conversion from % formatting to f-strings improves readability and aligns with the new consider-using-f-string checker being introduced. All conversions appear correct and maintain the same output format.


89-96: Clean f-string conversions in documentation generation.

The string formatting updates are consistent and maintain the same functionality while using modern Python syntax.


101-103: Appropriate handling of intentional legacy formatting.

The explicit pylint: disable=consider-using-f-string comment indicates this line was intentionally kept with % formatting, likely for specific compatibility requirements. This is a good example of how to handle cases where f-strings aren't suitable.

pylint/checkers/imports.py (6)

154-154: Good f-string conversion in tree representation.

The ternary expression with f-string formatting is clean and maintains the same logic.


161-163: Consistent f-string usage in tree indentation logic.

The string formatting conversions for sub-indentation are correct and improve readability.


742-744: Proper f-string conversion in error message formatting.

The error message for wrong import order now uses f-strings while maintaining the same informative output.


757-759: Clean f-string conversion for third party import errors.

The error message formatting is correctly updated to use f-strings.


772-774: Consistent f-string usage for first party import errors.

The conversion maintains the same error message format while using modern string formatting.


790-790: Appropriate f-string conversion for syntax error messages.

The error message formatting correctly uses f-strings while preserving the informative content.

pylint/lint/pylinter.py (4)

318-318: Good f-string conversion in help text.

The confidence levels help text now uses f-strings, which is more readable and consistent with the modernization effort.


632-632: Clean f-string conversion for deprecation warning.

The deprecation warning message correctly uses f-strings while maintaining the same functionality.


652-652: Appropriate f-string usage in error message.

The error message for config file issues is correctly updated to use f-strings.


1302-1308: Excellent f-string conversions in evaluation reporting.

The score evaluation messages are properly converted to f-strings, improving readability while maintaining the same informative output format. The conditional message addition logic remains unchanged.

tests/checkers/unittest_similar.py (8)

56-74: Correct test update for f-string formatted output.

The expected output string is properly updated to use f-strings for file paths, ensuring the test will pass with the modernized similar checker output.


85-108: Proper test assertion update for docstring ignore test.

The expected output correctly uses f-strings for file path formatting, matching the updated checker behavior.


133-147: Clean test update for multiline imports.

The expected output string correctly uses f-strings for file paths and maintains the same test logic.


172-198: Comprehensive test update for signature ignore functionality.

The expected output correctly uses f-strings throughout the multi-section similarity report, ensuring test accuracy with the modernized output format.


223-257: Proper test update for class method signature testing.

The expected output string is correctly updated to use f-strings for all file path references in the similarity report.


282-294: Correct test assertion for empty function signatures.

The expected output properly uses f-strings for file path formatting, maintaining test correctness.


327-338: Clean test update for basic similarity detection.

The expected output correctly uses f-strings for file paths in the similarity report.


350-370: Appropriate test update for meaningful content detection.

The expected output string correctly uses f-strings for file path formatting while maintaining the same test validation logic.

pylint/checkers/variables.py (5)

188-191: Convert unpacking info messages to f-strings
Modernized the extra info concatenation using f-strings without changing semantics.


1714-1714: Convert import message to f-string
Updated the unused-import message construction to use an f-string for consistency.


1721-1721: Convert import-from message to f-string
Modernized the unused-import-from message construction with an f-string.


2106-2106: Convert unused-import placeholder to f-string
Updated the import placeholder formatting to an f-string for clarity.


2131-2131: Convert import-from placeholder to f-string
Modernized the import-from message formatting to use an f-string.

pylint/utils/utils.py (8)

49-51: Use f-string in diff_string
Modernized the difference string construction with an f-string, preserving the original behavior.


82-84: Use f-string for formatted-doc output
Replaced concatenation with an f-string to insert the wrapped doc section followed by two newlines.


86-90: Use f-strings for option section markers
Updated both the section header and help formatting to f-strings for improved readability.


91-93: Use f-string for default value formatting
Modernized the default-value line to an f-string, keeping existing escape logic intact.


242-244: Use f-strings in comment helper
Simplified comment concatenation in _comment by switching to an f-string.


259-261: Use f-string for quoting whitespace value
Converted the whitespace-quoting logic to an f-string for clarity.


267-268: Wrap doc output using _comment helper
Moved doc-string printing into _comment helper for consistent formatting.


283-285: Use f-string for INI option placeholder
Updated the placeholder print to an f-string, improving readability.

pylint/extensions/_check_docs_utils.py (14)

250-253: LGTM! Clean f-string conversion for regex pattern.

The conversion from .format() to f-string raw literal is correct and maintains the same regex logic while improving readability.


262-265: LGTM! Proper f-string raw literal usage.

The f-string conversion correctly embeds the re_type variable directly into the regex pattern.


267-284: LGTM! Complex regex pattern successfully modernized.

The multi-line regex pattern conversion to f-string maintains all the original formatting and logic while improving string interpolation clarity.


287-293: LGTM! Consistent f-string conversion.

The regex pattern correctly uses f-string interpolation for the re_multiple_simple_type variable.


296-300: LGTM! Property type regex modernized correctly.

The f-string conversion maintains the proper regex structure for property type matching.


303-313: LGTM! Exception raise regex pattern updated properly.

The conversion to f-string raw literal correctly interpolates the re_multiple_simple_type variable while preserving the regex logic.


445-448: LGTM! GoogleDocstring regex pattern modernized.

The f-string conversion correctly combines re_type and re_xref variables in the container type regex pattern.


473-480: LGTM! Parameter line regex updated correctly.

The complex multi-line regex pattern successfully converted to f-string while maintaining proper variable interpolation for re_multiple_type.


489-492: LGTM! Raise line regex modernized properly.

The f-string conversion correctly embeds the re_multiple_type variable in the regex pattern.


501-504: LGTM! Returns line regex updated correctly.

The f-string raw literal properly interpolates the re_multiple_type variable while maintaining the regex structure.


509-512: LGTM! Property returns regex modernized correctly.

The f-string conversion maintains the proper regex logic for property return type matching.


724-730: LGTM! NumpyDocstring parameter regex updated properly.

The complex parameter line regex successfully converted to f-string with correct interpolation of GoogleDocstring.re_multiple_type.


739-742: LGTM! NumpyDocstring raise regex modernized.

The f-string conversion correctly references GoogleDocstring.re_type while maintaining the regex structure.


751-755: LGTM! NumpyDocstring returns regex updated correctly.

The f-string raw literal properly interpolates GoogleDocstring.re_multiple_type while preserving the regex logic.

pylint/checkers/classes.py (2)

2042-2042: LGTM! Clean f-string conversion for error message.

The message string is correctly modernized from .format() to f-string, improving readability while maintaining the same functionality.


2192-2193: LGTM! Appropriate pylint disable for legacy formatting.

The disable comment is correctly placed to suppress the new consider-using-f-string warning for the % formatting line that wasn't suitable for conversion. This aligns with the PR's approach of adding ignores where f-string conversion wasn't appropriate.

pylint/checkers/base.py (8)

196-196: Use f-string for default argument symbol values
Replaces manual string formatting with f"{x}()" in the mapping comprehension for consistency.


407-407: Format documented percentage with f-string
Replaces older formatting with f"{percent:.2f}" for clarity and uniformity.


412-412: Format badname percentage with f-string
Replaces older formatting with f"{percent:.2f}" to match the documented percentage style.


1706-1706: Use f-string in naming-style help text
Dynamically injects human_readable_name into the help description using an f-string.


1717-1717: Use f-string in naming-regex help text
Embeds human_readable_name and the option name via f-strings for clearer, self-updating help messages.


1889-1889: Use f-string for custom regex hint
Embeds the custom_regex.pattern representation in the hint using an f-string.


1891-1891: Use f-string for default naming style hint
Replaces static text with an f-string to include the naming_style_name dynamically.


2024-2024: Append naming pattern hint using f-string
Adds a dynamic pattern snippet via f" ({...!r} pattern)" when include_naming_hint is enabled.

pylint/checkers/strings.py (4)

83-85: LGTM! Good modernization with f-strings.

These regex pattern updates demonstrate the exact kind of improvement the new checker promotes - replacing .format() calls with more readable f-strings.


676-681: LGTM! Clear and well-documented message definition.

The new "consider-using-f-string" message is well-documented and follows the established pattern for Pylint message definitions.


919-920: LGTM! Clean integration of the new checker.

The integration follows the established pattern and appropriately calls the new detection method from visit_const.

Also applies to: 925-925


1063-1063: LGTM! Consistent f-string usage.

Another good example of modernizing string formatting with f-strings.

tests/functional/c/consider/consider_using_f_string.py (1)

1-108: Excellent comprehensive test coverage.

This test file provides thorough coverage of the new consider-using-f-string checker with well-organized test cases:

  • Good structure: Clear separation between scenarios that should and shouldn't trigger warnings
  • Comprehensive scenarios: Covers various formatting methods, argument types, and contexts
  • Clear expectations: Expected warnings are clearly marked with comments
  • Appropriate test data: Constants and collections provide realistic test scenarios

The static analysis warnings about unused variables and expressions are expected and appropriate for a functional test file.

Comment thread pylint/lint/utils.py
Comment on lines +99 to 105
msg = f"Option {option} expects a value"
raise ArgumentPreprocessingError(msg)
val = args[i]
del args[i]
elif not takearg and val is not None:
msg = "Option %s doesn't expects a value" % option
msg = f"Option {option} doesn't expects a value"
raise ArgumentPreprocessingError(msg)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix grammar in error message.

The phrase "doesn't expects a value" is incorrect. It should read "doesn't expect a value".
Apply this diff:

-                    msg = f"Option {option} doesn't expects a value"
+                    msg = f"Option {option} doesn't expect a value"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
msg = f"Option {option} expects a value"
raise ArgumentPreprocessingError(msg)
val = args[i]
del args[i]
elif not takearg and val is not None:
msg = "Option %s doesn't expects a value" % option
msg = f"Option {option} doesn't expects a value"
raise ArgumentPreprocessingError(msg)
msg = f"Option {option} expects a value"
raise ArgumentPreprocessingError(msg)
val = args[i]
del args[i]
elif not takearg and val is not None:
msg = f"Option {option} doesn't expect a value"
raise ArgumentPreprocessingError(msg)
🤖 Prompt for AI Agents
In pylint/lint/utils.py around lines 99 to 105, the error message "Option
{option} doesn't expects a value" contains a grammatical error. Change "doesn't
expects" to "doesn't expect" to correct the grammar in the raised
ArgumentPreprocessingError message.

@@ -1,5 +1,5 @@
"""test string format error"""
# pylint: disable=print-statement,unsupported-binary-operation,line-too-long
# pylint: disable=print-statement,unsupported-binary-operation,line-too-long, consider-using-f-string

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove deprecated 'print-statement' disable

The print-statement option was removed in newer Pylint versions (R0022). Drop it to avoid an unrecognized disable warning:

-# pylint: disable=print-statement,unsupported-binary-operation,line-too-long, consider-using-f-string
+# pylint: disable=unsupported-binary-operation,line-too-long,consider-using-f-string
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# pylint: disable=print-statement,unsupported-binary-operation,line-too-long, consider-using-f-string
# pylint: disable=unsupported-binary-operation,line-too-long,consider-using-f-string
🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 2-2: Useless option value for 'disable', 'print-statement' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)

🤖 Prompt for AI Agents
In tests/functional/s/string/string_formatting_error.py at line 2, remove the
deprecated 'print-statement' disable from the pylint directive to prevent
unrecognized disable warnings in newer Pylint versions.

Comment thread pylint/lint/run.py
def cb_list_confidence_levels(option, optname, value, parser):
for level in interfaces.CONFIDENCE_LEVELS:
print("%-18s: %s" % level)
print(f"%-18s: {level}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the f-string conversion - missing format value.

The conversion is incorrect. The %-18s format specifier expects a value but none is provided in the f-string.

Apply this fix:

-        print(f"%-18s: {level}")
+        print(f"{level:<18}: {level}")

Or if you want to maintain the original formatting approach:

-        print(f"%-18s: {level}")
+        print("%-18s: %s" % (level, level))
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
print(f"%-18s: {level}")
print(f"{level:<18}: {level}")
🤖 Prompt for AI Agents
In pylint/lint/run.py at line 43, the f-string uses a format specifier %-18s but
does not provide a value to format, causing an error. Fix this by either
removing the f-string and using the old-style formatting with the % operator and
supplying the value, or by converting the entire print statement to a proper
f-string with the value inside the braces. Ensure the format specifier has a
corresponding value to format.

Comment on lines +967 to +973
keyword = utils.safe_infer(keyword.value)

# If lists of more than one element are being unpacked
if isinstance(keyword, nodes.Dict):
if len(keyword.items) > 1 and len(keyword_args) > 1:
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix variable name confusion and clarify logic.

The variable keyword is reassigned on line 967, making the subsequent check confusing. The original keyword object from the loop is overwritten with the inferred value, which makes the code harder to understand.

Apply this diff to fix the variable naming issue:

-        keyword = utils.safe_infer(keyword.value)
+        inferred_value = utils.safe_infer(keyword.value)

         # If lists of more than one element are being unpacked
-        if isinstance(keyword, nodes.Dict):
-            if len(keyword.items) > 1 and len(keyword_args) > 1:
+        if isinstance(inferred_value, nodes.Dict):
+            if len(inferred_value.items) > 1 and len(keyword_args) > 1:
                 return
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
keyword = utils.safe_infer(keyword.value)
# If lists of more than one element are being unpacked
if isinstance(keyword, nodes.Dict):
if len(keyword.items) > 1 and len(keyword_args) > 1:
return
inferred_value = utils.safe_infer(keyword.value)
# If lists of more than one element are being unpacked
if isinstance(inferred_value, nodes.Dict):
if len(inferred_value.items) > 1 and len(keyword_args) > 1:
return
🧰 Tools
🪛 Ruff (0.11.9)

970-971: Use a single if statement instead of nested if statements

(SIM102)

🤖 Prompt for AI Agents
In pylint/checkers/strings.py around lines 967 to 973, the variable 'keyword' is
reassigned to the inferred value, causing confusion with the original 'keyword'
from the loop. To fix this, use a different variable name for the inferred value
(e.g., 'inferred_keyword') instead of overwriting 'keyword'. Update subsequent
references accordingly to maintain clarity and avoid variable name confusion.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (4)
pylint/lint/utils.py (1)

104-104: Fix grammar in error message.

The phrase "doesn't expects a value" is incorrect. It should read "doesn't expect a value".

Apply this diff:

-                    msg = f"Option {option} doesn't expects a value"
+                    msg = f"Option {option} doesn't expect a value"
pylint/lint/run.py (1)

43-43: Fix the malformed f-string conversion.

The f-string conversion is incorrect. The %-18s format specifier expects a value but none is provided.

Apply this fix:

-        print(f"%-18s: {level}")
+        print(f"{level:<18}: {level}")

This uses f-string left-alignment formatting to achieve the same 18-character padding as the original %-18s specifier.

tests/functional/s/string/string_formatting_error.py (1)

2-2: Address the unresolved deprecation issue from previous review.

While adding consider-using-f-string to the disable comment is appropriate for this functional test, the previous review comment about removing the deprecated print-statement disable option remains unaddressed.

Apply this fix to remove the deprecated option:

-# pylint: disable=print-statement,unsupported-binary-operation,line-too-long, consider-using-f-string
+# pylint: disable=unsupported-binary-operation,line-too-long,consider-using-f-string
pylint/checkers/strings.py (1)

967-973: Fix variable name confusion and clarify logic.

The variable keyword is reassigned on line 967, making the subsequent check confusing. The original keyword object from the loop is overwritten with the inferred value, which makes the code harder to understand.

Apply this diff to fix the variable naming issue:

-                    keyword = utils.safe_infer(keyword.value)
+                    inferred_value = utils.safe_infer(keyword.value)

                     # If lists of more than one element are being unpacked
-                    if isinstance(keyword, nodes.Dict):
-                        if len(keyword.items) > 1 and len(keyword_args) > 1:
+                    if isinstance(inferred_value, nodes.Dict):
+                        if len(inferred_value.items) > 1 and len(keyword_args) > 1:
                             return
🧹 Nitpick comments (3)
tests/functional/c/consider/consider_using_f_string.txt (1)

1-30: Test file structure looks appropriate

This functional test file correctly captures the expected output for the new consider-using-f-string checker with consistent message formatting across different line ranges.

However, note that the message text contains a grammatical error: "a f-string" should be "an f-string" (since "f" starts with a vowel sound). If this is intentional for testing purposes, it's fine, but if not, the grammar should be corrected in the source checker message definition rather than in this test file.

pylint/checkers/classes.py (1)

2192-2193: Suppress f-string suggestion for dynamic message
Disabling the consider-using-f-string checker here is acceptable given the dynamic tuple formatting, but you could refactor this to an f-string (e.g. f"between {expected_params[0]} or {expected_params[1]}") and remove the disable directive.

pylint/checkers/strings.py (1)

970-972: Simplify nested if statements.

The nested if statements can be combined for better readability.

Apply this diff to simplify the code:

-                    if isinstance(keyword, nodes.Dict):
-                        if len(keyword.items) > 1 and len(keyword_args) > 1:
-                            return
+                    if isinstance(keyword, nodes.Dict) and len(keyword.items) > 1 and len(keyword_args) > 1:
+                        return

And similarly for the second occurrence:

-            if isinstance(inferred_right, nodes.Dict):
-                if len(inferred_right.items) > 1:
-                    return
+            if isinstance(inferred_right, nodes.Dict) and len(inferred_right.items) > 1:
+                return

Also applies to: 988-990

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a19421 and 049bc9b.

📒 Files selected for processing (84)
  • ChangeLog (1 hunks)
  • doc/exts/pylint_extensions.py (1 hunks)
  • doc/whatsnew/2.11.rst (1 hunks)
  • pylint/checkers/__init__.py (1 hunks)
  • pylint/checkers/base.py (6 hunks)
  • pylint/checkers/base_checker.py (1 hunks)
  • pylint/checkers/classes.py (2 hunks)
  • pylint/checkers/exceptions.py (3 hunks)
  • pylint/checkers/imports.py (5 hunks)
  • pylint/checkers/misc.py (1 hunks)
  • pylint/checkers/raw_metrics.py (2 hunks)
  • pylint/checkers/refactoring/not_checker.py (1 hunks)
  • pylint/checkers/refactoring/refactoring_checker.py (1 hunks)
  • pylint/checkers/similar.py (2 hunks)
  • pylint/checkers/spelling.py (2 hunks)
  • pylint/checkers/strings.py (5 hunks)
  • pylint/checkers/typecheck.py (1 hunks)
  • pylint/checkers/variables.py (4 hunks)
  • pylint/config/__init__.py (1 hunks)
  • pylint/config/man_help_formatter.py (2 hunks)
  • pylint/config/option.py (2 hunks)
  • pylint/config/option_manager_mixin.py (1 hunks)
  • pylint/epylint.py (1 hunks)
  • pylint/extensions/_check_docs_utils.py (10 hunks)
  • pylint/extensions/broad_try_clause.py (1 hunks)
  • pylint/extensions/mccabe.py (3 hunks)
  • pylint/extensions/overlapping_exceptions.py (1 hunks)
  • pylint/graph.py (2 hunks)
  • pylint/lint/pylinter.py (4 hunks)
  • pylint/lint/report_functions.py (1 hunks)
  • pylint/lint/run.py (2 hunks)
  • pylint/lint/utils.py (1 hunks)
  • pylint/message/message_definition.py (1 hunks)
  • pylint/message/message_handler_mix_in.py (2 hunks)
  • pylint/pyreverse/diadefslib.py (1 hunks)
  • pylint/pyreverse/diagrams.py (2 hunks)
  • pylint/pyreverse/inspector.py (2 hunks)
  • pylint/pyreverse/utils.py (3 hunks)
  • pylint/pyreverse/vcg_printer.py (1 hunks)
  • pylint/reporters/base_reporter.py (1 hunks)
  • pylint/reporters/reports_handler_mix_in.py (1 hunks)
  • pylint/reporters/text.py (3 hunks)
  • pylint/reporters/ureports/nodes.py (1 hunks)
  • pylint/reporters/ureports/text_writer.py (1 hunks)
  • pylint/testutils/constants.py (2 hunks)
  • pylint/testutils/lint_module_test.py (4 hunks)
  • pylint/testutils/reporter_for_tests.py (1 hunks)
  • pylint/utils/utils.py (5 hunks)
  • script/bump_changelog.py (2 hunks)
  • tests/benchmark/test_baseline_benchmarks.py (10 hunks)
  • tests/checkers/unittest_python3.py (2 hunks)
  • tests/checkers/unittest_similar.py (11 hunks)
  • tests/functional/a/arguments.py (1 hunks)
  • tests/functional/c/consider/consider_using_f_string.py (1 hunks)
  • tests/functional/c/consider/consider_using_f_string.txt (1 hunks)
  • tests/functional/d/docstrings.py (1 hunks)
  • tests/functional/d/duplicate_string_formatting_argument.py (1 hunks)
  • tests/functional/l/logging_format_interpolation.py (1 hunks)
  • tests/functional/l/logging_not_lazy.py (1 hunks)
  • tests/functional/l/logging_not_lazy_with_logger.py (1 hunks)
  • tests/functional/l/logging_not_lazy_with_logger.txt (1 hunks)
  • tests/functional/m/misplaced_format_function.py (1 hunks)
  • tests/functional/n/new_style_class_py_30.py (2 hunks)
  • tests/functional/n/new_style_class_py_30.txt (1 hunks)
  • tests/functional/r/raise/raising_format_tuple.py (1 hunks)
  • tests/functional/r/renamed_import_logging_not_lazy.py (1 hunks)
  • tests/functional/s/slots_checks.py (1 hunks)
  • tests/functional/s/string/string_formatting.py (1 hunks)
  • tests/functional/s/string/string_formatting_error.py (1 hunks)
  • tests/functional/s/string/string_formatting_failed_inference.py (1 hunks)
  • tests/functional/s/string/string_formatting_failed_inference_py35.py (1 hunks)
  • tests/functional/s/string/string_formatting_py3.py (1 hunks)
  • tests/functional/t/too/too_many_return_statements.py (1 hunks)
  • tests/functional/u/undefined/undefined_loop_variable.py (1 hunks)
  • tests/functional/u/unused/unused_argument.py (1 hunks)
  • tests/functional/u/use/used_before_assignement.py (1 hunks)
  • tests/functional/u/use/used_before_assignment_issue853.py (1 hunks)
  • tests/input/func_w0401_package/thing2.py (1 hunks)
  • tests/profile/test_profile_against_externals.py (2 hunks)
  • tests/pyreverse/test_utils.py (1 hunks)
  • tests/test_check_parallel.py (2 hunks)
  • tests/test_epylint.py (2 hunks)
  • tests/test_func.py (2 hunks)
  • tests/test_self.py (6 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
tests/functional/d/duplicate_string_formatting_argument.py

[error] 1-1: Unrecognized option found: files-output, no-space-check, function-name-hint, variable-name-hint, const-name-hint, attr-name-hint, argument-name-hint, class-attribute-name-hint, inlinevar-name-hint, class-name-hint, module-name-hint, method-name-hint

(E0015)

tests/functional/r/renamed_import_logging_not_lazy.py

[error] 1-1: Unrecognized option found: files-output, no-space-check, function-name-hint, variable-name-hint, const-name-hint, attr-name-hint, argument-name-hint, class-attribute-name-hint, inlinevar-name-hint, class-name-hint, module-name-hint, method-name-hint

(E0015)

tests/functional/u/undefined/undefined_loop_variable.py

[error] 1-1: Unrecognized option found: files-output, no-space-check, function-name-hint, variable-name-hint, const-name-hint, attr-name-hint, argument-name-hint, class-attribute-name-hint, inlinevar-name-hint, class-name-hint, module-name-hint, method-name-hint

(E0015)

tests/functional/l/logging_not_lazy.py

[error] 1-1: Unrecognized option found: files-output, no-space-check, function-name-hint, variable-name-hint, const-name-hint, attr-name-hint, argument-name-hint, class-attribute-name-hint, inlinevar-name-hint, class-name-hint, module-name-hint, method-name-hint

(E0015)

tests/functional/s/string/string_formatting_error.py

[refactor] 2-2: Useless option value for 'disable', 'print-statement' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)

tests/functional/d/docstrings.py

[error] 1-1: Unrecognized option found: files-output, no-space-check, function-name-hint, variable-name-hint, const-name-hint, attr-name-hint, argument-name-hint, class-attribute-name-hint, inlinevar-name-hint, class-name-hint, module-name-hint, method-name-hint

(E0015)


[refactor] 1-1: Useless option value for 'disable', 'no-self-use' was moved to an optional extension, see https://pylint.readthedocs.io/en/latest/whatsnew/2/2.14/summary.html#removed-checkers.

(R0022)

tests/functional/s/string/string_formatting_py3.py

[error] 1-1: Unrecognized option found: files-output, no-space-check, function-name-hint, variable-name-hint, const-name-hint, attr-name-hint, argument-name-hint, class-attribute-name-hint, inlinevar-name-hint, class-name-hint, module-name-hint, method-name-hint

(E0015)

pylint/reporters/reports_handler_mix_in.py

[error] 54-54: Instance of 'ReportsHandlerMixIn' has no 'stats' member

(E1101)

tests/profile/test_profile_against_externals.py

[error] 51-51: Unexpected keyword argument 'do_exit' in constructor call

(E1123)

tests/functional/c/consider/consider_using_f_string.py

[error] 1-1: Unrecognized option found: files-output, no-space-check, function-name-hint, variable-name-hint, const-name-hint, attr-name-hint, argument-name-hint, class-attribute-name-hint, inlinevar-name-hint, class-name-hint, module-name-hint, method-name-hint

(E0015)

🪛 LanguageTool
tests/functional/c/consider/consider_using_f_string.txt

[misspelling] ~1-~1: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~2-~2: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~3-~3: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~4-~4: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~5-~5: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~6-~6: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~7-~7: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~8-~8: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~9-~9: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~10-~10: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~11-~11: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~12-~12: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~13-~13: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~14-~14: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~15-~15: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~16-~16: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~17-~17: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~18-~18: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~19-~19: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~20-~20: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~21-~21: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~22-~22: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~23-~23: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~24-~24: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~25-~25: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~26-~26: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~27-~27: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~28-~28: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~29-~29: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH consider-using-f-string:...

(EN_A_VS_AN)


[misspelling] ~30-~30: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...matting a regular string which could be a f-string":HIGH

(EN_A_VS_AN)

🪛 Ruff (0.11.9)
tests/functional/c/consider/consider_using_f_string.py

27-27: Star-arg unpacking after a keyword argument is strongly discouraged

(B026)


55-55: Star-arg unpacking after a keyword argument is strongly discouraged

(B026)


76-76: Found useless expression. Either assign it to a variable or remove it.

(B018)


81-81: Local variable A is assigned to but never used

Remove assignment to unused variable A

(F841)


82-82: Local variable B is assigned to but never used

Remove assignment to unused variable B

(F841)


83-83: Local variable C is assigned to but never used

Remove assignment to unused variable C

(F841)


83-83: Star-arg unpacking after a keyword argument is strongly discouraged

(B026)


84-84: Local variable D is assigned to but never used

Remove assignment to unused variable D

(F841)


85-85: Local variable E is assigned to but never used

Remove assignment to unused variable E

(F841)


86-86: Local variable F is assigned to but never used

Remove assignment to unused variable F

(F841)


87-87: Local variable G is assigned to but never used

Remove assignment to unused variable G

(F841)


88-88: Local variable H is assigned to but never used

Remove assignment to unused variable H

(F841)


89-89: Ambiguous variable name: I

(E741)


89-89: Local variable I is assigned to but never used

Remove assignment to unused variable I

(F841)


90-90: Local variable J is assigned to but never used

Remove assignment to unused variable J

(F841)


91-91: Local variable K is assigned to but never used

Remove assignment to unused variable K

(F841)


92-92: Local variable L is assigned to but never used

Remove assignment to unused variable L

(F841)


93-93: Local variable M is assigned to but never used

Remove assignment to unused variable M

(F841)


94-94: Local variable N is assigned to but never used

Remove assignment to unused variable N

(F841)


98-98: Local variable a is assigned to but never used

Remove assignment to unused variable a

(F841)


99-99: Local variable b is assigned to but never used

Remove assignment to unused variable b

(F841)


100-100: Local variable c is assigned to but never used

Remove assignment to unused variable c

(F841)


101-101: Local variable d is assigned to but never used

Remove assignment to unused variable d

(F841)


102-102: Local variable e is assigned to but never used

Remove assignment to unused variable e

(F841)


103-103: Local variable f is assigned to but never used

Remove assignment to unused variable f

(F841)


104-104: Local variable g is assigned to but never used

Remove assignment to unused variable g

(F841)


105-105: Local variable h is assigned to but never used

Remove assignment to unused variable h

(F841)


106-106: Local variable i is assigned to but never used

Remove assignment to unused variable i

(F841)


107-107: Local variable j is assigned to but never used

Remove assignment to unused variable j

(F841)

pylint/checkers/strings.py

970-971: Use a single if statement instead of nested if statements

(SIM102)


988-989: Use a single if statement instead of nested if statements

(SIM102)

🔇 Additional comments (171)
tests/functional/a/arguments.py (1)

2-2: LGTM! Appropriate disable directive addition.

The addition of consider-using-f-string to the disable list is correct and necessary to prevent the new checker from flagging this test file, which focuses on testing function arguments rather than string formatting.

pylint/epylint.py (2)

189-189: LGTM! Clean modernization to f-string.

The conversion from % formatting to f-string is correctly implemented and improves readability.


192-192: LGTM! Consistent f-string usage.

The string formatting modernization is correct and maintains the same functionality while improving code consistency.

pylint/reporters/base_reporter.py (1)

45-45: LGTM! Proper f-string conversion.

The modernization from % formatting to f-string is correctly implemented and maintains the same functionality.

tests/functional/r/raise/raising_format_tuple.py (1)

7-7: LGTM! Necessary disable directive for test consistency.

The addition of consider-using-f-string to the disable list is appropriate since this test file intentionally uses various string formatting methods that should not be converted to f-strings for testing purposes.

pylint/pyreverse/vcg_printer.py (1)

230-230: LGTM! Conventional raw f-string prefix ordering.

The change from rf"..." to fr"..." is syntactically equivalent and follows the conventional ordering where the f-string prefix comes last.

tests/test_epylint.py (1)

23-23: LGTM! Appropriate use of disable comments for test preservation.

The # pylint: disable-next=consider-using-f-string comments are correctly placed to suppress the new checker for test cases that need to preserve old-style string formatting for testing purposes.

Also applies to: 41-41

tests/functional/n/new_style_class_py_30.py (1)

17-17: LGTM! Clean conversion to f-strings.

The string formatting conversions from % operator to f-strings are correct and improve readability while maintaining the same functionality.

Also applies to: 32-32

pylint/reporters/reports_handler_mix_in.py (1)

54-54: F-string conversion is correct, but verify self.stats access.

The conversion to f-string syntax is correct. However, the static analysis hint about self.stats not being a member might be valid - this mixin class doesn't initialize self.stats in its __init__ method, yet accesses it here.

Please verify that self.stats is properly initialized by classes that use this mixin:

#!/bin/bash
# Search for classes that inherit from ReportsHandlerMixIn and check if they initialize self.stats
ast-grep --pattern $'class $_ ($_): 
  $$$
' | grep -A 10 -B 2 "ReportsHandlerMixIn"

# Also search for where self.stats is defined
rg -A 3 "self\.stats\s*=" 
tests/profile/test_profile_against_externals.py (1)

21-21: LGTM! All f-string conversions are correct.

The string formatting conversions from % operator to f-strings are syntactically correct and maintain the same functionality:

  • Simple variable interpolation at line 21
  • Function call interpolation at line 49
  • Multiple expressions interpolation at line 54

All conversions improve readability while preserving the original behavior.

Also applies to: 49-49, 54-54

pylint/checkers/raw_metrics.py (1)

32-32: LGTM! Correct f-string conversions with proper formatting.

Both string formatting conversions are correct:

  • Line 32: Clean conversion of simple variable interpolation
  • Line 43: Proper conversion of numeric formatting with precision specifier (%.2ff"{percent:.2f}")

The conversions maintain the exact same formatting behavior while using modern f-string syntax.

Also applies to: 43-43

tests/functional/n/new_style_class_py_30.txt (1)

2-4: LGTM: Correct line number adjustments.

The line number updates correctly reflect the changes made to the corresponding source file where print statements were modernized to use f-string formatting.

pylint/lint/utils.py (1)

99-99: LGTM: Correct f-string conversion.

The string formatting conversion is correct and improves readability.

pylint/reporters/ureports/nodes.py (2)

53-53: LGTM: Correct f-string conversion.

The modernization from % formatting to f-string improves readability while maintaining the same functionality for dynamic method name construction.


57-57: LGTM: Correct f-string conversion.

The modernization from % formatting to f-string improves readability while maintaining the same functionality for dynamic method name construction.

pylint/config/__init__.py (1)

130-130: LGTM: Correct f-string conversion.

The modernization from % formatting to f-string improves readability while maintaining the same error message functionality.

pylint/config/option_manager_mixin.py (1)

248-248: LGTM: Correct f-string conversion.

The modernization from % formatting to f-string improves readability while correctly maintaining the dynamic help message generation logic.

pylint/graph.py (4)

57-70: LGTM! Clean f-string conversions in DotBackend constructor.

All string formatting updates in the constructor are correctly converted from old-style formatting to f-strings while preserving the original functionality and output format.


155-155: LGTM! Proper f-string conversion for edge emission.

The conversion from old-style formatting to f-string maintains the correct DOT graph syntax for edge declarations.


162-162: LGTM! Proper f-string conversion for node emission.

The conversion correctly preserves the DOT graph syntax for node declarations while modernizing the string formatting.


167-167: LGTM! Simple and correct f-string conversion.

The normalize_node_id function correctly converts to f-string format while maintaining the same output.

script/bump_changelog.py (2)

21-21: LGTM! Proper f-string conversion for date formatting.

The NEW_RELEASE_DATE_MESSAGE correctly uses f-string syntax while maintaining the same date formatting functionality.


131-139: LGTM! Appropriate use of pylint disable comments.

The explicit consider-using-f-string disable comments are correctly placed for cases where old-style % formatting is intentionally preserved, likely for specific formatting requirements in this script.

pylint/pyreverse/inspector.py (2)

36-36: LGTM! Simple f-string conversion for debug output.

The print statement correctly converts from % formatting to f-string while maintaining the same output format.


285-285: LGTM! Proper f-string conversion for module path construction.

The conversion from .format() to f-string correctly preserves the logic for building relative module paths.

tests/benchmark/test_baseline_benchmarks.py (1)

134-134: LGTM! Consistent f-string conversions for assertion messages.

All assertion error messages are correctly converted from % formatting to f-strings while maintaining the same functionality for displaying linter messages when tests fail.

Also applies to: 156-156, 169-169, 187-187, 206-206, 225-225, 244-244, 269-269, 295-295, 312-312

pylint/lint/run.py (1)

353-353: LGTM! Proper f-string conversion for error message.

The conversion correctly interpolates the jobs configuration value into the error message using f-string syntax.

pylint/extensions/mccabe.py (4)

53-57: Adopt f-string for bottom identifier.
Replacing str(self._bottom_counter) with f"{self._bottom_counter}" is functionally equivalent and brings consistency with modern string formatting.


138-142: Standardize numbering with f-strings.
Using f"{self._bottom_counter}" in _subgraph_parse preserves the previous behavior while aligning with the new formatting style.


183-185: Update symbolic complexity message formatting.
Converting to f"'{node.name}'" maintains the quoted method/function name exactly as before and modernizes the code.


185-188: Modernize default node description.
Switching to f"This '{node.__class__.__name__.lower()}'" replicates the original lowercase class name formatting and updates to f-strings.

pylint/config/man_help_formatter.py (2)

18-20: Use f-string for heading.
Replacing the old literal with f".SH {heading.upper()}\n" simplifies the code and is consistent with the project's f-string adoption.


57-61: Suppress f-string suggestion for date formatting.
Retaining %-formatting for the date tuple and adding # pylint: disable=consider-using-f-string is intentional to handle the tuple unpacking; the surrounding f-string correctly incorporates it.

pylint/reporters/text.py (4)

147-151: Simplify module header with f-string.
The change to f"************* Module {msg.module}" is behavior-preserving and improves readability.


173-176: Convert warning message to f-string.
Leveraging an f-string in the deprecation warning maintains clarity and embeds the variables directly.


227-230: Modernize colorized module separator.
Using f"************* Module {msg.module}" inside colorize_ansi retains the intended output and matches the new formatting standard.


231-233: Consistent fallback formatting for unnamed modules.
The f-string f"************* {msg.module}" will produce the same blank separator when msg.module is falsy, which mirrors the original behavior.

pylint/checkers/misc.py (1)

110-113: Switch to raw f-string for regex.
Changing to fr"#\s*({notes}|{self.config.notes_rgx})\b" (and the fallback fr"#\s*({notes})\b") is fully equivalent to the previous %-format approach and aligns with the f-string modernization.

tests/test_self.py (6)

237-238: Raw f-string for regex pattern.
pattern = fr"\[{MAIN_CHECKER_NAME.upper()}" correctly builds the regular expression by combining raw and formatted string semantics.


300-302: Leverage f-string for jobs option.
Using f"-j {int(jobs)}" matches pytest’s invocation style and keeps the test logic intact.


487-489: Adopt f-string for rcfile argument.
Using f"--rcfile={config_path}" streamlines the test invocation without altering its behavior.


502-504: f-string for plugin rcfile path.
f"--rcfile={config_path}" correctly injects the dummy plugin config path in the first assertion.


513-514: Consistent f-string in second plugin test.
Reusing f"--rcfile={config_path}" here aligns with the earlier change and maintains the test’s intent.


529-530: Use f-string for comments rcfile test.
Employing f"--rcfile={config_path}" cleanly integrates the config path into this test as well.

tests/functional/l/logging_not_lazy_with_logger.py (1)

2-2: LGTM! Appropriate disable for functional test.

The disable comment for consider-using-f-string is correctly added to this functional test file that intentionally uses % formatting to test the lazy logging checker functionality.

tests/functional/d/duplicate_string_formatting_argument.py (1)

1-1: LGTM! Correct disable directive for functional test.

The addition of consider-using-f-string to the existing disable comment is appropriate since this test file needs to use .format() to test duplicate string formatting argument detection.

tests/functional/s/string/string_formatting_failed_inference.py (1)

2-2: LGTM! Appropriate disable for edge case testing.

The addition of consider-using-f-string to the disable comment is correct since this test file needs to use .format() to test string formatting with failed inference scenarios.

tests/functional/l/logging_not_lazy.py (1)

1-1: LGTM! Correct disable for logging test functionality.

The addition of consider-using-f-string to the disable comment is appropriate since this functional test needs to use various string formatting patterns (including % formatting and concatenation) to test the logging-not-lazy checker.

tests/functional/d/docstrings.py (1)

1-1: LGTM! Appropriate disable comment addition.

The addition of consider-using-f-string to the disable list is correct since this test file contains legacy string formatting (line 83) but focuses on testing docstring functionality, not string formatting practices.

tests/functional/s/string/string_formatting.py (1)

4-4: LGTM! Essential disable for string formatting tests.

This disable is necessary since the file intentionally contains numerous .format() and % formatting examples to test string formatting checkers. Converting these to f-strings would break the test purpose.

tests/functional/u/use/used_before_assignement.py (1)

2-2: LGTM! Appropriate disable for focused test case.

The disable is correct since this test uses % formatting intentionally to test used-before-assignment warnings (lines 5, 7-8). The legacy formatting is part of the test scenario and shouldn't be modernized.

tests/functional/s/string/string_formatting_failed_inference_py35.py (1)

2-2: LGTM! Necessary disable for complex formatting test.

The disable is appropriate since line 6 uses complex % formatting with tuple unpacking that's specifically testing inference edge cases. Converting this to f-string could alter the test scenario.

tests/functional/t/too/too_many_return_statements.py (1)

30-30: LGTM! Good modernization to f-string.

The conversion from legacy % formatting to f-string is correct and maintains the same functionality while following modern Python string formatting practices.

tests/functional/r/renamed_import_logging_not_lazy.py (1)

1-1: LGTM! Appropriate disable directive added.

The addition of consider-using-f-string to the disable list is correct for this functional test file, which intentionally uses legacy % string formatting to test logging behavior rather than string formatting style.

tests/functional/m/misplaced_format_function.py (1)

4-4: LGTM! Correctly placed disable directive.

Adding the consider-using-f-string disable on a separate line is appropriate for this functional test, which specifically tests misplaced .format() behavior and needs to retain the legacy formatting syntax.

doc/whatsnew/2.11.rst (1)

15-17: LGTM! Well-documented new checker.

The documentation clearly describes the new consider-using-f-string checker functionality and appropriately references the originating issue #3592.

tests/functional/l/logging_format_interpolation.py (1)

2-2: LGTM! Appropriate disable for logging test.

Adding consider-using-f-string to the disable list is correct since this test intentionally uses .format() calls to verify logging interpolation behavior, not string formatting style.

tests/functional/s/string/string_formatting_py3.py (1)

1-1: LGTM! Necessary disable for string formatting tests.

The addition of consider-using-f-string to the disable list is appropriate since this test uses % formatting specifically to test format argument validation, not formatting style preferences.

tests/functional/u/undefined/undefined_loop_variable.py (1)

1-1: LGTM! Appropriate disable directive for test file.

The addition of consider-using-f-string to the disable comment is correct, as this test file intentionally contains old-style string formatting examples (.format() on line 84 and % formatting on line 88) that should not trigger the new checker.

tests/functional/u/use/used_before_assignment_issue853.py (1)

1-1: LGTM! Correct suppression of new checker for test file.

The addition of consider-using-f-string to the disable directive is appropriate, as this test file contains intentional old-style % formatting (line 13) that should not trigger warnings from the new checker.

tests/pyreverse/test_utils.py (1)

69-69: LGTM! Correct raw f-string prefix order.

The change from rf to fr follows Python conventions for combining raw and formatted string prefixes. While both orders are valid, fr is the canonical and preferred order.

tests/functional/u/unused/unused_argument.py (1)

75-75: LGTM! Modernized string formatting to f-string.

The conversion from old-style % formatting to f-string (f'{etype} X') improves readability and performance while maintaining identical functionality. This aligns with the PR's goal of modernizing string formatting throughout the codebase.

tests/input/func_w0401_package/thing2.py (1)

7-7: LGTM! Modernized string formatting to f-string.

The conversion to f-string syntax (f"{THING1}, plus {THING2}") improves readability and follows modern Python practices while maintaining identical functionality. This change aligns with the PR's modernization goals.

pylint/extensions/broad_try_clause.py (1)

64-64: LGTM! Clean f-string modernization.

The conversion from .format() to f-string is syntactically correct and preserves the original message content and functionality.

pylint/checkers/__init__.py (1)

68-69: LGTM! Proper f-string conversion with preserved formatting.

The conversion from old-style %.3f formatting to f-string {value:.3f} is correct and maintains the original floating-point precision specification and conditional logic.

ChangeLog (2)

13-13: Changelog entry follows established style
The new consider-using-f-string entry is formatted consistently with existing items under "What's New in Pylint 2.11.0?".


15-15: Issue closure reference is correct
The Closes #3592 line properly links this addition to the corresponding issue.

doc/exts/pylint_extensions.py (1)

40-40: LGTM! String formatting modernized correctly.

The conversion from % formatting to f-string is syntactically correct and maintains the same functionality while improving readability.

pylint/testutils/reporter_for_tests.py (1)

35-35: LGTM! String formatting modernized correctly.

The conversion from % formatting to f-string is syntactically correct and maintains the same functionality while improving readability.

pylint/reporters/ureports/text_writer.py (1)

97-97: LGTM! String formatting modernized correctly.

The conversion from % formatting to f-string is syntactically correct and maintains the same functionality while improving readability.

tests/functional/l/logging_not_lazy_with_logger.txt (1)

2-4: LGTM! Test expectations updated correctly.

The line numbers have been appropriately updated to reflect changes in the corresponding test file. The warning messages remain unchanged, indicating the test logic is preserved.

pylint/extensions/overlapping_exceptions.py (2)

69-69: LGTM! String formatting modernized correctly.

The conversion from % formatting to f-string is syntactically correct and maintains the same functionality while improving readability.


77-77: LGTM! String formatting modernized correctly.

The conversion from % formatting to f-string is syntactically correct and maintains the same functionality while improving readability.

pylint/lint/report_functions.py (1)

68-68: LGTM: Correct modernization to f-string formatting.

The conversion from "%.2f" % val to f"{val:.2f}" is functionally equivalent and follows the PR's objective to modernize string formatting.

pylint/pyreverse/diadefslib.py (2)

142-142: LGTM: Correct modernization to f-string formatting.

The conversion from "packages %s" % node.name to f"packages {node.name}" is functionally equivalent and improves readability.


145-145: LGTM: Correct modernization to f-string formatting.

The conversion from "classes %s" % node.name to f"classes {node.name}" is functionally equivalent and improves readability.

tests/test_func.py (2)

41-41: LGTM: Correct modernization to f-string formatting.

The conversion from "in %s\n:: %s" % (ex.file, ', '.join(ex.args)) to f"in {ex.file}\n:: {', '.join(ex.args)}" is functionally equivalent and improves readability.


58-58: LGTM: Correct modernization to f-string formatting.

The conversion from self.package + ".%s" % name.replace('.py', '') to self.package + f".{name.replace('.py', '')}" is functionally equivalent and improves readability.

pylint/checkers/refactoring/not_checker.py (1)

78-80: LGTM: Correct modernization to f-string formatting.

The conversion from .format() to f-string formatting is functionally equivalent and improves readability. The suggestion string construction logic remains the same.

tests/checkers/unittest_python3.py (2)

503-503: LGTM: Correct modernization to f-string formatting.

The conversion from "x.iter%s() #@" % meth to f"x.iter{meth}() #@" is functionally equivalent and improves readability.


540-540: LGTM: Correct modernization to f-string formatting.

The conversion from "x.view%s() #@" % meth to f"x.view{meth}() #@" is functionally equivalent and improves readability.

pylint/checkers/refactoring/refactoring_checker.py (1)

1409-1409: Use of f-string is correct and preserves original behavior.

The new f-string builds the ternary suggestion exactly as before (truth_value if cond else false_value). No change in logic.

pylint/message/message_definition.py (6)

67-67: Modernized checker reference message with f-string.

The f-string correctly interpolates self.checker_name into the description for checkerref.


72-72: f-string used for minimum version formatting.

The restriction string < {minversion} is built correctly with joined tuple elements.


74-74: f-string used for maximum version formatting.

The restriction string >= {maxversion} is built correctly with joined tuple elements.


77-77: f-string adds Python version restriction when checkerref is true.

The message is correctly appended for Python version bounds under the checkerref condition.


80-80: f-string adds Python version restriction in the default branch.

The help text for version limits is correctly formatted when checkerref is false.


86-86: Return f-string for message help is clear and concise.

The help output now uses an f-string to prefix the message identifier and title correctly.

pylint/testutils/constants.py (2)

10-12: Suppressing f-string suggestion on legacy version string.

SYS_VERS_STR uses % formatting and includes a disable comment to avoid the new checker. This is intentional for compatibility in tests.


25-25: Suppressing f-string suggestion in regex literal.

The raw regex string remains in % style with a disable comment to prevent noisy warnings.

pylint/checkers/typecheck.py (1)

251-251: LGTM! Clean modernization to f-string formatting.

The conversion from .format() to f-string improves readability while maintaining identical functionality for the hint message construction.

pylint/message/message_handler_mix_in.py (2)

258-258: LGTM! Excellent modernization of error message formatting.

The conversion from % formatting to f-strings in the check_message_definition method improves code readability while maintaining identical error message content and logic.

Also applies to: 262-264, 269-269


373-373: LGTM! Clean f-string conversion in documentation generation.

The modernization from % formatting to f-strings in the get_checkers_documentation method enhances readability without altering the documentation output.

Also applies to: 375-375

pylint/config/option.py (2)

94-94: LGTM! Clean exception message modernization.

The conversion from % formatting to f-string in the exception handling improves readability while maintaining identical error message content.


159-159: LGTM! Improved error message formatting.

The f-string conversion in the option validation error message enhances code readability without changing the error message logic or content.

pylint/pyreverse/utils.py (3)

134-134: LGTM! Clean error message modernization.

The conversion from % formatting to f-string in the error handling improves readability while maintaining identical functionality.


179-179: LGTM! Improved method name construction.

The f-string conversion for building callback method names in get_callbacks enhances code readability without altering the method resolution logic.

Also applies to: 182-182


260-260: LGTM! Appropriate use of raw f-string.

The conversion to a raw f-string is correct for the Optional type annotation string, maintaining the backslash literal while improving syntax consistency.

tests/functional/s/slots_checks.py (1)

28-28: LGTM! Clean test code modernization.

The conversion from % formatting to f-string in the generator expression maintains identical slot name generation while improving code consistency with modern Python practices.

pylint/checkers/spelling.py (3)

236-236: LGTM: Clean f-string conversion

The help message formatting has been correctly modernized from % formatting to f-string syntax while preserving the exact same output.


403-403: LGTM: Appropriate f-string conversion

The file write operation has been correctly updated to use f-string formatting, making the code more readable and consistent.


410-410: LGTM: Correct usage of raw f-string for regex

The conversion to fr"..." (raw f-string) is the right approach here since this is a regex pattern that may contain backslashes that should not be interpreted as escape sequences.

pylint/testutils/lint_module_test.py (3)

56-56: LGTM: Clean f-string conversions for pytest.skip calls

The conversion of these error messages to f-strings improves readability while maintaining the same functionality.

Also applies to: 65-65, 76-76


195-195: LGTM: Error message initialization modernized

The conversion to f-string formatting makes the error message construction more readable and consistent with modern Python practices.


201-204: LGTM: Appropriate retention of % formatting with explicit disables

The decision to retain % formatting in these list comprehensions with explicit pylint disable comments is reasonable - likely for testing purposes or where the % formatting is more suitable for the context.

Also applies to: 207-207

pylint/pyreverse/diagrams.py (2)

113-113: LGTM: Clean conversion from .format() to f-string

The attribute name formatting with type annotations has been correctly modernized to use f-string syntax, improving readability while maintaining the same output format.


243-243: LGTM: Module path construction modernized

The conversion from .format() to f-string for module name construction is appropriate and makes the code more readable.

pylint/checkers/base_checker.py (4)

73-73: LGTM: Checker title formatting modernized

The conversion to f-string for constructing the checker title improves readability while maintaining the same string manipulation logic.


76-80: LGTM: RST documentation formatting conversions

All the RST anchor, title, and metadata formatting has been appropriately converted to f-strings, making the documentation generation code more readable and consistent.


84-84: LGTM: Documentation sections modernized

The f-string conversions for documentation content, options section, and message formatting are clean and improve code readability.

Also applies to: 89-89, 96-96


101-103: LGTM: Appropriate retention of % formatting for reports

The decision to keep % formatting for report line construction with an explicit pylint disable comment is reasonable - likely because this format works better for the tuple unpacking pattern used here.

pylint/checkers/similar.py (2)

460-460: LGTM! String formatting modernization.

The conversion from .format() to f-string improves readability while maintaining identical functionality.


675-675: LGTM! Clean f-string conversion.

The __str__ method modernization is straightforward and maintains the same output format.

tests/test_check_parallel.py (2)

33-35: LGTM! Test data generation modernized.

The conversion from % formatting to f-strings for generating test file data names is clean and improves readability.


422-423: LGTM! Intentional preservation of legacy formatting.

The pylint disable comment appropriately suppresses the new consider-using-f-string warning while preserving the % formatting, likely for testing backwards compatibility or specific edge cases.

pylint/checkers/exceptions.py (4)

274-276: LGTM! Appropriate disable comment usage.

The pylint disable comment correctly prevents the new consider-using-f-string checker from flagging this intentionally preserved % formatting in the help text.


491-491: LGTM! Clean suggestion message modernization.

The f-string conversion for the binary operation exception suggestion improves readability while maintaining the same message format.


498-498: LGTM! Comparison suggestion modernization.

The f-string conversion correctly handles the complex string interpolation with join() for multiple operands, maintaining the same suggestion format.


558-558: LGTM! Error message modernization.

The f-string conversion for the ancestor class error message is straightforward and maintains the same informative error format.

tests/checkers/unittest_similar.py (8)

56-59: LGTM! Test assertion modernization.

The conversion from % formatting to f-strings in the expected output maintains identical string content while improving readability.


85-88: LGTM! Consistent formatting updates.

The f-string conversions for the docstring ignore test assertions are clean and maintain the exact expected output format.

Also applies to: 99-100


133-136: LGTM! Multiline import test modernization.

The f-string conversion preserves the exact expected output for the multiline import similarity test.


172-176: LGTM! Signature test assertion updates.

The f-string conversions for the signature-related test assertions maintain the exact expected output format while improving code readability.

Also applies to: 188-189


223-226: LGTM! Class method test modernization.

The f-string conversions for class method similarity test assertions preserve the exact expected output while modernizing the formatting approach.

Also applies to: 245-247


282-285: LGTM! Empty function test update.

The f-string conversion maintains the exact expected output for the empty function similarity test.


327-330: LGTM! Basic similarity test modernization.

The f-string conversion for the basic similarity test assertion preserves the expected output while improving readability.


350-353: LGTM! Meaningful content test update.

The f-string conversion for the final test assertion maintains the exact expected output format while completing the systematic modernization of this test file.

pylint/checkers/imports.py (4)

154-154: Consistent use of f-strings in _repr_tree_defs.
Modernizing to f-strings improves readability without altering logic.

Also applies to: 161-161, 163-163


742-743: Refactored message args to f-strings for wrong-import-order.
Embedding node.as_string() in f-strings preserves the original placeholders and quotation.


757-758: Refactored message args to f-strings in third-party import check.
This mirrors the standard-import case and maintains consistency.


790-790: Use f-string for syntax-error reporting.
Constructing the error message with !r ensures proper quoting of module name and exception.

pylint/lint/pylinter.py (4)

318-318: F-string for dynamic help text in confidence option.
Precomputing valid levels at import time improves clarity of the help message.


632-632: Switched to f-string in deprecation warning.
Dynamically computing the replacement option retains original intent.


652-652: F-string for config-read error print statement.
Simplifies string interpolation and aligns with project style.


1302-1302: Converted evaluation messages to f-strings.
Both the exception and success messages now use f-strings for cleaner formatting.

Also applies to: 1305-1305

pylint/checkers/variables.py (4)

184-193: Use f-strings for unpacking info
Modernized message construction in _get_unpacking_extra_info to use f-strings. No logic change.


1715-1715: Modernize import message to f-string
Replaced older formatting with an f-string for the unused-import warning in _check_is_unused. Behavior is intact.


2105-2105: Modernize import message to f-string
Converted the unused-import message to an f-string in _check_imports. No change in functionality.


2131-2131: Modernize imported-from message to f-string
Replaced old formatting with an f-string for ImportFrom warnings in _check_imports. Logic remains the same.

pylint/utils/utils.py (9)

49-51: Adopt f-string in diff_string
Updated diff_str construction to use an f-string for clarity; behavior unchanged.


82-84: Use f-string for formatted doc
Converted documentation insertion in get_rst_section to an f-string. No logic change.


85-87: Use f-string for option name line
Modernized the :{optname}: line in get_rst_section to an f-string. Functionality is preserved.


87-90: Use f-string for help text
Replaced concatenation with an f-string for the formatted help text in get_rst_section. Behavior unchanged.


91-93: Use f-string for default value
Changed default value line to an f-string in get_rst_section for readability; logic remains the same.


242-244: Use f-string in comment builder
Simplified _comment return to an f-string. No change in the output format.


258-261: Use f-string for quoting default string
Replaced manual quoting logic with an f-string in _format_option_value. Behavior is intact.


267-269: Use f-string for section header
Converted the INI section header print to an f-string in format_section. No functional change.


283-285: Use f-string for commented option
Updated commented option printing to an f-string in _ini_format. Functionality is preserved.

pylint/checkers/classes.py (1)

2042-2042: Use f-string for static error message
Good modernization: using an f-string to include the NEXT_METHOD constant in the error message. No behavior change.

pylint/extensions/_check_docs_utils.py (14)

250-253: Modernize regex pattern definition with f-string
Switching re_simple_container_type to a raw f-string correctly embeds re_type while preserving regex semantics.


262-265: Modernize cross-reference pattern with f-string
The fr"""…""" form cleanly interpolates re_type for re_xref; behavior remains unchanged.


267-284: Convert parameter regex raw pattern to f-string
The raw f-string for re_param_raw maintains the capture groups and spacing while embedding type patterns.


287-294: Convert type regex raw pattern to f-string
Using an f-string for re_type_raw safely injects re_multiple_simple_type without altering functionality.


296-303: Convert property type pattern to f-string
The raw f-string for re_property_type_raw preserves regex logic and embeds the multiple-type pattern correctly.


303-314: Convert exception raises regex to f-string
Switching to fr"""…""" for re_raise_raw replaces older .format() calls, embedding re_multiple_simple_type as intended.


445-448: Modernize container type regex with f-string
The raw f-string for re_container_type cleanly incorporates both re_type and re_xref. Approved.


472-480: Convert parameter line pattern to f-string
The fr"""…""" literal embeds re_multiple_type in the parameter-line regex, keeping multiline and verbose flags intact.


488-493: Convert raise line pattern to f-string
Refactoring re_raise_line to use a raw f-string correctly brings in re_multiple_type. No semantic change.


500-505: Convert returns line pattern to f-string
Using an f-string for re_returns_line embeds re_multiple_type as before; functionality is preserved.


508-513: Convert property returns line pattern to f-string
The raw f-string for re_property_returns_line properly interpolates re_multiple_type. Approved.


724-730: Convert numpy param line pattern to f-string
The fr"""…""" literal here embeds GoogleDocstring.re_multiple_type correctly and matches the original behavior.


739-743: Convert numpy raise line pattern to f-string
The raw f-string for re_raise_line cleanly integrates GoogleDocstring.re_type. Behavior unchanged.


750-756: Convert numpy returns line pattern to f-string
Switching re_returns_line to an f-string correctly interpolates GoogleDocstring.re_multiple_type and maintains capture group semantics.

pylint/checkers/base.py (1)

196-196: String formatting modernization looks good!

All conversions from old-style formatting to f-strings are correct and improve code readability.

Also applies to: 407-407, 412-412, 1707-1707, 1718-1718, 1889-1889, 1891-1891, 2024-2024

pylint/checkers/strings.py (2)

83-85: F-string conversions are correct.

The regex compilation and error message formatting have been properly converted to f-strings.

Also applies to: 1063-1063


676-681: New checker message definition looks good.

The "consider-using-f-string" message is well-defined and aligns with the PR's objective.

tests/functional/c/consider/consider_using_f_string.py (5)

1-4: Well-structured test file with appropriate pylint disables.

The file header and pylint disables are appropriate for a functional test file that intentionally uses unused variables and expressions for testing purposes.


5-21: Good test data setup with clear structure.

The constants and helper functions provide a comprehensive foundation for testing different formatting scenarios. The naming is clear and the data structures cover the necessary test cases.


39-49: Good coverage of simple formatting cases that should trigger warnings.

The "bad" examples correctly identify simple formatting patterns that should be converted to f-strings. The comment annotations # [consider-using-f-string] properly mark the expected warning locations.


67-77: Statement "bad" examples are consistent with print examples.

Good consistency in testing the same formatting patterns across different contexts.


97-107: Assignment "bad" examples complete the test coverage.

Good consistency in testing simple formatting cases that should trigger the f-string suggestion across all contexts.

Comment on lines +24 to +37
def print_good():
print("String {}, {} or {}".format(*PARAM_LIST))
print("String {}, {}, {} or {}".format(*PARAM_LIST_SINGLE, *PARAM_LIST))
print("String {Param}, {}, {} or {}".format(Param=PARAM_1, *PARAM_LIST))
print("String {Param} {Param}".format(Param=PARAM_1))
print("{Param_1} {Param_2}".format(**PARAM_DICT))
print("{Param_1} {Param_2} {Param_3}".format(**PARAM_DICT_SINGLE, **PARAM_DICT))
print("{Param_1} {Param_2} {Param_3}".format(Param_1=PARAM_1, **PARAM_DICT))
print("{Param_1} {Param_2}".format(**PARAM_DICT))
print("{Param_1} {Param_2}".format(**return_dict()))
print("%(Param_1)s %(Param_2)s" % PARAM_LIST)
print("%(Param_1)s %(Param_2)s" % PARAM_DICT)
print("%(Param_1)s %(Param_2)s" % return_dict())
print("{a[Param_1]}{a[Param_2]}".format(a=PARAM_DICT))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Comprehensive coverage of complex formatting scenarios.

The "good" examples correctly identify formatting patterns that should not trigger the f-string warning, including star unpacking, dictionary unpacking, repeated parameters, and nested dictionary access.

However, there's a logical error in the % formatting:

Line 34 has incorrect % formatting syntax:

print("%(Param_1)s %(Param_2)s" % PARAM_LIST)

This will cause a TypeError at runtime because named parameter formatting (%(name)s) requires a dictionary, but PARAM_LIST is a list.

-    print("%(Param_1)s %(Param_2)s" % PARAM_LIST)
+    print("%(Param_1)s %(Param_2)s" % PARAM_DICT)
🧰 Tools
🪛 Ruff (0.11.9)

27-27: Star-arg unpacking after a keyword argument is strongly discouraged

(B026)

🤖 Prompt for AI Agents
In tests/functional/c/consider/consider_using_f_string.py around lines 24 to 37,
the line using percent formatting with named placeholders incorrectly applies a
list (PARAM_LIST) instead of a dictionary, causing a TypeError. Replace
PARAM_LIST with a dictionary that contains the keys 'Param_1' and 'Param_2' or
use a suitable dictionary variable to match the named placeholders in the format
string.

Comment on lines +80 to +94
def assignment_good():
A = "String {}, {} or {}".format(*PARAM_LIST)
B = "String {}, {}, {} or {}".format(*PARAM_LIST_SINGLE, *PARAM_LIST)
C = "String {Param}, {}, {} or {}".format(Param=PARAM_1, *PARAM_LIST)
D = "String {Param} {Param}".format(Param=PARAM_1)
E = "{Param_1} {Param_2}".format(**PARAM_DICT)
F = "{Param_1} {Param_2} {Param_3}".format(**PARAM_DICT_SINGLE, **PARAM_DICT)
G = "{Param_1} {Param_2} {Param_3}".format(Param_1=PARAM_1, **PARAM_DICT)
H = "{Param_1} {Param_2}".format(**PARAM_DICT)
I = "{Param_1} {Param_2}".format(**return_dict())
J = "%(Param_1)s %(Param_2)s" % PARAM_LIST
K = "%(Param_1)s %(Param_2)s" % PARAM_DICT
L = "%(Param_1)s %(Param_2)s" % return_dict()
M = "{a[Param_1]}{a[Param_2]}".format(a=PARAM_DICT)
N = "{Param}".format

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Assignment context testing completes the comprehensive coverage.

The assignment examples cover the same scenarios in a third context, ensuring the checker works across all typical use cases.

Same logical error pattern continues:

Line 90 has the same incorrect % formatting issue:

-    J = "%(Param_1)s %(Param_2)s" % PARAM_LIST
+    J = "%(Param_1)s %(Param_2)s" % PARAM_DICT

Line 94 is an interesting edge case testing assignment of the format method itself rather than a formatted string - this appears intentional for testing edge cases.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def assignment_good():
A = "String {}, {} or {}".format(*PARAM_LIST)
B = "String {}, {}, {} or {}".format(*PARAM_LIST_SINGLE, *PARAM_LIST)
C = "String {Param}, {}, {} or {}".format(Param=PARAM_1, *PARAM_LIST)
D = "String {Param} {Param}".format(Param=PARAM_1)
E = "{Param_1} {Param_2}".format(**PARAM_DICT)
F = "{Param_1} {Param_2} {Param_3}".format(**PARAM_DICT_SINGLE, **PARAM_DICT)
G = "{Param_1} {Param_2} {Param_3}".format(Param_1=PARAM_1, **PARAM_DICT)
H = "{Param_1} {Param_2}".format(**PARAM_DICT)
I = "{Param_1} {Param_2}".format(**return_dict())
J = "%(Param_1)s %(Param_2)s" % PARAM_LIST
K = "%(Param_1)s %(Param_2)s" % PARAM_DICT
L = "%(Param_1)s %(Param_2)s" % return_dict()
M = "{a[Param_1]}{a[Param_2]}".format(a=PARAM_DICT)
N = "{Param}".format
def assignment_good():
A = "String {}, {} or {}".format(*PARAM_LIST)
B = "String {}, {}, {} or {}".format(*PARAM_LIST_SINGLE, *PARAM_LIST)
C = "String {Param}, {}, {} or {}".format(Param=PARAM_1, *PARAM_LIST)
D = "String {Param} {Param}".format(Param=PARAM_1)
E = "{Param_1} {Param_2}".format(**PARAM_DICT)
F = "{Param_1} {Param_2} {Param_3}".format(**PARAM_DICT_SINGLE, **PARAM_DICT)
G = "{Param_1} {Param_2} {Param_3}".format(Param_1=PARAM_1, **PARAM_DICT)
H = "{Param_1} {Param_2}".format(**PARAM_DICT)
I = "{Param_1} {Param_2}".format(**return_dict())
J = "%(Param_1)s %(Param_2)s" % PARAM_DICT
K = "%(Param_1)s %(Param_2)s" % PARAM_DICT
L = "%(Param_1)s %(Param_2)s" % return_dict()
M = "{a[Param_1]}{a[Param_2]}".format(a=PARAM_DICT)
N = "{Param}".format
🧰 Tools
🪛 Ruff (0.11.9)

81-81: Local variable A is assigned to but never used

Remove assignment to unused variable A

(F841)


82-82: Local variable B is assigned to but never used

Remove assignment to unused variable B

(F841)


83-83: Local variable C is assigned to but never used

Remove assignment to unused variable C

(F841)


83-83: Star-arg unpacking after a keyword argument is strongly discouraged

(B026)


84-84: Local variable D is assigned to but never used

Remove assignment to unused variable D

(F841)


85-85: Local variable E is assigned to but never used

Remove assignment to unused variable E

(F841)


86-86: Local variable F is assigned to but never used

Remove assignment to unused variable F

(F841)


87-87: Local variable G is assigned to but never used

Remove assignment to unused variable G

(F841)


88-88: Local variable H is assigned to but never used

Remove assignment to unused variable H

(F841)


89-89: Ambiguous variable name: I

(E741)


89-89: Local variable I is assigned to but never used

Remove assignment to unused variable I

(F841)


90-90: Local variable J is assigned to but never used

Remove assignment to unused variable J

(F841)


91-91: Local variable K is assigned to but never used

Remove assignment to unused variable K

(F841)


92-92: Local variable L is assigned to but never used

Remove assignment to unused variable L

(F841)


93-93: Local variable M is assigned to but never used

Remove assignment to unused variable M

(F841)


94-94: Local variable N is assigned to but never used

Remove assignment to unused variable N

(F841)

🤖 Prompt for AI Agents
In tests/functional/c/consider/consider_using_f_string.py around lines 80 to 94,
line 90 uses incorrect % formatting with PARAM_LIST which should be a dictionary
for named placeholders. Fix this by replacing PARAM_LIST with a dictionary or
using .format() or f-string syntax instead. The other lines are correct or
intentionally testing edge cases, so no changes needed there.

Comment on lines +52 to +65
def statement_good():
"String {}, {} or {}".format(*PARAM_LIST)
"String {}, {}, {} or {}".format(*PARAM_LIST_SINGLE, *PARAM_LIST)
"String {Param}, {}, {} or {}".format(Param=PARAM_1, *PARAM_LIST)
"String {Param} {Param}".format(Param=PARAM_1)
"{Param_1} {Param_2}".format(**PARAM_DICT)
"{Param_1} {Param_2} {Param_3}".format(**PARAM_DICT_SINGLE, **PARAM_DICT)
"{Param_1} {Param_2} {Param_3}".format(Param_1=PARAM_1, **PARAM_DICT)
"{Param_1} {Param_2}".format(**PARAM_DICT)
"{Param_1} {Param_2}".format(**return_dict())
"%(Param_1)s %(Param_2)s" % PARAM_LIST
"%(Param_1)s %(Param_2)s" % PARAM_DICT
"%(Param_1)s %(Param_2)s" % return_dict()
"{a[Param_1]}{a[Param_2]}".format(a=PARAM_DICT)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Statement context testing mirrors print function testing well.

The standalone statement examples provide good coverage for the same scenarios as the print examples.

Same logical error as in print_good():

Line 62 has the same incorrect % formatting issue:

-    "%(Param_1)s %(Param_2)s" % PARAM_LIST
+    "%(Param_1)s %(Param_2)s" % PARAM_DICT
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def statement_good():
"String {}, {} or {}".format(*PARAM_LIST)
"String {}, {}, {} or {}".format(*PARAM_LIST_SINGLE, *PARAM_LIST)
"String {Param}, {}, {} or {}".format(Param=PARAM_1, *PARAM_LIST)
"String {Param} {Param}".format(Param=PARAM_1)
"{Param_1} {Param_2}".format(**PARAM_DICT)
"{Param_1} {Param_2} {Param_3}".format(**PARAM_DICT_SINGLE, **PARAM_DICT)
"{Param_1} {Param_2} {Param_3}".format(Param_1=PARAM_1, **PARAM_DICT)
"{Param_1} {Param_2}".format(**PARAM_DICT)
"{Param_1} {Param_2}".format(**return_dict())
"%(Param_1)s %(Param_2)s" % PARAM_LIST
"%(Param_1)s %(Param_2)s" % PARAM_DICT
"%(Param_1)s %(Param_2)s" % return_dict()
"{a[Param_1]}{a[Param_2]}".format(a=PARAM_DICT)
def statement_good():
"String {}, {} or {}".format(*PARAM_LIST)
"String {}, {}, {} or {}".format(*PARAM_LIST_SINGLE, *PARAM_LIST)
"String {Param}, {}, {} or {}".format(Param=PARAM_1, *PARAM_LIST)
"String {Param} {Param}".format(Param=PARAM_1)
"{Param_1} {Param_2}".format(**PARAM_DICT)
"{Param_1} {Param_2} {Param_3}".format(**PARAM_DICT_SINGLE, **PARAM_DICT)
"{Param_1} {Param_2} {Param_3}".format(Param_1=PARAM_1, **PARAM_DICT)
"{Param_1} {Param_2}".format(**PARAM_DICT)
"{Param_1} {Param_2}".format(**return_dict())
"%(Param_1)s %(Param_2)s" % PARAM_DICT
"%(Param_1)s %(Param_2)s" % PARAM_DICT
"%(Param_1)s %(Param_2)s" % return_dict()
"{a[Param_1]}{a[Param_2]}".format(a=PARAM_DICT)
🧰 Tools
🪛 Ruff (0.11.9)

55-55: Star-arg unpacking after a keyword argument is strongly discouraged

(B026)

🤖 Prompt for AI Agents
In tests/functional/c/consider/consider_using_f_string.py around lines 52 to 65,
line 62 uses incorrect % formatting with PARAM_LIST, which is logically wrong.
Replace the % formatting on line 62 to use a dictionary or correct mapping
instead of a list to fix the formatting error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants