-
Notifications
You must be signed in to change notification settings - Fork 44
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
Support Django 5.0 and Python 3.12 #74
Conversation
python-version: | ||
- "3.8" | ||
- "3.9" | ||
django-version: | ||
- "3.2" | ||
- "4.0" | ||
- "4.1" | ||
- "4.2" | ||
- "3.10" | ||
- "3.11" | ||
- "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.
I’ve moved the GitHub setup to only use a per-Python matrix, using tox to run the relevant environments per version. This is what I use on my ~30 open source projects and it works really well. It requires less maintenance and is actually faster than splitting per Django version unless you have a long test suite.
.github/workflows/tests.yml
Outdated
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pyyaml coveralls pytest-django django==${{ matrix.django-version }}.* | ||
pip install -e . | ||
pip install flake8 | ||
|
||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
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.
flake8 could be split into a separate job but for now I left it on each environment.
|
||
* Added support for Python 3.12. | ||
|
||
* Dropped the `VERSION` and `__version__` attributes. To check the version of the package, use `importlib.metadata.version("django-typed-models")` ([docs](https://docs.python.org/3/library/importlib.metadata.html#distribution-versions) / |
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.
pkg_resources
is gone from Python 3.12, so it’s necessary to at least change this. I think it’s best to drop the version attributes and recommend using the new method in the standard library, importlib.metadata.version()
. Loading the version proactively slows down startup unnecessarily for the 99% of cases where it’s not used.
include_hidden, | ||
seen_models is None, | ||
) | ||
if django.VERSION >= (5, 0): |
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.
Change necessary due to the change in signature of Model._meta._get_fields
. It seems the simplest to have two versions split by version. If you use django-upgrade it can automatically drop the versioned block when you stop supporting Django < 5.0: https://github.com/adamchainz/django-upgrade/#versioned-blocks
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.
looks good, thanks! CI failing because tox isn't there so probably we need to install it in github actions?
It works nicely locally 💯 Good tip about tox -f
; I hadn't seen that before.
Pushed a commit earlier, seems good now. |
thanks! |
released in 0.14.0 👍 |
No description provided.