Skip to content

Conversation

@haradhansharma
Copy link

More straight forward parser consumes

More straight forward parser consumes
@JoelLefkowitz JoelLefkowitz added the 1.23.x Release target in 1.23.x label Oct 17, 2024
@JoelLefkowitz JoelLefkowitz added the enhancement Enhancement label Mar 7, 2025
@JoelLefkowitz
Copy link
Collaborator

JoelLefkowitz commented Mar 7, 2025

Hey @haradhansharma could you please clarify the details of this commit?

The return type of the function is a list:

media_types = [parser.media_type for parser in parser_classes or []]
non_form_media_types = [encoding for encoding in media_types if not is_form_media_type(encoding)]

if len(non_form_media_types) == 0:
    return media_types

return non_form_media_types

But this expression may be an individual object:

return [media_types[0]]

Also media_types can be empty, so we can't index it without accounting for that.

I agree that we can drop the or [] in the media_types expression because parser_classes is guaranteed to be a list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.23.x Release target in 1.23.x enhancement Enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants