From b699a1586a618172515410dd14f2294d54fef4a4 Mon Sep 17 00:00:00 2001 From: David Diamant Date: Thu, 28 Sep 2023 12:47:10 +0300 Subject: [PATCH] add django stubs for HistoricForeignKey --- simple_history/models.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/simple_history/models.py b/simple_history/models.py index 6dc4db9e8..66d8c64f8 100644 --- a/simple_history/models.py +++ b/simple_history/models.py @@ -3,6 +3,7 @@ import uuid import warnings from functools import partial +from typing import TypeVar from django.apps import apps from django.conf import settings @@ -45,6 +46,13 @@ except ImportError: from threading import local as LocalContext + +# __set__ value type +_ST = TypeVar("_ST") +# __get__ return type +_GT = TypeVar("_GT") + + registered_models = {} @@ -873,7 +881,7 @@ def get_queryset(self): ) -class HistoricForeignKey(ForeignKey): +class HistoricForeignKey(ForeignKey[_ST, _GT]): """ Allows foreign keys to work properly from a historic instance.