| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Alrighty, I think this one's ready for review any time. Let me know if you have any q's or feedback - I think these changes will massively improve ergonomics for peewee users (all 3 of us lol). |
Sorry, something went wrong.
|
A general comment: Non-obvious Anys need to be documented, i.e. what are the acceptable types and/or why is Any used here. Obvious Anys include dict[str, Any], Callable[..., Any], or Field[Any]. But for example, in _FieldKwargs default: Any and choices: Iterable[tuple[Any, str]] | None need to be explained with a (short) comment, for example: default: Any # Accepted types depend on the field type(I'm not sure whether that's the correct explanation.) |
Sorry, something went wrong.
|
@srittau / team - it really would be fantastic to hear what remaining blockers there are from your side. These changes, I believe, will seriously improve the utility of the stub for Peewee users. Like Django and others, we have a really dynamic API and use metaclass magic and descriptors for field access. These changes address differentiating ModelClass.field vs model_inst.field, something that's historically been a pain point, among a number of other improvements. I hope you will consider merging. The distribution channel for a second/separate set of stubs is just not there, IMO, so I'm really hoping that these changes can get upstreamed. I can go into more detail about this if you wish, but I think the best value and least pain for existing users is typeshed. |
Sorry, something went wrong.
Couple more comments for some Any's that might get flagged.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Sorry, something went wrong.
|
@srittau - I've added a minimal test-case (kinda followed what wtforms is doing, since we have a similar metaclass thing going on). Also commented 3 additional Any's which might be considered non-trivial. I believe this patch is good to go, are you able to review? |
Sorry, something went wrong.
Sorry, something went wrong.
|
Oh, I totally missed this PR, I've send a few other ones for peewee, don't hesitate to grab what I've done if it's good enough for you (it's not much) |
Sorry, something went wrong.
|
@Psycojoker - this is great, many thanks. I'm going to pull in your fixes for chunked, Check, and #15961 (though database can be str or None for deferring init). I've already added one that's doing what #15958 does, except I missed the alias/noop stuff so I'm grabbing that. I don't think the multi types one is probably worth it, since that's internal-only. Diff is here, coleifer/peewee@32debcb |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks!
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Attempt to get Peewee's typing a little bit nicer and bring in some of the additions since 4.0.5.
Added:
For field access - peewee uses metaclass magic along with descriptors, kinda like Django. Fields are now generic over their Python value, so Model.field is the field instance for building queries, and instance.field is the value (e.g. str for CharField, related model for a ForeignKeyField, etc). Also specifying null=True makes the instance value optional, which is nice.