nedbat / cog

Small bits of Python computation for static files
MIT License
339 stars 26 forks source link

Source code modernization #32

Open vergenzt opened 4 months ago

vergenzt commented 4 months ago

Hi @nedbat! I've been thinking about a few suggestions / requests for this app, but you've mentioned in a few places that the code style is pretty archaic. I'm interested in helping to modernize it. I'm gonna put my tentative todo list here -- obviously :+1:'ing or :-1:'ing each PR will be up to you, but if you're up for weighing in here that'd be helpful.

nedbat commented 4 months ago

I have no objections to those changes, I just don't feel much need to make them. I don't use pre-commit hooks, but if we add the ruff checks to CI also, then we can stay in-synch.

For the formatting changes, we should add a .git-blame-ignore-revs file also so that git blame won't get distracted by them.

What substantive changes were you thinking of making? I'd hate for you to put in this work and then for us to disagree on your eventual goal.

vergenzt commented 4 months ago

Didn't have much specifics in mind. Mostly was just bored and love this tool and wanted to unblock some previous requests you've mentioned. E.g. 5 years ago you mentioned the coding style is "really archaic". 😆

I think some things I would love to do include:

  1. Add long option equivalents for some of the short options currently available. (I prefer to use long options in source controlled scripts for readability's sake.)
  2. I think my biggest long term goal would be https://github.com/nedbat/cog/issues/17#issuecomment-1919632924

    I'm currently interested in creating an offshoot of this package called cogshell (where the code snippets are shell code instead of Python 🙂). I would love to use this package's code as the processing engine, but it needs a bit of refactoring for that to work.

    I've had the thought that maybe there's a world in which that mode of evaluation could possibly live within this cog package as an option flag? Or maybe a different opening marker? I'm not sure. 🤷 I think if it ends up being an offshoot package that's fine too though -- in either case I think cleaning this package up to be able to inherit & override specific parts would be more productive than rewriting the core logic from scratch in an offshoot package.

I'll harbor no expectations that you'll approve a future changes just because you approve an earlier one. 🙂

vergenzt commented 4 months ago

For the formatting changes, we should add a .git-blame-ignore-revs file also so that git blame won't get distracted by them.

This is totally awesome by the way. I had no idea this is a thing but I love it.