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

Improve pre gen project.py #4885

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Collins-Webdev
Copy link

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.

Collins-Webdev and others added 3 commits February 22, 2024 09:53
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.
Copy link
Author

@Collins-Webdev Collins-Webdev left a comment

Choose a reason for hiding this comment

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

Reviewed

@foarsitter
Copy link
Collaborator

Reviewed

What do you mean with this? Can you look into the failing tests?

In general I like your changes to hooks/pre_gen_project.py. I would like to go one step further and remove the whole python 2 code block.

Your changes to tests/test_hooks.py are of little value and, in my opinion, not worth cluttering the git history.

Also I would like to see a single commit for a change like this but we can always squash the commits when merging.

Comment on lines -21 to -27
# 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 }) }}
"""
Copy link
Member

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)

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

3 participants