Commit graph

1118 commits

Author SHA1 Message Date
Benedikt Willi
f09ea0e472 Fix compatibility issues with django-modeltranslation by modifying manager mixins
- Added a new class `_GenericMixin` to serve as a runtime placeholder for `Generic[ModelT]`. This change prevents `TypeError` during `__class__` assignments, which was an issue when mixins inherited from `Generic[T]` at runtime.
- All manager mixins have been updated to inherit from `_GenericMixin` instead of `Generic[ModelT]`. This ensures compatibility with `django-modeltranslation`.
- Introduced regressions tests to confirm that the manager instances support `__class__` reassignment without issues. Tests were added for `SoftDeletableManager`, `InheritanceManager`, `QueryManager`, and `JoinManager`.

Closes GH-#636.
2025-12-15 11:38:33 +01:00
Jelmer
af7c211f26
Merge pull request #642 from foarsitter/lt_django42
Drop support for older Django versions
2025-04-08 10:15:14 +02:00
jelmert
e32d433017 Drop support for older Django versions 2025-04-08 10:04:45 +02:00
Jelmer
128feade2e
Merge pull request #641 from foarsitter/django52
Add formal support for Django 5.2
2025-04-08 09:59:44 +02:00
jelmert
10c43ce7a6 Add formal support for Django 5.2 2025-04-08 09:56:18 +02:00
jelmert
2ad921c04d Model.save keyword only 2025-04-08 09:55:41 +02:00
jelmert
a8e3298260 Use postgres 14 2025-04-08 09:55:41 +02:00
jelmert
edd9a3c3c3 Do not pin versions 2025-04-08 09:55:41 +02:00
Nick Prat
e777819073
Fixed an infinite recursion bug when deleting models related to a tracked model with a ForeignKey (#620)
* Fixed an infinite recursion bug when deleting a model, that has a reverse relationship to a tracked model with SET_NULL on_delete

---------

Co-authored-by: Napat Ch <napat@thevcgroup.com>
2025-04-03 19:58:57 +02:00
Jelmer Draaijer
d1eb8004f2 Fix changelog 2024-09-17 20:05:04 +02:00
jelmert
1ec54667a1 Add classifiers & changelog entry 2024-09-05 17:12:03 +02:00
jelmert
6b86747e5a Add Python version 3.13 to test matrix and test against main 2024-09-05 16:58:24 +02:00
jelmert
bf13ba6733 Add each version on its own line to prevent merge conflicts 2024-09-05 16:57:27 +02:00
Jelmer
aeef1088a1
Merge pull request #627 from foarsitter/release50
Release 5.0.0
2024-09-04 08:18:49 +02:00
Jelmer Draaijer
67d2a4e28f Release 5.0.0 2024-09-04 08:13:21 +02:00
Jelmer
7b091f5c45
Merge pull request #622 from gmcrocetti/issue-541
chore: Replicate Django's signature at SoftDelete queryset
2024-08-28 18:59:28 +02:00
Guilherme Martins Crocetti
1673feae7b
chore: Replicate Django's signature at SoftDelete queryset 2024-08-28 10:41:31 -03:00
Jelmer
2882614f0c
Merge pull request #626 from jazzband/django51
Add formal support for django 5.1
2024-08-28 10:04:04 +02:00
jelmert
0476fad22a Add formal support for django 5.1 2024-08-28 09:48:40 +02:00
Jelmer
3fc446e374
Merge pull request #625 from jazzband/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-08-28 09:42:16 +02:00
pre-commit-ci[bot]
e4d6561a08
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/PyCQA/flake8: 7.1.0 → 7.1.1](https://github.com/PyCQA/flake8/compare/7.1.0...7.1.1)
- [github.com/asottile/pyupgrade: v3.16.0 → v3.17.0](https://github.com/asottile/pyupgrade/compare/v3.16.0...v3.17.0)
2024-08-05 17:55:05 +00:00
Jelmer
731ed804f3
Merge pull request #603 from ProtixIT/type-annotations
Add type annotations
2024-06-19 17:24:56 +02:00
Jelmer
95664ef6ef
Merge pull request #623 from jazzband/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2024-06-18 12:27:25 +02:00
pre-commit-ci[bot]
cc3a2b78b3
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/PyCQA/flake8: 7.0.0 → 7.1.0](https://github.com/PyCQA/flake8/compare/7.0.0...7.1.0)
- [github.com/asottile/pyupgrade: v3.15.2 → v3.16.0](https://github.com/asottile/pyupgrade/compare/v3.15.2...v3.16.0)
2024-06-17 17:39:52 +00:00
Maarten ter Huurne
9dc224723b Tell coverage tool to ignore lines intended for mypy only
In particular, `if TYPE_CHECKING:` blocks and `...` in bodies of
overloaded method definitions.
2024-06-14 11:57:28 +02:00
Maarten ter Huurne
5fc37eb4b4 Provide type arguments to field base classes 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
00937608fa Add type argument to DescriptorWrapper
This preserves the type of the wrapped descriptor (usually a field).

Maybe this is overkill, as `DescriptorWrapper` seems to only be used
as part of the `FieldTracker` implementation and is not documented
and barely tested. But technically, it is public API.
2024-06-13 12:02:05 +02:00
Maarten ter Huurne
1db7d6ba33 Fix type generics in InheritanceIterable 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
f4653f08e5 Preserve tracked function's return type in FieldTracker 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
23a756e13e Annotate test_fields package 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
8f0b4ee2f8 Suppress mypy errors in field tracker tests
I can't find a way to inform mypy of the actual types without
duplicating a lot of test code.
2024-06-13 12:02:05 +02:00
Maarten ter Huurne
3c314234ff Drop uses of JoinManager from the tests
The `JoinManager` class is deprecated and not annotated.
2024-06-13 12:02:05 +02:00
Maarten ter Huurne
ecc7312bf4 Override signature of query-returning methods in InheritanceManager 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
7d6cad0200 Annotate test_field_tracker module 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
949d110d04 Annotate the test_models package 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
e4c88103f5 Add pytest to type check dependencies
We also type check the unit tests and the unit tests now import
functionality from pytest.
2024-06-13 12:02:05 +02:00
Maarten ter Huurne
9d3940a6f2 Annotate the test_choices module
This required a bit of refactoring to get the type of `STATUS` correct
for each suite.

There are two cases which I decided not to support in the type system:
- passing a list instead of a tuple when defining an option group
- `in` checks using a data type that doesn't match the choices
2024-06-13 12:02:05 +02:00
Maarten ter Huurne
c83ef89bc9 Annotate test helpers 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
23f1811b9d Annotate return type of test methods 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
218843d754 Add minimal annotations to unit tests
These annotations are sufficient to pass mypy inspection if mypy is
configured to allow unannotated functions.
2024-06-13 12:02:05 +02:00
Maarten ter Huurne
aeeb69a9dd Enable postponed evaluation of annotations for all test modules
This allows using the latest annotation syntax supported by the type
checker regardless of the runtime Python version.
2024-06-13 12:02:05 +02:00
Maarten ter Huurne
713a3fec88 Make type aliases compatible with old Python versions 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
2b0b4827a5 Annotate the choices module
The `Choices` constructor actually only accepts lists and tuples, not
arbitrary sequences. However, using `list` in the annotation opens
a can of worms related to type variance.
2024-06-13 12:02:05 +02:00
Maarten ter Huurne
ebfb3455dc Annotate the fields module 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
172cc72ec6 Annotate the models module 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
bde2d8f9a9 Annotate the managers module 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
56ea527286 Annotate the tracker module 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
632441ea53 Require full annotation in mypy configuration 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
0043fedf46 Enable postponed evaluation of annotations for all source modules
This allows using the latest annotation syntax supported by the type
checker regardless of the runtime Python version.
2024-06-13 12:02:05 +02:00
Maarten ter Huurne
885da698d5 Upgrade mypy and django-stubs 2024-06-13 12:02:05 +02:00