-
Notifications
You must be signed in to change notification settings - Fork 2
test on current python/django versions, linter config #90
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
Conversation
ruff format . | ||
ruff format . --check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running ruff format .
in CI isn't really helpful because ruff exits with code 0 even if it changes files, so if files need reformatting, ruff format .
will just change them and not fail the build.
In CI we need to run ruff format . --check
which will exit with code 1 if filed need reformatting.
[tool.ruff] | ||
line-length = 80 | ||
lint.ignore = ["E501"] | ||
lint.extend-select = [ | ||
"I", | ||
"C4", | ||
"SIM", | ||
"Q003", | ||
"RET", | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the standard config we should be using
See https://docs.google.com/document/d/1Sb_m86KG5ca0lOZMgtJZwch32eVfA0syAY9MeIW1Ljk/edit#heading=h.gnuw7hn63sl7
Note that adding the config here is the reason we now have a load of new errors that need fixing (mostly import sorting)
name: Curly Lint | ||
command: | | ||
curlylint . | ||
git ls-files '*.html' | xargs djhtml --check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as DemocracyClub/EveryElection#2210 (comment) here for the same reasons
mock_render.called_once_with( | ||
mock_render.assert_called_once_with( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This never did anything because called_once_with
isn't a function. Same with the other similar line in this file.
This was not a visible error when running the tests under python 3.10, but python 3.12 introduces a check for this. Related reading:
py38: | ||
docker: | ||
- image: cimg/python:3.8 | ||
py39: | ||
docker: | ||
- image: cimg/python:3.9 | ||
py310: | ||
docker: | ||
- image: cimg/python:3.10 | ||
py312: | ||
docker: | ||
- image: cimg/python:3.12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything we care about/where we consume this package should be running python 3.10 or 3.12 now.
We don't need to keep testing for python 3.8/3.9 compatibility.
django_version: [ ">=3.2,<4.0", ">=4.0,<4.1", ">=4.1,<4.2" ] | ||
python_version: [ py310, py312 ] | ||
django_version: [ ">=4.2,<4.3", ">=5.1,<5.2" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything we care about/where we consume this package should now be running Django 4.2.x. We can drop compatibility testing for everything older than that.
I've also added testing on Django 5.1.x so we're flagging any compatibility issues we are likely to encounter when upgrading to Django 5.2.x after the May 2025 elections.
@@ -6,7 +6,7 @@ readme = "README.md" | |||
authors = [{name = "Sym Roe"}, {name = "Virginia Dooley"}] | |||
|
|||
dependencies = [ | |||
"django>=3.2,<4.3", | |||
"django>=4.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, unless we know we're relying on something we know will break in a future release, I'd tend to avoid upper-bound version constraints for python packages.
TODO: once this is approved, cut a release after merging |
I tested this by installing it locally in Website. Is the plan to remove |
Chris and I had a chat about this and he explained more about how |
This PR continues the wider platform and version upgrades work I am looking at across DC repos.
Key topics on this one are bumping to current/applicable python/django versions and bringing linter setup into line with other DC projects.
Commit log should be pretty descriptive for this one. I will also leave some comments inline on the diff with a bit of further explanation.