Skip to content

Conversation

@dev-chin
Copy link

@dev-chin dev-chin commented Jan 8, 2026

Since I see You don't read Issues, hopefully you will read this PR. Reported issue many weeks ago

#2

Called function was commented out in 1.44.29, but this call still existed causing error in some instances.

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 8, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Uncomments the logging setup path so that a logger is always configured, and removes a stray self-call in the test helper that could cause recursive execution or side effects when importing or running tests.

Sequence diagram for updated setup_logging_custom behavior

sequenceDiagram
    actor Developer
    participant App
    participant LoggerModule
    participant logging

    Developer->>App: import richcolorlog
    App->>LoggerModule: setup_logging_custom(name, level, other_params)
    LoggerModule->>LoggerModule: check environment
    alt NO_LOGGING not set
        LoggerModule->>logging: basicConfig(level)
    else NO_LOGGING set
        LoggerModule->>logging: basicConfig(level=CRITICAL)
    end
    LoggerModule->>logging: getLogger(name)
    logging-->>LoggerModule: logger instance
    LoggerModule->>LoggerModule: assign CustomLogger class
    LoggerModule-->>App: configured CustomLogger instance
Loading

Flow diagram for updated setup_logging_custom and test helper

flowchart TD
    A["Call setup_logging_custom"] --> B["Set environment NO_LOGGING based on parameters"]
    B --> C{"NO_LOGGING is set?"}
    C -->|Yes| D["logging.basicConfig(level=CRITICAL)"]
    C -->|No| E["logging.basicConfig(level from parameters)"]
    D --> F["logger = logging.getLogger(name)"]
    E --> F
    F --> G["Set logger.__class__ = CustomLogger"]
    G --> H["Return configured logger"]

    subgraph Test_helper_changes
        T1["Define test() helper function"] --> T2["Previously: implicit call to test() at end of file"]
        T2 --> T3["Potential recursive execution or side effects"]
        T1 --> T4["Now: no automatic call to test()"]
        T4 --> T5["test() runs only when explicitly invoked"]
    end
Loading

File-Level Changes

Change Details Files
Ensure setup_logging_custom always configures and returns a CustomLogger instead of short‑circuiting when logging is disabled via environment.
  • Commented out the early return guarded by _check_logging_disabled so the function proceeds to create and configure a logger instance
  • Kept the NO_LOGGING environment and logging.basic configuration logic intact while allowing CustomLogger setup to run
richcolorlog/logger.py
Prevent automatic execution of the test helper when the module is imported or the function definition is read.
  • Removed the trailing test() call at the end of the file to avoid immediate invocation of the test function
richcolorlog/logger.py

Possibly linked issues

  • #N/A: The PR removes the failing _check_logging_disabled call that causes the NameError reported in the issue.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Instead of commenting out the _check_logging_disabled() block, either remove it entirely or replace it with a clearer, configurable condition (e.g., a function parameter or explicit flag) so the logging-disable behavior is well defined rather than left as dead code.
  • By removing the early return when logging is disabled, setup_logging_custom now always mutates the logger into CustomLogger; if this change is intentional, consider making that behavior explicit in the function name or signature so callers understand it no longer respects the previous disable mechanism.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Instead of commenting out the `_check_logging_disabled()` block, either remove it entirely or replace it with a clearer, configurable condition (e.g., a function parameter or explicit flag) so the logging-disable behavior is well defined rather than left as dead code.
- By removing the early return when logging is disabled, `setup_logging_custom` now always mutates the logger into `CustomLogger`; if this change is intentional, consider making that behavior explicit in the function name or signature so callers understand it no longer respects the previous disable mechanism.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dev-chin
Copy link
Author

dev-chin commented Jan 8, 2026

@sourcery-ai shut up.

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.

1 participant