Closed JanChec closed 4 years ago
Hey,
I know that the support for new Python is not there yet, so I'm not making it a PR. Instead I put here how it can be achieved to have type hints for N() and G() functions (super useful for using the lib with an IDE that uses type hints).
N()
G()
In __init__.py, at the top:
__init__.py
import typing (...) INSTANCE_TYPE = typing.TypeVar('INSTANCE')
Then:
def new(model: typing.Type[INSTANCE_TYPE], shelve=False, n=1, persist_dependencies=True, **kwargs) -> INSTANCE_TYPE:
def get(model: typing.Type[INSTANCE_TYPE], shelve=False, n=1, **kwargs) -> INSTANCE_TYPE:
Thanks @Kern3l ! I did a hack to handle the Python 2/3 compatibility. https://github.com/paulocheque/django-dynamic-fixture/pull/102
It is ugly but it works well for a test library.
Hey,
I know that the support for new Python is not there yet, so I'm not making it a PR. Instead I put here how it can be achieved to have type hints for
N()
andG()
functions (super useful for using the lib with an IDE that uses type hints).In
__init__.py
, at the top:Then: