fcurella / django-fakery

🏭 An easy-to-use implementation of Creation Methods for Django, backed by Faker.
http://django-fakery.readthedocs.org/en/stable/
MIT License
115 stars 6 forks source link

Use `SaveHooks` as explicit generic type alias #75

Closed sobolevn closed 5 months ago

sobolevn commented 5 months ago

It is defined as SaveHooks = List[Callable[[T], None]], so we need to set T explicitly as SaveHooks[T]

Problem that my mypy detects:

tests/plugins/identity/verification.py:26: error: No overload variant of "m" of "Factory" matches argument type "Any"  [call-overload]
tests/plugins/identity/verification.py:26: note: Possible overload variants:
tests/plugins/identity/verification.py:26: note:     def m(self, model: str, pre_save: list[Callable[[Model], Any]] | None, post_save: list[Callable[[Model], Any]] | None, seed: Any | bytearray | int | None, quantity: None) -> Callable[..., Model]
tests/plugins/identity/verification.py:26: note:     def m(self, model: Any, pre_save: list[Callable[[Any], None]] | None, post_save: list[Callable[[Any], None]] | None, seed: Any | bytearray | int | None, quantity: None) -> Callable[..., Any]
tests/plugins/identity/verification.py:26: note:     def m(self, model: str, pre_save: list[Callable[[Model], Any]] | None, post_save: list[Callable[[Model], Any]] | None, seed: Any | bytearray | int | None, quantity: int | None) -> Callable[..., list[Model]]
tests/plugins/identity/verification.py:26: note:     def m(self, model: Any, pre_save: list[Callable[[Any], None]] | None, post_save: list[Callable[[Any], None]] | None, seed: Any | bytearray | int | None, quantity: int | None) -> Callable[..., list[Any]]
coveralls commented 5 months ago

Coverage Status

coverage: 90.855%. remained the same when pulling d51b94b1bb3e6d35a7097bd1e81661051397be7d on sobolevn:patch-4 into f7414aa9d92ae8fd01c3baff909d938fb85c82aa on fcurella:master.