fix(environment): split hot reload path lists on os.pathsep
All Submissions:
- Have you followed the guidelines stated in CONTRIBUTING.md file?
- Have you checked to ensure there aren't any other open Pull Requests for the desired changed?
Type of change
- Bug fix (non-breaking change which fixes an issue)
Changes To Core Features:
- Have you added an explanation of what your changes do and why you'd like us to include them?
- Have you written new tests for your core changes, as applicable?
- Have you successfully ran tests with your changes locally?
Description
REFLEX_HOT_RELOAD_INCLUDE_PATHS, REFLEX_HOT_RELOAD_EXCLUDE_PATHS and REFLEX_HOT_RELOAD_OVERRIDE_PATHS are list[Path] values split on :, so on Windows an absolute path is cut at its drive letter. There is no existing issue for this. It was found by reading environment.py and reproduced on Windows.
get_reload_paths() with REFLEX_HOT_RELOAD_OVERRIDE_PATHS set on Windows:
| Value | Before | After |
|---|---|---|
D:\work\shared | <cwd>\D, C:\work\shared | D:\work\shared |
C:\work\a;D:\work\b | <cwd>\C, C:\work\a;D, C:\work\b | C:\work\a, D:\work\b |
Path lists without their own SequenceOptions now use os.pathsep, the same separator REFLEX_ENV_FILE uses. EnvVar.set joins with the same delimiter, because it had ":" hard-coded and would otherwise write a value the interpreter cannot read back.
Nothing changes on Linux and macOS, where os.pathsep is :. Other list types still split on :.
One behavior change on Windows: relative paths listed as src:lib were split before and need src;lib now. The news fragment says so.
Testing
The new tests in tests/units/test_environment.py patch os.pathsep to ;, so they check the Windows behavior on every platform. test_path_list_env_value_splits_on_pathsep and test_path_list_env_var_round_trips_through_set fail on main and pass here, on Windows and Linux. The other two tests pin what must not change: an explicit SequenceOptions delimiter and non-path lists.