Add missing generic on Factory subclasses#1060
Add missing generic on Factory subclasses#1060Viicos wants to merge 5 commits intoFactoryBoy:masterfrom
Factory subclasses#1060Conversation
rbarrois
left a comment
There was a problem hiding this comment.
Thanks for catching that!
That's a good point for the abstract factories; for the concrete ones (StubFactory, ListFactory, DictFactory), I believe we should use the actual class instead of the typevar'd.
Finally, would you be able to add a couple of tests in tests/test_typing.py? Those are exercised through make test as the first check.
Thanks!
|
Good catch on concrete factories. I updated tests to make use of |
|
I add tried to use |
|
Yes this is why I added |
|
Hi @rbarrois, any chance we could get a release once this is merged? The typing addition from the previous PR would be really useful in test code as it really plays well in IDEs :) Thanks! |
|
|
||
| from . import base, errors | ||
|
|
||
| T = TypeVar("T") |
There was a problem hiding this comment.
Is it required to create a new TypeVar here? Can't we import it from base.py or user base.T? The same applies todjango.py and mogo.py.
|
Hey there 😄 we use FactoryBoy quite a lot at Tacto. Since this PR has been open for quite some time, I just worked on top of it to see if we can get it merged soon. This is why I opened another PR: #1100 that basically works on top of this PR and the existing comments. I'll look into other issues that we saw so far with typing with mypy, and see if I can address them ;) looking forward! |
Following #1059, subclasses were missing the type var, making it impossible to parametrize at runtime.
There's a couple places where I'd like to see typing added (e.g.
LazyAttributeand friends' callables arguments). They should be pretty straightforward, would you like to have a PR implementing it?