-
Notifications
You must be signed in to change notification settings - Fork 815
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
The type of dark attribute of class App might be inaccurate. (Reactive[bool] -> bool) #4614
Comments
Dark should be from textual.app import App, ComposeResult
from textual.widgets import Label
class LightApp(App[None]):
def __init__(self):
super().__init__()
self.dark = False
def compose(self) -> ComposeResult:
yield Label("This is a light app")
if __name__ == "__main__":
LightApp().run() I also see no type issues with the code (in this case using pyright): It might be a good idea to say what you're using for type checking, and perhaps which IDE you're using. For example, the type checker in (some versions of?) PyCharm are known to be lacking a little and sometimes can mislead people. |
Yeah, PyCharm doesn't understand descriptors all that well. @Haphaistos2333 feel free to report this to the PyCharm folks. |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Current code in src/textual/app.py:
I personally believe the type of the attribute "dark" should be bool instead of Reactive. (Correct me if I was wrong.)
Reactive class does not implement
__bool__
method, soReactive(False)
is actuallyTrue
when casted to bool, which is quite confusing.In the code example, the first execution of
self.app.dark = not self.app.dark
is actually settingself.app.dark
to boolean typeFalse
, which mean if I initially setself.app.dark
toReactive(False)
, the theme is still light unless I toggle it once.The code seems not using features of Reactive on dark attribute, so it will be more convincing changing the type to bool.
The text was updated successfully, but these errors were encountered: