@@ -24,7 +24,7 @@ The trick is:
2424
25251 . Have each step run one script that has a good name, so they're documented
2626 by that script and its name, and can be run without ` make ` - like from
27- your editor or whatever. I keep mine in ` ./build / ` . The reason for having
27+ your editor or whatever. I keep mine in ` ./scripts / ` . The reason for having
2828 them as separate scripts is because you might want to bypass dependencies
2929 in a CI pipeline.
30302 . Have the dependencies for the step be the script itself plus one file
@@ -47,9 +47,15 @@ I like `flake8` for linting because it's not as harsh as `pylint`, and is
4747supported by my IDE of choice.
4848
4949Part of the ` make dev ` setup installs ` pre-commit ` , which will make sure that
50- commits are up to a certain standard. The provided config file runs code
50+ commits are up to a certain standard. The provided config file runs the code
5151formatters, linters and a few other checks. Have a look at
52- ` .pre-commit-config.yaml ` to see what's going on in there.
52+ ` .pre-commit-config.yaml ` to see what's going on in there. pre-commit is very
53+ slow and very annoying, but it forces code quality on us which makes up for the
54+ inconvenience.
55+
56+ See the ` .flake8 ` config for some ignored rules where flake8 and black get into
57+ a fight, and there's ` isort ` and ` black ` conflict rules in the pre-commit
58+ config too.
5359
5460### IDE
5561
@@ -62,6 +68,9 @@ belong to the project, so it's appropriate to put them in source control.
6268The config also provides recommendations for extensions, which you'll be
6369prompted to install when you open the project for the first time.
6470
71+ I could (and sometimes do) go one step further and use devcontainers, but at
72+ time of writing it's still a bit fiddly to get set up.
73+
6574### Package layout
6675
6776Under the ` example_package ` dir there's a ` pyproject.toml ` that defines the
@@ -71,19 +80,43 @@ the code and tests.
7180The layout is as-per the pypi packaging guidelines. When referencing stuff in
7281the code I tend to use the full ` package.module ` names because otherwise imports
7382tend to break in weird ways in different environments, and it means I can
74- reference stuff in parent directories without ripping my hair out.
83+ reference stuff in parent directories without ripping my hair out. It makes the
84+ imports look a bit Java-y but it's staying that way until implicit imports are
85+ removed from Python.
7586
7687### Testing
7788
78- I use ` pytest ` and write tests in a functional style, and develop using TDD.
79- If you get into the habit of actually running a new piece of code from a new
80- unit test then you'll find yourself writing testable code. Tests are
89+ I use ` pytest ` and write tests in a functional style, and develop largely using
90+ TDD. If you get into the habit of actually running a new piece of code from a
91+ new unit test then you'll find yourself writing testable code. Tests are
8192fundamentally just other pieces of code, so if a function is difficult to test
82- then it's probably difficult to reuse too.
93+ then it's probably difficult to reuse too. But it doesn't work all the time;
94+ testing filesystem interactions and external services have a heavy
95+ test-development overhead, which hinders rather than helps refactoring efforts;
96+ your mileage may vary.
97+
98+ Run ` make coverage ` for a test coverage report.
99+
100+ ### CI and CD
101+
102+ There's a couple of workflows in the ` .github ` dir, one to run the unit tests
103+ and one to release the project to pypi. The first
104+
105+ The release process runs whenever you
106+ push tag changes to GitHub.
107+
108+ Before the release process will work you
109+ need to get a key from pypi and add
110+
111+ there's a couple of workflows, one that runs the
112+ ` make test ` any time a commit is pushed. This
113+
114+ ### Documentation
83115
84- Run ` make coverage ` for a test coverage report. I like to keep my coverage at
85- 100%. Not sure if that's a taste thing or a side-effect of the way I'm
86- developing, but I like it.
116+ You'll see a ` mkdocs ` config in the root. This is combined with the ` make docs `
117+ script to make the github pages documentation for the project. If you look at
118+ this README.md file you'll see it's actually a symlink to the one in the package
119+ dir, and it's also symlinked from
87120
88121## Some opinionated stuff
89122
0 commit comments