Skip to content

PR #32029: Add flake8-logging-format (G) rules and fix logging statements #33694

@qiaozikl

Description

@qiaozikl

This PR adds flake8-logging-format (G) rules to the ruff configuration and fixes all logging statements in the codebase to use proper logging format strings instead of f-strings. This improves code consistency and follows best practices for logging.

Changes Made:

Configuration Changes:

  • Added G (flake8-logging-format) to the ruff lint select rules in pyproject.toml

Code Changes:

Fixed logging statements in 8 files:

  1. libs/langchain/langchain/agents/agent_iterator.py - Fixed logger.debug call
  2. libs/langchain/langchain/memory/entity.py - Fixed multiple logger.debug calls
  3. libs/langchain/langchain/retrievers/multi_query.py - Fixed logger.info calls
  4. libs/langchain/langchain/retrievers/re_phraser.py - Fixed logger.info call
  5. libs/langchain/langchain/retrievers/self_query/base.py - Fixed logger.info calls
  6. libs/langchain/langchain/smith/evaluation/runner_utils.py - Fixed multiple logger calls including error handling and warnings
  7. libs/langchain/pyproject.toml - Added the G rule to ruff configuration
  8. libs/langchain/uv.lock - Updated dependency version

Key Improvements:

  • Replaced f-strings with proper logging format strings using %s placeholders
  • Improved error handling logging with more detailed information
  • Ensured consistent logging format across the codebase
  • Added proper exception logging with traceback information

This change aligns the codebase with Python logging best practices and improves maintainability.

Merge Status: Merged on July 14, 2025
Reviewer: @mdrxy (approved with minor suggestion about input key validation that was addressed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions