Textualize / textual

The lean application framework for Python. Build sophisticated user interfaces with a simple Python API. Run your apps in the terminal and a web browser.
https://textual.textualize.io/
MIT License
24.04k stars 740 forks source link

Potentially dead code in `App._broker_event` by virtue of `style.meta` static analysis #1869

Open rodrigogiraoserrao opened 1 year ago

rodrigogiraoserrao commented 1 year ago

There is potentially dead code in:

https://github.com/Textualize/textual/blob/dc4421e76a782f02f6de8e3fb20512b18c8965d1/src/textual/app.py#L2076-L2077

The action is extracted from style.meta which has a very dynamic type.

Is it actually possible to have callables in style.meta? At the time of writing, deleting those two lines of code doesn't break the tests.

If it is possible for style.meta to contain callables, is that a feature we really want?

Can we type style.meta more restrictively and type _event_broker.py::HandlerArguments.action more restrictively? E.g., by using the typical str | Action which uses the type Action from actions.py?

willmcgugan commented 7 months ago

@rodrigogiraoserrao Is this stale? Feel free to close if its no longer relevant.

rodrigogiraoserrao commented 7 months ago

@willmcgugan The code is still there and it is still safe to remove it from our test suite. I suspect this is remnant of a way in which actions were built/handled but now it is no longer needed.