Fix test_mode string evaluation in BaseMixin#1529
Draft
Conversation
- Changed _test_mode property to use spyglass.settings.config.test_mode instead of reading directly from dj.config - This ensures proper string-to-boolean conversion via str_to_bool() function - Added test to verify _test_mode property returns boolean value - Added comprehensive unit test for str_to_bool function Fixes #1528 Co-authored-by: samuelbray32 <24991442+samuelbray32@users.noreply.github.com>
Changed docstring to reference exact module path 'spyglass.settings.config.test_mode' instead of 'SpyglassConfig.test_mode' Co-authored-by: samuelbray32 <24991442+samuelbray32@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix test mode evaluation for string value in BaseMixin
Fix test_mode string evaluation in BaseMixin
Feb 13, 2026
CBroz1
reviewed
Feb 19, 2026
CBroz1
reviewed
Feb 19, 2026
src/spyglass/utils/mixins/base.py
Outdated
| # Check dj.config directly instead of importing module-level variable | ||
| # which gets stale if load_config() is called after initial import | ||
| return dj.config.get("custom", {}).get("test_mode", False) | ||
| return sg_config.test_mode |
Member
There was a problem hiding this comment.
Is this config a dictionary? I think this needs...
Suggested change
| return sg_config.test_mode | |
| return sg_config.get('test_mode', False) |
Collaborator
There was a problem hiding this comment.
Switched it to just import test_mode directly
CBroz1
added a commit
to CBroz1/spyglass
that referenced
this pull request
Feb 19, 2026
samuelbray32
approved these changes
Feb 25, 2026
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.
Description
String
"false"indj.config["custom"]["test_mode"]evaluated asTruebecauseBaseMixin._test_modereturned raw values without type conversion. Any non-empty string is truthy in Python.Changes:
src/spyglass/utils/mixins/base.py: Changed_test_modeproperty to usespyglass.settings.config.test_modeinstead of directly readingdj.config. This ensures string-to-boolean conversion via existingstr_to_bool().tests/utils/test_dj_helper_fn.py: Addedtest_str_to_bool()covering truthy/falsy strings and edge cases.tests/utils/test_mixin.py: Addedtest_test_mode_property_uses_settings()to verify boolean return type.Before:
After:
Checklist:
CITATION.cffaltersnippet for release notes.CHANGELOG.mdwith PR number and description.Original prompt
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.