$ PYRIGHT_PYTHON_FORCE_VERSION=1.1.316 pyright
WARNING: there is a new pyright version available (v1.1.316 -> v1.1.317).
Please install the new version or set PYRIGHT_PYTHON_FORCE_VERSION to `latest`
/home/io/Projects/textual-paint/src/textual_paint/paint.py
/home/io/Projects/textual-paint/src/textual_paint/paint.py:39:28 - error: Type of "get_current_worker" is partially unknown
Type of "get_current_worker" is "() -> Worker[Unknown]" (reportUnknownVariableType)
1 error, 0 warnings, 0 informations
- Center the canvas (when it's smaller than the viewport).
- Adjust the scroll position when entering View Bitmap mode to anchor
the top/left (when the image is larger than the viewport).
- Restore the scroll position when exiting View Bitmap mode.
Avoid the cell background showing past the left/top of the border of the cell, by using left/top-aligned characters (▛▌▀) rather than centered border characters (┼┆┄).
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.)
If digits were present in the document, they were concatenated after
the color codes, and they ran together indistinguishably.
This changed the color index numbers that were read back, to potentially
invalid color indices, and lost the digits as part of the document.
It needs the delimiter of the ending escape code to separate the digits.
When attempting to save in a format only supported for opening,
it tripped the assertion here, which I'm removing.
(This code was a little complicated to reason about, and I thought I was
oversimplifying, when restructuring to handle the overlap of warnings,
but I couldn't place what case I was missing, until testing this.)
This avoids duplicately detecting the format from the file extension
in one case, and in the other case, avoids using a bogus file name to
implement a default fallback file format.