I was hoping this would fix the Python rocket icon showing in the dock on macOS, but it doesn't. It still stays until the program exits.
Might still be good to do though.
It's hard to install on Windows, and this seems to be misleading:
ERROR: Could not build wheels for psutil, which is required to install pyproject.toml-based projects
→ PYRIGHT_PYTHON_FORCE_VERSION=latest pyright
added 1 package, and audited 2 packages in 4s
found 0 vulnerabilities
/home/io/Projects/textual-paint/src/textual_paint/paint.py
/home/io/Projects/textual-paint/src/textual_paint/paint.py:1173:64 - error: Condition will always evaluate to True since the types "Never" and "None" have no overlap (reportUnnecessaryComparison)
/home/io/Projects/textual-paint/src/textual_paint/paint.py:1214:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
/home/io/Projects/textual-paint/src/textual_paint/paint.py:1217:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
/home/io/Projects/textual-paint/src/textual_paint/paint.py:1220:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
/home/io/Projects/textual-paint/src/textual_paint/paint.py:1223:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
/home/io/Projects/textual-paint/src/textual_paint/paint.py:1229:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
/home/io/Projects/textual-paint/src/textual_paint/paint.py:1233:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
7 errors, 0 warnings, 0 informations
While Pyright can narrow down the type of format_id from `str | None` to `str` based on `format_id in Image.SAVE` (where `Image.SAVE` is `dict[str, Any]`), mypy does not.
When opening the Open dialog, it shouldn't populate the file name input,
but when clicking a file, it should fill in the clicked file's name.
The `_expanding_directory_tree` flag gave false positives:
- When opening a file in a directory the program doesn't have permissions to via the CLI,
such as with `python -m src.textual_paint.paint /root/nonexistent`,
opening the Open dialog, and clicking a file, it wasn't populating the filename input,
because the flag was never cleared if it couldn't find (access) the
directories and file matching any of the path parts, working down the directory structure.
This was broken in [b3ca55a3b1] "Use new callback to remove race condition"
but before, it just cleared the flag after a delay, so it wasn't a good solution,
It also gave false negatives:
- When opening the Open dialog, it was populating the name input field
with the file selected programmatically with `expand_to_path`,
instead of leaving it blank.
The automatic expansion was broken in [e9755637d6] "Update Textual to 0.26.0"
due to changes 0.25.0, since directory contents are now loaded in a worker.
This flag's behavior was broken since rewriting the code to handle asynchronous directory loading in
[4e1f11ab23] "Fix expanding directory tree to current folder, in file dialogs"
An alternative I considered was to create a new message such as `EnhancedDirectoryTree.NodeHighlighted`, but let's call it `EnhancedNodeHighlighted`, then to have `on_tree_node_highlighted` in `EnhancedDirectoryTree` which sends `EnhancedNodeHighlighted` always with `from_expand_to_path=False`, and then do:
| # Suppress EnhancedNodeHighlighted with from_expand_to_path=False
| with self.prevent(self.EnhancedNodeHighlighted):
| self.select_node(node)
| # Send it with the flag set
| self.post_message(self.EnhancedNodeHighlighted(..., from_expand_to_path=True))
The solution I settled on was to add an `on_tree_node_highlighted` method to my `EnhancedDirectoryTree` for the purpose of clearing the flag, with still a further delay so that the app's `on_tree_node_highlighted` can use the flag before its cleared.
(I left `_expanding_directory_tree` in at this commit for comparison of the behavior. For a fair estimate of the complexity of this change, include the following cleanup in the diff.)