Jainish1808 commited on
Commit
eac9fcd
·
1 Parent(s): 59274a4

Fix bool env whitespace parsing and ignore venv dirs

Browse files
Files changed (3) hide show
  1. .gitignore +3 -0
  2. config/settings.py +16 -0
  3. tests/config/test_config.py +10 -0
.gitignore CHANGED
@@ -5,6 +5,9 @@ __pycache__
5
  .ruff_cache
6
  .serena
7
  .venv
 
 
 
8
  agent_workspace
9
  .env
10
  server.log
 
5
  .ruff_cache
6
  .serena
7
  .venv
8
+ .venv/
9
+ venv/
10
+ env/
11
  agent_workspace
12
  .env
13
  server.log
config/settings.py CHANGED
@@ -145,6 +145,22 @@ class Settings(BaseSettings):
145
  return None
146
  return v
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  @field_validator("whisper_device")
149
  @classmethod
150
  def validate_whisper_device(cls, v: str) -> str:
 
145
  return None
146
  return v
147
 
148
+ @field_validator(
149
+ "fast_prefix_detection",
150
+ "enable_network_probe_mock",
151
+ "enable_title_generation_skip",
152
+ "enable_suggestion_mode_skip",
153
+ "enable_filepath_extraction_mock",
154
+ "nim_enable_thinking",
155
+ "voice_note_enabled",
156
+ mode="before",
157
+ )
158
+ @classmethod
159
+ def normalize_bool_env_values(cls, v):
160
+ if isinstance(v, str):
161
+ return v.strip()
162
+ return v
163
+
164
  @field_validator("whisper_device")
165
  @classmethod
166
  def validate_whisper_device(cls, v: str) -> str:
tests/config/test_config.py CHANGED
@@ -298,6 +298,16 @@ class TestSettingsOptionalStr:
298
  s = Settings()
299
  assert s.whisper_device == device
300
 
 
 
 
 
 
 
 
 
 
 
301
 
302
  class TestPerModelMapping:
303
  """Test per-model fields and resolve_model()."""
 
298
  s = Settings()
299
  assert s.whisper_device == device
300
 
301
+ def test_bool_env_with_trailing_newline(self, monkeypatch):
302
+ """Boolean env values with whitespace/newlines are parsed correctly."""
303
+ from config.settings import Settings
304
+
305
+ monkeypatch.setenv("ENABLE_NETWORK_PROBE_MOCK", "true\n")
306
+ monkeypatch.setenv("ENABLE_TITLE_GENERATION_SKIP", " false ")
307
+ s = Settings()
308
+ assert s.enable_network_probe_mock is True
309
+ assert s.enable_title_generation_skip is False
310
+
311
 
312
  class TestPerModelMapping:
313
  """Test per-model fields and resolve_model()."""