Skip to content

Conversation

@mgunnin
Copy link

@mgunnin mgunnin commented Nov 13, 2025

Summary

  • Fixes undefined logger error in github_scraper.py
  • Moves logging configuration before code_analyzer import
  • Prevents NameError when code_analyzer module is not available

Details

The code_analyzer import block was referencing logger.warning() before the logger was configured. This change reorders the initialization so that logging is set up first, ensuring logger is available for the import error handling.

Changes

  • Moved logging.basicConfig() and logger = logging.getLogger(__name__) to execute before the code_analyzer import statement
  • No functional changes to the logic, just reordering for proper initialization sequence

Before

try:
    from code_analyzer import CodeAnalyzer
    CODE_ANALYZER_AVAILABLE = True
except ImportError:
    CODE_ANALYZER_AVAILABLE = False
    logger.warning("Code analyzer not available")  # ❌ NameError - logger not defined yet

logging.basicConfig(...)
logger = logging.getLogger(__name__)

After

logging.basicConfig(...)
logger = logging.getLogger(__name__)

try:
    from code_analyzer import CodeAnalyzer
    CODE_ANALYZER_AVAILABLE = True
except ImportError:
    CODE_ANALYZER_AVAILABLE = False
    logger.warning("Code analyzer not available")  # ✅ Works correctly

Test Plan

  • Code runs without NameError
  • logger.warning() works correctly when code_analyzer is missing
  • Existing functionality unchanged
  • No regression in import behavior

Related Issues

Resolves import order bug discovered during codebase maintenance

Resolves undefined logger error by ensuring logging is configured
before the code_analyzer import statement that references logger.warning().
This prevents NameError when code_analyzer is not available.
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