Skip to content
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

Add reflex init app name validator, prevent import failure during reflex run #2336

Merged

Conversation

Jishnu-Nandhiath
Copy link
Contributor

@Jishnu-Nandhiath Jishnu-Nandhiath commented Dec 25, 2023

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)

New Feature Submission:

  • Does your submission pass the tests?
  • Have you linted your code locally prior to submission?

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?

Issue: improper app directory name passed during reflex init will cause reflex run to fail, if the name is not according to python package naming conventions.

Run the below command to recreate the issue,
reflex init --name="123" --template="sidebar"
and try running reflex run.

We get the following error.

from 123 import styles
         ^
SyntaxError: invalid syntax

This issue can also occur if reflex init is run inside a folder with similar improper app directory naming.

I've refactored get_default_app_name() of reflex init, and added a regex validator to check the app_name passed to the function, to ensure proper directory naming. Else it displays a console error, with proper message.

Copy link
Contributor

@picklelo picklelo left a comment

Choose a reason for hiding this comment

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

thanks for adding!

@picklelo picklelo merged commit c5c4266 into reflex-dev:main Dec 28, 2023
42 of 45 checks passed
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.

None yet

2 participants