mirror of
https://github.com/1j01/textual-paint.git
synced 2024-12-26 16:21:57 +03:00
Resolve all non-strict mode Pyright errors
This commit is contained in:
parent
2a35778cbd
commit
0b6006325e
@ -887,6 +887,9 @@ def is_inside_polygon(x: int, y: int, points: List[Offset]) -> bool:
|
|||||||
if y > min(p1y, p2y):
|
if y > min(p1y, p2y):
|
||||||
if y <= max(p1y, p2y):
|
if y <= max(p1y, p2y):
|
||||||
if x <= max(p1x, p2x):
|
if x <= max(p1x, p2x):
|
||||||
|
x_intersection = x # Avoid "possibly unbound" type checker error
|
||||||
|
# I don't know if this is right; should it flip `inside` in this case?
|
||||||
|
# Is this an actual case that can occur, where p1y == p2y AND p1x != p2x?
|
||||||
if p1y != p2y:
|
if p1y != p2y:
|
||||||
x_intersection = (y - p1y) * (p2x - p1x) / (p2y - p1y) + p1x
|
x_intersection = (y - p1y) * (p2x - p1x) / (p2y - p1y) + p1x
|
||||||
if p1x == p2x or x <= x_intersection:
|
if p1x == p2x or x <= x_intersection:
|
||||||
@ -2588,6 +2591,7 @@ class PaintApp(App[None]):
|
|||||||
def cancel_preview(self) -> None:
|
def cancel_preview(self) -> None:
|
||||||
"""Revert the currently previewed action."""
|
"""Revert the currently previewed action."""
|
||||||
if self.preview_action:
|
if self.preview_action:
|
||||||
|
assert self.preview_action.region is not None, "region should have been initialized for preview_action"
|
||||||
self.preview_action.undo(self.image)
|
self.preview_action.undo(self.image)
|
||||||
self.canvas.refresh_scaled_region(self.preview_action.region)
|
self.canvas.refresh_scaled_region(self.preview_action.region)
|
||||||
self.preview_action = None
|
self.preview_action = None
|
||||||
|
@ -47,10 +47,11 @@ def get_desktop_environment() -> str:
|
|||||||
return "razor-qt"
|
return "razor-qt"
|
||||||
elif desktop_session.startswith("wmaker"): # e.g. wmaker-common
|
elif desktop_session.startswith("wmaker"): # e.g. wmaker-common
|
||||||
return "windowmaker"
|
return "windowmaker"
|
||||||
|
gnome_desktop_session_id = os.environ.get("GNOME_DESKTOP_SESSION_ID")
|
||||||
if os.environ.get('KDE_FULL_SESSION') == 'true':
|
if os.environ.get('KDE_FULL_SESSION') == 'true':
|
||||||
return "kde"
|
return "kde"
|
||||||
elif os.environ.get('GNOME_DESKTOP_SESSION_ID'):
|
elif gnome_desktop_session_id:
|
||||||
if not "deprecated" in os.environ.get('GNOME_DESKTOP_SESSION_ID'):
|
if not "deprecated" in gnome_desktop_session_id:
|
||||||
return "gnome2"
|
return "gnome2"
|
||||||
#From http://ubuntuforums.org/showthread.php?t=652320
|
#From http://ubuntuforums.org/showthread.php?t=652320
|
||||||
elif is_running("xfce-mcs-manage"):
|
elif is_running("xfce-mcs-manage"):
|
||||||
@ -61,13 +62,16 @@ def get_desktop_environment() -> str:
|
|||||||
|
|
||||||
def is_running(process: str) -> bool:
|
def is_running(process: str) -> bool:
|
||||||
"""Returns whether a process with the given name is (likely) currently running.
|
"""Returns whether a process with the given name is (likely) currently running.
|
||||||
Uses a basic text search, and so may have false positives."""
|
|
||||||
|
Uses a basic text search, and so may have false positives.
|
||||||
|
"""
|
||||||
#From http://www.bloggerpolis.com/2011/05/how-to-check-if-a-process-is-running-using-python/
|
#From http://www.bloggerpolis.com/2011/05/how-to-check-if-a-process-is-running-using-python/
|
||||||
# and http://richarddingwall.name/2009/06/18/windows-equivalents-of-ps-and-kill-commands/
|
# and http://richarddingwall.name/2009/06/18/windows-equivalents-of-ps-and-kill-commands/
|
||||||
try: #Linux/Unix
|
try: #Linux/Unix
|
||||||
s = subprocess.Popen(["ps", "axw"],stdout=subprocess.PIPE)
|
s = subprocess.Popen(["ps", "axw"],stdout=subprocess.PIPE)
|
||||||
except: #Windows
|
except: #Windows
|
||||||
s = subprocess.Popen(["tasklist", "/v"],stdout=subprocess.PIPE)
|
s = subprocess.Popen(["tasklist", "/v"],stdout=subprocess.PIPE)
|
||||||
|
assert s.stdout is not None
|
||||||
for x in s.stdout:
|
for x in s.stdout:
|
||||||
# if re.search(process, x):
|
# if re.search(process, x):
|
||||||
if process in str(x):
|
if process in str(x):
|
||||||
@ -183,10 +187,11 @@ def set_wallpaper(file_loc: str, first_run: bool = True):
|
|||||||
#From https://stackoverflow.com/questions/1977694/change-desktop-background
|
#From https://stackoverflow.com/questions/1977694/change-desktop-background
|
||||||
import ctypes
|
import ctypes
|
||||||
SPI_SETDESKWALLPAPER = 20
|
SPI_SETDESKWALLPAPER = 20
|
||||||
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, file_loc, 0)
|
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, file_loc, 0) # type: ignore
|
||||||
elif desktop_env=="mac": #Not tested since I do not have a mac
|
elif desktop_env=="mac": #Not tested since I do not have a mac
|
||||||
#From https://stackoverflow.com/questions/431205/how-can-i-programatically-change-the-background-in-mac-os-x
|
#From https://stackoverflow.com/questions/431205/how-can-i-programatically-change-the-background-in-mac-os-x
|
||||||
try:
|
try:
|
||||||
|
assert os.name == "mac" # avoid 'Import "appscript" could not be resolved' on other platforms
|
||||||
from appscript import app, mactypes
|
from appscript import app, mactypes
|
||||||
app('Finder').desktop_picture.set(mactypes.File(file_loc))
|
app('Finder').desktop_picture.set(mactypes.File(file_loc))
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
Loading…
Reference in New Issue
Block a user