This commit is contained in:
Will McGugan 2020-06-27 22:56:10 +01:00
parent f4e5c7cdfc
commit b38c757275
1 changed files with 14 additions and 4 deletions

View File

@ -1,4 +1,4 @@
from typing import Iterable, List, Optional
from typing import Iterable, List, Optional, overload
from typing_extensions import Literal
from ._loop import loop_last
@ -340,10 +340,20 @@ LEGACY_WINDOWS_SUBSTITUTIONS = {
}
def get_safe_box(box: Optional[Box], legacy_windows: bool) -> Box:
@overload
def get_safe_box(box: None, legacy_windows: bool) -> None:
...
@overload
def get_safe_box(box: Box, legacy_windows: bool) -> Box:
...
def get_safe_box(box: Optional[Box], legacy_windows: bool) -> Optional[Box]:
"""Substitute Box constants that don't render on windows legacy."""
if legacy_windows:
return LEGACY_WINDOWS_SUBSTITUTIONS.get(box, box) if box else None
if legacy_windows and box is not None:
return LEGACY_WINDOWS_SUBSTITUTIONS.get(box, box)
else:
return box