Skip to content

avoid side effects of checking app module existing#5480

Merged
adhami3310 merged 1 commit into
mainfrom
khaleel/eng-6378-internal-usage-of-find_spec-results-in-unexpected-import-of
Jun 23, 2025
Merged

avoid side effects of checking app module existing#5480
adhami3310 merged 1 commit into
mainfrom
khaleel/eng-6378-internal-usage-of-find_spec-results-in-unexpected-import-of

Conversation

@adhami3310
Copy link
Copy Markdown
Member

No description provided.

@linear
Copy link
Copy Markdown

linear Bot commented Jun 20, 2025

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 improves module path detection by replacing importlib.util.find_spec() with a safer custom implementation to prevent unintended module imports during path inspection.

  • Added new get_module_path() in reflex/utils/misc.py that safely checks module existence without side effects
  • Refactored get_app_file() and get_reload_paths() in reflex/utils/exec.py to use the new helper function
  • Removed unnecessary origin path validation in reflex/utils/prerequisites.py for more robust module path handling

3 files reviewed, 1 comment
Edit PR Review Bot Settings | Greptile

Comment thread reflex/utils/misc.py
Comment on lines +46 to +48
else:
return current_path / "__init__.py" # Made it through all parts

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: The else clause will only trigger if the loop completes without a break, meaning we found all parts as directories. However, we need to check if the final path actually exists before returning.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jun 20, 2025

CodSpeed Performance Report

Merging #5480 will not alter performance

Comparing khaleel/eng-6378-internal-usage-of-find_spec-results-in-unexpected-import-of (68a6e7c) with main (6a29fbf)

Summary

✅ 8 untouched benchmarks

@adhami3310 adhami3310 merged commit 670c69f into main Jun 23, 2025
41 checks passed
@adhami3310 adhami3310 deleted the khaleel/eng-6378-internal-usage-of-find_spec-results-in-unexpected-import-of branch June 23, 2025 20:37
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.

Internal usage of find_spec results in unexpected import of parent packages

2 participants