mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-04-14 03:13:30 -07:00
Core: Fix OptionList and OptionSet to allow Iterable of Iterable (#2911)
* fix, maybe
* typegard for iterable of any
* wow I'm so tired I just changed the method name without changing what it actually does...
* also exclude bytes in is_iterable_but_str
* apply pr comments
* Update Utils.py
Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com>
* Revert "also exclude bytes in is_iterable_but_str"
This reverts commit cf087d2ee2.
---------
Co-authored-by: Doug Hoskisson <beauxq@users.noreply.github.com>
This commit is contained in:
11
Utils.py
11
Utils.py
@@ -713,7 +713,7 @@ def messagebox(title: str, text: str, error: bool = False) -> None:
|
||||
import ctypes
|
||||
style = 0x10 if error else 0x0
|
||||
return ctypes.windll.user32.MessageBoxW(0, text, title, style)
|
||||
|
||||
|
||||
# fall back to tk
|
||||
try:
|
||||
import tkinter
|
||||
@@ -969,11 +969,8 @@ class RepeatableChain:
|
||||
return sum(len(iterable) for iterable in self.iterable)
|
||||
|
||||
|
||||
def is_iterable_of_str(obj: object) -> TypeGuard[typing.Iterable[str]]:
|
||||
""" but not a `str` (because technically, `str` is `Iterable[str]`) """
|
||||
def is_iterable_except_str(obj: object) -> TypeGuard[typing.Iterable[typing.Any]]:
|
||||
""" `str` is `Iterable`, but that's not what we want """
|
||||
if isinstance(obj, str):
|
||||
return False
|
||||
if not isinstance(obj, typing.Iterable):
|
||||
return False
|
||||
obj_it: typing.Iterable[object] = obj
|
||||
return all(isinstance(v, str) for v in obj_it)
|
||||
return isinstance(obj, typing.Iterable)
|
||||
|
||||
Reference in New Issue
Block a user