Fix #70: don't call logging.basicConfig() at import#73
Closed
iskandr wants to merge 1 commit into
Closed
Conversation
attribute_parsing, create_missing_features and read_gtf each called
logging.basicConfig(level=logging.INFO) at import, which adds a handler to the
ROOT logger and sets the root level to INFO — hijacking downstream applications'
logging configuration and breaking pytest's caplog in their test suites.
Per the Python logging HOWTO ("Configuring Logging for a Library"), remove the
import-time basicConfig calls and attach a NullHandler to the top-level gtfparse
logger instead, so importing gtfparse is side-effect-free. Applications opt in
to gtfparse's INFO logs via their own logging configuration.
Claude-Session: https://claude.ai/code/session_01Nc9jzi2yp77EVa8yjN1mog
Coverage Report for CI Build 28965821496Coverage decreased (-0.02%) to 95.192%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions8 previously-covered lines in 3 files lost coverage.
Coverage Stats
💛 - Coveralls |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #70.
attribute_parsing.py,create_missing_features.py, andread_gtf.pyeach calllogging.basicConfig(level=logging.INFO)at module import. That mutates the root logger (adds a handler, sets the root level toINFO) as an import side effect, which hijacks a downstream application's logging configuration and breakspytest'scaplogin downstream test suites.Change
Per the Python logging HOWTO ("Configuring Logging for a Library"):
logging.basicConfig(...)calls (keep each module'slogger = logging.getLogger(__name__)).logging.NullHandler()to the top-levelgtfparselogger in__init__.py, so importing gtfparse emits nothing and reconfigures nothing by default. Applications opt in to gtfparse's INFO logs via their own logging config.Before / after
Tests
Full suite green (59 passed). No behavior change beyond logging side effects.