Skip to content

move environment into its own file#5403

Merged
adhami3310 merged 1 commit intomainfrom
move-environment-into-its-own-file
Jun 2, 2025
Merged

move environment into its own file#5403
adhami3310 merged 1 commit intomainfrom
move-environment-into-its-own-file

Conversation

@adhami3310
Copy link
Copy Markdown
Member

No description provided.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Jun 2, 2025

CodSpeed Performance Report

Merging #5403 will not alter performance

Comparing move-environment-into-its-own-file (df97d42) with main (6bf6f6f)

Summary

✅ 8 untouched benchmarks

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR moves environment-related code from reflex.config into a dedicated reflex.environment module, improving code organization and maintainability. The changes primarily involve updating import statements across multiple files while preserving existing functionality.

  • Created new reflex/environment.py with centralized environment variable management, including type-safe EnvVar class and comprehensive EnvironmentVariables class
  • Removed environment code from reflex.config.py and updated all imports across codebase to use new reflex.environment module
  • Added proper type hints and validation for environment variables with support for boolean, integer, path, and enum types
  • Maintained backward compatibility while improving code organization by isolating environment concerns

💡 (4/5) You can add custom instructions or style guidelines for the bot here!

29 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

Comment thread reflex/environment.py
Comment on lines +183 to +190
return [
interpret_env_var_value(
v,
get_args(field_type)[0],
f"{field_name}[{i}]",
)
for i, v in enumerate(value.split(":"))
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: List parsing should handle empty strings and whitespace in split values

Suggested change
return [
interpret_env_var_value(
v,
get_args(field_type)[0],
f"{field_name}[{i}]",
)
for i, v in enumerate(value.split(":"))
]
return [
interpret_env_var_value(
v.strip(),
get_args(field_type)[0],
f"{field_name}[{i}]",
)
for i, v in enumerate(value.split(":"))
if v.strip()
]

Comment thread reflex/environment.py
Comment on lines +237 to +239
env_value = os.getenv(self.name, None)
if env_value and env_value.strip():
return self.interpret(env_value)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Strip should be applied before checking if env_value exists to handle whitespace-only strings

Suggested change
env_value = os.getenv(self.name, None)
if env_value and env_value.strip():
return self.interpret(env_value)
env_value = os.getenv(self.name, None)
if env_value := (env_value.strip() if env_value else None):
return self.interpret(env_value)

@adhami3310 adhami3310 merged commit 13bedad into main Jun 2, 2025
42 checks passed
@adhami3310 adhami3310 deleted the move-environment-into-its-own-file branch June 2, 2025 20:11
adhami3310 added a commit that referenced this pull request Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants