Skip to content
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

Allow tuples and other iterables in source() method #1895

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

miguelgrinberg
Copy link
Collaborator

Fixes #1893

@miguelgrinberg miguelgrinberg marked this pull request as ready for review September 3, 2024 10:14
Comment on lines 719 to 720
elif not isinstance(fields, (str, InstrumentedField)):
return [str(f) for f in fields]
Copy link
Member

@pquentin pquentin Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered a more explicit check, like explicitly allowing lists and tuples or looking for for collections.abc.Iterable? If not, maybe this warrants a comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment for now. Basically the way I'm thinking about this is that in this case the typing change broke how the library works at runtime. My goal was to address the runtime problem. As I mentioned back when we did the typing changes, I think we could replace specific types such as List and Dict with more generic ones in a lot of places, but when I look at that I'll do it for the whole library.

@miguelgrinberg miguelgrinberg added the backport 8.x Backport to 8.x label Sep 3, 2024
@miguelgrinberg miguelgrinberg merged commit 6853db7 into elastic:main Sep 3, 2024
17 checks passed
@miguelgrinberg miguelgrinberg deleted the source-tuple-fix branch September 3, 2024 19:18
github-actions bot pushed a commit that referenced this pull request Sep 3, 2024
* Allow tuples and other iterables in source() method

Fixes #1893

* review feedback

(cherry picked from commit 6853db7)
miguelgrinberg added a commit that referenced this pull request Sep 3, 2024
* Allow tuples and other iterables in source() method

Fixes #1893

* review feedback

(cherry picked from commit 6853db7)

Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 8.x Backport to 8.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression: source() does not accept iterables
2 participants