Minor Enhancements, deprecated function cleanup

This commit is contained in:
David Sangrey committed 2026-06-03 22:44:52 -04:00
1 parent c8ebf9704c
commit 2a06fba38d
3 files changed
+14 -12

No files matched your search

+5 -8
View File
@@ -182,7 +182,7 @@ def listify(thing: list | dict | None) -> list[Any]:
JSON objects indexed by integers. Sparse arrays are converted to
lists with gaps filled with None.
"""
if thing is None:
if not thing:
return []
if isinstance(thing, list):
@@ -1295,13 +1295,10 @@ def index_possibly_sparse_list(data: Mapping[str, V] | list[V], key: int) -> V:
>>> index_possibly_sparse_list(data, 0)
'test_list'
"""
if isinstance(data, list):
return data[key]
if isinstance(data, dict):
return data[str(key)]
raise ValueError(f'Unexpected data type {type(data)}')
try:
return data[key] if isinstance(data, list) else data[str(key)]
except (KeyError, IndexError) as e:
raise ValueError(f'Unexpected data type or missing key: {type(data)}') from e
######################################################################
+4 -3
View File
@@ -8,7 +8,6 @@ from pathlib import Path
import subprocess
import sys
import tkinter as tk
from os import system
from tkinter import colorchooser as tkColorChooser # type: ignore # noqa: N812
from tkinter import ttk
from itertools import count
@@ -40,12 +39,14 @@ logger = get_main_logger()
def open_folder(file: Path) -> None:
"""Open the given file in the OS file explorer."""
# Ensure we are working with a resolved Path object
file_path = Path(file).resolve()
if sys.platform.startswith('win'):
# On Windows, use the "start" command to open the folder
system(f'start "" "{file}"')
subprocess.run(['start', '', file_path], shell=True)
elif sys.platform.startswith('linux'):
# On Linux, use the "xdg-open" command to open the folder
system(f'xdg-open "{file}"')
subprocess.run(['xdg-open', str(file_path)])
def help_open_system_profiler(parent) -> None:
+5 -1
View File
@@ -40,7 +40,11 @@ class TimeoutAdapter(HTTPAdapter):
def new_session(timeout: int = REQUEST_TIMEOUT, session: Session | None = None) -> Session:
"""DEPRECATED: Create a new requests.Session."""
"""
Create a new requests.Session.
DEPRECATED. Will be removed in a future version (6.3 or later).
"""
warnings.warn(
"timeout_session.new_session() is deprecated and will be removed. "
"Use requests.Session() directly and pass explicit timeouts to request methods.",