-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Improve pre gen project.py #4885
base: master
Are you sure you want to change the base?
Improve pre gen project.py #4885
Conversation
Used a variable (expected_content) for the expected content of the gitignore file to enhance readability. Ensured consistent newlines (os.linesep) in the expected content. Separated the import statements to make them clearer. Added more whitespace for better readability.
I created separate functions (check_project_slug, check_author_name, etc.) to encapsulate specific checks. This makes the code more modular and readable. Function Parameters: I modified the functions to take parameters instead of using global variables directly. This enhances reusability and makes the functions more flexible. Input Function: I replaced raw_input() with input() to ensure compatibility with both Python 2 and 3, as the input() function serves the same purpose in Python 3. Encapsulation of Main Checks: The main logic for checking project_slug, author_name, Python version, Whitenoise, and mail service is now encapsulated within the __main__ block. This improves code organization and readability. Readability and Clarity: Variable names are more descriptive, improving the readability of the code. Consistent Formatting: I ensured consistent formatting and adhered to PEP 8 conventions for better style and consistency.
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed
What do you mean with this? Can you look into the failing tests? In general I like your changes to Your changes to Also I would like to see a single commit for a change like this but we can always squash the commits when merging. |
# The content of this string is evaluated by Jinja, and plays an important role. | ||
# It updates the cookiecutter context to trim leading and trailing spaces | ||
# from domain/email values | ||
""" | ||
{{ cookiecutter.update({ "domain_name": cookiecutter.domain_name | trim }) }} | ||
{{ cookiecutter.update({ "email": cookiecutter.email | trim }) }} | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to stay here (as per the comment)
Function Extraction:
I created separate functions (check_project_slug, check_author_name, etc.) to encapsulate specific checks. This makes the code more modular and readable.
Function Parameters:
I modified the functions to take parameters instead of using global variables directly. This enhances reusability and makes the functions more flexible.
Input Function:
I replaced raw_input() with input() to ensure compatibility with both Python 2 and 3, as the input() function serves the same purpose in Python 3.
Encapsulation of Main Checks:
The main logic for checking project_slug, author_name, Python version, Whitenoise, and mail service is now encapsulated within the main block. This improves code organization and readability.
Readability and Clarity:
Variable names are more descriptive, improving the readability of the code.
Consistent Formatting:
I ensured consistent formatting and adhered to PEP 8 conventions for better style and consistency.