-
Notifications
You must be signed in to change notification settings - Fork 79
fix(interface): prevent configure_logging from being silently overwritten #408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,7 +114,11 @@ def working() -> str: | |
| return random.choice(["⚙️", "🔧", "🔨", "⚒️", "🛠️", "💼", "👷", "🏗️", "🪛", "👨💻"]) | ||
|
|
||
|
|
||
| _configured = False | ||
|
|
||
|
|
||
| def configure_logging(config: LoggingConfig | None = None) -> None: | ||
| global _configured | ||
| config = config or LoggingConfig.default() | ||
|
|
||
| root_logger = logging.getLogger() | ||
|
|
@@ -137,6 +141,8 @@ def configure_logging(config: LoggingConfig | None = None) -> None: | |
| for name in config.to_silence: | ||
| quiet_noisy_logger(name) | ||
|
|
||
| _configured = True | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
After In practice this doesn't cause a functional bug because the Consider documenting this clearly, or renaming the flag to Prompt To Fix With AINote: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
|
|
||
|
|
||
| def quiet_noisy_logger(name: str) -> None: | ||
| logger = logging.getLogger(name) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,14 @@ | |
| quiet_noisy_logger, | ||
| ) | ||
|
|
||
| import data_designer.logging as _logging_mod | ||
|
|
||
| @pytest.fixture(autouse=True) | ||
| def reset_configured_flag(): | ||
| original = _logging_mod._configured | ||
| yield | ||
| _logging_mod._configured = original | ||
|
Comment on lines
+22
to
+26
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The fixture captures the current value of If the module is imported in a process where Adding an explicit reset to Prompt To Fix With AI |
||
|
|
||
|
|
||
| @pytest.fixture | ||
| def stub_default_logging_config(): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing blank line before top-level function (PEP 8)
PEP 8 requires two blank lines between top-level definitions. Currently only one blank line separates
_configured = Falsefromdef configure_logging(...).Prompt To Fix With AI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!