fpgmaas / cookiecutter-poetry

A modern cookiecutter template for Python projects that use Poetry for dependency management
https://fpgmaas.github.io/cookiecutter-poetry/
MIT License
358 stars 55 forks source link

Prettier Pre-commit Hooks #96

Open kenibrewer opened 11 months ago

kenibrewer commented 11 months ago

Is your feature request related to a problem? Please describe.

Docs diffs become much easier to maintain when there is an opinionated code formatter for the Markdown files such as Prettier. Prettier also allows opinionated formatting of other files relevant to python projects including YAML and JSON.

Describe the solution you would like

An ideal solution would consist of the following:

Additional context

If this feature is of interest, feel free to assign it to me for completion.

fpgmaas commented 11 months ago

This sounds good to me! The only challenge I foresee here is that currently, when running

pip install cookiecutter
cookiecutter https://github.com/fpgmaas/cookiecutter-poetry.git

the following commands will run successfully:

cd <project_name>
git init -b main
git add .
git commit -m "Init commit"
git remote add origin git@github.com:<github_author_handle>/<project_name>.git
git push -u origin main

and the CI/CD pipeline will run successfully. However, after introducing this pre-commit hook, the CI/CD pipeline will likely fail. The reason for this is that it is incredibly difficult to format all the files in the {{cookiecutter.project_name}} folder in exactly such a way that, whichever combination of argument a user gives, they are exactly in the format prettier would want. And even if we manage to do so, it is an unrealistic goal that we manage to keep it that way.

So we would maybe need to update the set of commands above to also run the pre commit hooks once before pushing.

If we can manage to find a clean solution to that, I am happy with this change!