mirror of
https://github.com/1j01/textual-paint.git
synced 2024-12-21 05:41:54 +03:00
Fix type errors in watchdog thread cleanup
- `observer` can be None, if --restart-on-changes was not passed, but the hotkey F2 is pressed. - `is_alive` is a bound method, not a property. It was definitely used like a property in the code I referenced. I didn't fix these type checker errors for a long time because: 1. they never caused actual problems for me, and 2. when adding a type annotation `observer: Observer | None`, Pyright gets even _more_ confused, saying it's Unknown | None instead of BaseObserver | None. The secret trick was to leave it unannotated. 3. Adding parentheses to make it `is_alive()` also made Pyright seem even more confused, saying it was Unknown — until I added the conditional.
This commit is contained in:
parent
ef409f4756
commit
d90449e2de
@ -65,9 +65,10 @@ def restart_program():
|
||||
|
||||
try:
|
||||
try:
|
||||
if observer:
|
||||
observer.stop()
|
||||
observer.join(timeout=1)
|
||||
if observer.is_alive:
|
||||
if observer.is_alive():
|
||||
print("Timed out waiting for file change observer thread to stop.")
|
||||
except RuntimeError as e:
|
||||
# Ignore "cannot join current thread" error
|
||||
|
Loading…
Reference in New Issue
Block a user