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

Upgrade dependencies #216

Merged
merged 4 commits into from
Jan 15, 2024
Merged

Conversation

iaindillingham
Copy link
Member

This PR upgrades all dev and prod dependencies in one go 💥. As a consequence, we make two changes to the codebase:

  • Django 5.0 removed the django.utils.timezone.utc alias to datetime.timezone.utc (release notes), so we replace it.

  • Several settings are deprecated, so we take the opportunity to replace them with the STORAGES and DJANGO_VITE settings.

Eventually, we'll replace the black, flake8, and isort hooks in .pre-commit-config to reflect opensafely-core/repo-template. However, we'll do that in a separate PR.

Having merged and released this PR, I plan to close the open Dependabot alerts, get Dependabot working again, and watch the repo.

This commit upgrades all dev and prod dependencies in one go. As a
consequence, we make two changes to the codebase:

* Django 5.0 removed the `django.utils.timezone.utc` alias to
  `datetime.timezone.utc` ([release notes][1]), so we replace it.

* Several settings are deprecated, so we take the opportunity to replace
  them with the `STORAGES` and `DJANGO_VITE` settings.

Eventually, we'll replace the black, flake8, and isort hooks in
`.pre-commit-config` to reflect opensafely-core/repo-template. However,
we'll do that in a separate PR.

[1]: https://docs.djangoproject.com/en/5.0/releases/5.0/
We don't need it, because `BASE_DIR` is a `pathlib.Path`.
Eventually, we'll replace flake8. For now, though, we need to update its
config so `just check` doesn't fail.
Copy link
Contributor

@rebkwok rebkwok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits, feel free to ignore

@@ -4,7 +4,6 @@


class Migration(migrations.Migration):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be inclined to skip migrations in the linters, since they're mostly autogenerated by Django, and django includes this empty line. Then again, it'll be auto-fixed from now on for any new migrations, so it's not really an issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your comment. I think I'm going to format migrations, as that means pyproject.toml is shorter. I've seen a couple of comments about Django 5.0 formatting migrations, but couldn't find anything in the release notes.

from datetime import datetime

from django.utils import timezone
from datetime import datetime, timezone
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: in other projects I usually import the datetime timezone with an alias (e.g.from datetime import timezone as dt_timezone), because it's quite common to also need to use things from django.utils.timezone (timezone.now, particularly).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again. My aim was to touch the codebase as little as possible, so I'm not going to use an alias now. However, I may use an alias later.

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