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

Remove black and isort dependencies #92

Merged
merged 23 commits into from
Mar 19, 2024
Merged

Conversation

mcflugen
Copy link
Member

My goal with this pull request is to remove the black and isort dependencies of the babelizer. Although they serve an important purpose in that they produce reproducible builds and remove lint that might be generated by the jinja templates (e.g. trailing whitespace), they add a couple extra dependencies. Instead of using black and isort, I thought it would be better if we ensure the babelizer generates well formatted code all by itself.

To this end, I attempted to modify the jinja templates but that quickly resulted in complex and difficult to read template files (I don't think I ever got them to work just right, anyway). Instead, I've added a new module, _render_files.py that renders some of the project's files with Python and then the template files just include the generated file contents. The Python code is much easier to read and to maintain than the equivalent jinja code.

To ensure that the resulting files are formatted correctly (at least for black and isort) I've added tests that run black and isort over the generated projects, returning an error if anything needs modifying.

@mcflugen
Copy link
Member Author

@mdpiper What do you think of these changes? I like removing dependencies but does this make things easier or more difficult to follow? I felt that some of our jinja templates were becoming overly complicated.

@mdpiper
Copy link
Member

mdpiper commented Mar 15, 2024

@mcflugen I think it's a good idea! As much as I enjoy templating, the files were getting thick with jinja code, making them hard to read.

@mcflugen
Copy link
Member Author

@mdpiper I've added a few more sub-commands to babelize that, like babelize sample-config, generate individual files rather than an entire project. I don't think they contribute much to the babelizer but they were easy to add and are things we may want to use as standalone commands.

  • babelize sample-gitignore: print an example .gitignore file
  • babelize sample-license: print an example license.rst file
  • babelize sample-meson-build: print an example meson.build file

I can imagine using these commands not so much with the babelizer but when creating new projects (or, in the case of babelize sample-meson-build, when converting setuptools projects to meson projects).

@mdpiper
Copy link
Member

mdpiper commented Mar 18, 2024

@mcflugen I think these are great!

I think it would be neat to use this technique to make the bind-c layer for a Fortran component.

@mcflugen mcflugen merged commit d4800a1 into develop Mar 19, 2024
37 checks passed
@mcflugen mcflugen deleted the mcflugen/remove-prettier branch March 19, 2024 19:22
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.

2 participants