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

Support Django 5.0 and Python 3.12 #74

Merged
merged 2 commits into from
Oct 24, 2023
Merged

Conversation

adamchainz
Copy link
Contributor

No description provided.

Comment on lines 8 to +13
python-version:
- "3.8"
- "3.9"
django-version:
- "3.2"
- "4.0"
- "4.1"
- "4.2"
- "3.10"
- "3.11"
- "3.12"
Copy link
Contributor Author

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.

Comment on lines 23 to 30
- 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
Copy link
Contributor Author

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) /
Copy link
Contributor Author

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):
Copy link
Contributor Author

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

Copy link
Owner

@craigds craigds left a 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.

@adamchainz
Copy link
Contributor Author

Pushed a commit earlier, seems good now.

@craigds
Copy link
Owner

craigds commented Oct 24, 2023

thanks!

@craigds craigds merged commit be292a8 into craigds:master Oct 24, 2023
5 checks passed
@craigds
Copy link
Owner

craigds commented Oct 24, 2023

released in 0.14.0 👍

@adamchainz adamchainz deleted the django_5.0 branch October 25, 2023 10:48
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