-
-
Couldn't load subscription status.
- Fork 516
Improve stubs for flatten and flatten_fieldsets
#2572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve stubs for flatten and flatten_fieldsets
#2572
Conversation
350a803 to
046aa7c
Compare
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
4c89ad4 to
2438ddb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like pyright is not happy with something :(
d927064 to
bca1c4d
Compare
Yeah... Looking into that. It's hard to get the different type checkers to agree on pretty much anything at all it seems 😞 I've fixed a bunch of the pyright issues, ignored a few around the model fields that can't be handled until we support making fields generic as per #2214, and a handful still to check. The good news is that, by adding some testing, I ended up simplifying the implementation. |
This renames `_DisplayT` to `_ListDisplayT` and creates a new `_DisplayT` alias with the contents of the `_ListOrTuple`. This will be used in the next commit.
These functions are implemented in a generic way that doesn't generally care about the content. The existing return type of `Callable | str` makes these awkward to use. I've changed the use of `Sequence` in the `_FieldGroups` alias to use `_ListOrTuple`. This is another case where `ModelAdmin.fields` and the `"fields"` item in fieldsets are presumed by Django to be a `list` or `tuple`, e.g. there are some system checks that ensure this. See https://github.com/django/django/blob/afbb8c709d40e77b3f71c152d363c5ad95ceec2d/django/contrib/admin/utils.py#L102-L120
bca1c4d to
d1a968e
Compare
|
Success @sobolevn! Somehow it's turned out rather clean after my silly false starts! 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks!
I have made things!
These functions are implemented in a generic way that doesn't generally care about the content. The existing return type of
Callable | strmakes these awkward to use.I've changed the use of
Sequencein the_FieldGroupsalias to use_ListOrTuple. This is another case whereModelAdmin.fieldsand the"fields"item in fieldsets are presumed by Django to be alistortuple, e.g. there are some system checks that ensure this.See https://github.com/django/django/blob/afbb8c709d40e77b3f71c152d363c5ad95ceec2d/django/contrib/admin/utils.py#L102-L120
Related issues
N/A