-
Notifications
You must be signed in to change notification settings - Fork 844
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
Alternative method to initialise Select
#3691
Comments
Can I work on this? I have done a quick prototype solution following the class method approach you suggested. Before I go forward with formalizing the prototype, I wanted to ask: is this preferrable to overloading the constructor? |
Hey @azinneck0485 thanks for your interest! Let us just make sure that the class method is a good idea and then we'll let you know. |
I think we should go ahead and add the classmethod. @azinneck0485 are you happy to contribute that? |
Yes, I will contribute that change and get a PR in once I've tested it. |
Excellent @azinneck0485! |
Hi @rodrigogiraoserrao -- I have made the code changes and done some testing on my own. I have also updated the documentation by adding an example (which is just the existing example modified to use the new class method to create the select control). All changes have been pushed to a branch on my fork. However, I am not yet ready for a PR as I have run into some problems running I don't want to accidentally update snapshots erroneously, so I wanted to check and see if you had any tips on what I should look into to ensure these tests pass? |
Hi @azinneck0485, thanks for the update! In my case, I'm running Python 3.7 and if I run Notice how there's a red warning saying there are 13 unused snapshots, which makes it look like in the end the tests failed (see the Error 1 at the bottom). However, at the same time, pytest reports that those tests were skipped. In short, there's an issue with the snapshot tests reporting (which is a problem in the tool we use for the snapshots) and it's ok for those 13 snapshots to report that “error”. In order to update only the snapshot(s) you created, first make sure they look ok. For example, if you had a snapshot test called |
@rodrigogiraoserrao, thanks for you tips! After adding those packages, the failures went away and I was able to successfully run the new snapshot tests I created. I have added PR #3743 that includes the code change, test changes, and documentation changes. Please let me know if there are additional changes that I need to make. Thanks again for all your help. |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
I propose we extend
Select.__init__
or create a classmethodSelect.from_values
to accept an iterable ofSelectType
and automatically build the labels by converting them to strings.I find that often we just want labels that are string representations of the values we want to select:
data_source
is often just a list of strings or paths and the comprehension to create the tuple looks really awkward.For example, in the
Select
docs we do this:I personally don't like it at all.
The text was updated successfully, but these errors were encountered: