-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Refactor config management #516
base: main
Are you sure you want to change the base?
Conversation
Sandbox Executions
Run `tests/test_config.py` through the sandbox.
|
Apply Sweep Rules to your PR?
|
tests/test_config.py
Outdated
config.persist_env("TEST_VAR", "test_value", env_file) | ||
with open(env_file, "r") as f: | ||
lines = f.readlines() | ||
assert "TEST_VAR=test_value\n" in lines |
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.
assert "TEST_VAR=test_value\n" in lines | |
assert "TEST_VAR=test_value" in lines |
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.
🚀 Wrote Changes
Done.
tests/test_config.py
Outdated
|
||
def test_obfuscate(): | ||
assert config.obfuscate("test_value", 0.5, "*") == "*****value" | ||
assert config.obfuscate("another_test_value", 0.3, "#") == "#############t_value" |
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.
assert config.obfuscate("another_test_value", 0.3, "#") == "#############t_value" | |
assert config.obfuscate("another_test_value", 0.3, "#") == "#############value" |
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.
🚀 Wrote Changes
Done.
PR Feedback (click)
Description
This PR refactors the configuration management in the
config.py
file to improve code readability and reduce the need for linter pragmas.The changes include:
_DEFAULTS
dictionary with direct variable definitions..env
and saving defaults into separate functions.getenv_fallback
,persist_env
, andobfuscate
functions to work with the new configuration management approach.Summary of Changes
config.py
file to define configuration variables directly instead of using a dictionary..env
and saving defaults into separate functions.getenv_fallback
,persist_env
, andobfuscate
functions to work with the new configuration management approach.Please review and merge this PR. Thank you!
Fixes #485.
🎉 Latest improvements to Sweep:
rope
library to refactor Python! Check out Large Language Models are Bad at Refactoring Code. To have Sweep refactor your code, trysweep: Refactor <your_file>.py to be more modular
!💡 To get Sweep to edit this pull request, you can: