Aug 3, 2023·edited Aug 3, 2023Liked by Laszlo Sragner
So very close to how I set things up. I hadn't really considered extending line-length from 88...but I might, now! Lots of little things I hadn't seen, like half the ruff configs.
A few things I do differently:
- install all those tools with `--group dev`; I don't want pytest, ruff etc. in production builds, even if they don't add much
- with pre-commit in the environment, you don't need `poetry run` in the commit-hooks
- does your ruff hook work as intended? does the hook fail if it finds an error it can't autofix? I ended up needing `ruff check --force-exclude --fix --exit-non-zero-on-fix` as well as `require_serial: true` though I can't remember why I needed force-exclude or require_serial
- let unittest stay dead. I still use classes with pytest, but I don't need to inherit a special class, and I can use plan `assert`s instead of the weird unittest functions
It's definitely not tied down to the last bits so all suggestions are welcome. My intention was to create a 15 min version when people can bootstrap and then have these kind of conversations.
`--group dev` is a good idea. I am terrible managing these different environments
> though I can't remember why I needed force-exclude or require_serial
That's exactly me feeling about these tools as well. You read 10 SO posts and fiddle until it works and immediately forgot why you did it and lose the links to the references...
So very close to how I set things up. I hadn't really considered extending line-length from 88...but I might, now! Lots of little things I hadn't seen, like half the ruff configs.
A few things I do differently:
- install all those tools with `--group dev`; I don't want pytest, ruff etc. in production builds, even if they don't add much
- with pre-commit in the environment, you don't need `poetry run` in the commit-hooks
- does your ruff hook work as intended? does the hook fail if it finds an error it can't autofix? I ended up needing `ruff check --force-exclude --fix --exit-non-zero-on-fix` as well as `require_serial: true` though I can't remember why I needed force-exclude or require_serial
- let unittest stay dead. I still use classes with pytest, but I don't need to inherit a special class, and I can use plan `assert`s instead of the weird unittest functions
Good comments. Ruff settings are from FastAPI.
It's definitely not tied down to the last bits so all suggestions are welcome. My intention was to create a 15 min version when people can bootstrap and then have these kind of conversations.
`--group dev` is a good idea. I am terrible managing these different environments
> though I can't remember why I needed force-exclude or require_serial
That's exactly me feeling about these tools as well. You read 10 SO posts and fiddle until it works and immediately forgot why you did it and lose the links to the references...
You can replace "black" with "ruff-format", as it's built in to ruff (can configure in pyproject.toml):
https://docs.astral.sh/ruff/formatter/#black-compatibility
Then you can replace the black pre-commit hook with this one:
```
- id: ruff-format
```
Thanks for your comment. Indeed, ruff will replace black entirely. It also has a VSCode plugin.
The Python dev stack is simplifying!
I'd keep mentioning black for backreference as many people will hear about it elsewhere.