Skip to content

Conversation

@Miyamura80
Copy link
Owner

Summary

  • Expand ruff rules with B (bugbear), C4 (comprehensions), SIM (simplify) and fix all resulting violations (B904, B028, B009, C416, SIM114)
  • Extract _identify_provider() helper in global_config.py to deduplicate model-name regex matching across llm_api_key() and api_base()
  • Narrow exception catches in dspy_inference.py and dspy_langfuse.py to specific exception types
  • Add thread-safe logging initialization with threading.Lock() and double-checked locking pattern
  • Fix Python version in ruff workflow to dynamically read from .python-version file
  • Add ruff-check hook to .pre-commit-config.yaml
  • Enable pytest coverage collection with --cov=src --cov=common --cov=utils (was previously a no-op without --cov)
  • Remove utils/llm/** from coverage omit so LLM utilities are measured

Test plan

  • make ruff passes with expanded rules
  • make fmt produces no formatting changes
  • make test_fast — all 4 tests pass including new thread-safety test
  • Coverage properly collected and reported (23% with fast tests, threshold set to 20%)
  • Pre-commit hooks pass (large files, fmt, ruff)

🤖 Generated with Claude Code

Miyamura80 and others added 7 commits January 24, 2026 14:14
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
- Expand ruff rules with B, C4, SIM and fix all violations
- Extract _identify_provider() helper to deduplicate model matching
- Narrow exception catches in dspy_inference and dspy_langfuse
- Add thread-safe logging initialization with double-checked locking
- Fix Python version in ruff workflow to read from .python-version
- Add ruff-check hook to pre-commit config
- Enable pytest coverage collection with --cov flags
- Remove utils/llm from coverage omit list

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@greptile-apps
Copy link

greptile-apps bot commented Jan 24, 2026

Greptile Overview

Greptile Summary

This PR systematically improves code quality and CI/CD infrastructure. Expands ruff linting with bugbear (B), comprehensions (C4), and simplify (SIM) rules and fixes all resulting violations including proper exception chaining (B904), narrowing bare exception catches, and simplifying dict/isinstance usage. Extracts _identify_provider() helper in common/global_config.py to eliminate duplicated provider detection logic. Adds thread-safe logging initialization using double-checked locking pattern with comprehensive test coverage. Improves CI/CD by splitting test targets (fast/slow/nondeterministic), dynamically reading Python version from .python-version file, and adding pre-commit ruff checks. Enables pytest coverage collection that was previously a no-op and measures LLM utility coverage.

  • Thread-safe logging with threading.Lock() and double-checked locking pattern in src/utils/logging_config.py:148-150
  • New _identify_provider() helper deduplicates model name regex matching in common/global_config.py:226-239
  • Exception chaining with from e added to all caught exceptions (B904)
  • Narrowed exception catches from bare Exception to specific types in utils/llm/dspy_inference.py:80 and utils/llm/dspy_langfuse.py:232
  • Coverage now properly collected with --cov=src --cov=common --cov=utils in pytest.ini:6
  • Test targets split into test_fast, test_slow, test_nondeterministic for better CI organization

Confidence Score: 5/5

  • Safe to merge with high confidence - all changes are code quality improvements with proper test coverage
  • All changes improve code quality through linting fixes, proper exception handling, thread safety, and better test organization. The thread-safety implementation uses standard double-checked locking pattern with comprehensive test coverage. Exception handling improvements follow best practices. CI/CD enhancements are well-structured.
  • No files require special attention

Important Files Changed

Filename Overview
common/global_config.py Added _identify_provider() helper to deduplicate provider detection, added from e to exception chains (B904), added stacklevel=2 to warnings.warn (B028)
pyproject.toml Expanded ruff rules with B (bugbear), C4 (comprehensions), SIM (simplify), removed utils/llm/** from coverage omit
pytest.ini Added coverage collection with --cov=src --cov=common --cov=utils, lowered threshold to 20%
src/utils/logging_config.py Added thread-safe logging initialization with threading.Lock() and double-checked locking pattern
tests/test_logging_thread_safety.py New test verifying concurrent setup_logging() calls only initialize logging once
utils/llm/dspy_inference.py Narrowed exception catch from bare Exception to specific types (RuntimeError, ValueError, TypeError)
utils/llm/dspy_langfuse.py Replaced dict comprehension with dict() call (C416), narrowed exception catches, simplified isinstance check with tuple (SIM114)

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