Skip to content

Commit 865938f

Browse files
committed
Add has_width_or_height() helper
1 parent f732cc9 commit 865938f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/omnipy/data/_display/dimensions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Dimensions(Generic[WidthT, HeightT]):
3131
DimensionsWithWidth = Dimensions[pyd.NonNegativeInt, pyd.NonNegativeInt | None]
3232
DimensionsWithHeight = Dimensions[pyd.NonNegativeInt | None, pyd.NonNegativeInt]
3333
DimensionsWithWidthAndHeight = Dimensions[pyd.NonNegativeInt, pyd.NonNegativeInt]
34+
DimensionsWithWidthOrHeight = DimensionsWithWidth | DimensionsWithHeight
3435
AnyDimensions = (
3536
GeneralDimensions | DimensionsWithWidth | DimensionsWithHeight | DimensionsWithWidthAndHeight)
3637

@@ -47,6 +48,10 @@ def has_width_and_height(dims: AnyDimensions) -> TypeIs[DimensionsWithWidthAndHe
4748
return has_width(dims) and has_height(dims)
4849

4950

51+
def has_width_or_height(dims: AnyDimensions) -> TypeIs[DimensionsWithWidthOrHeight]:
52+
return has_width(dims) or has_height(dims)
53+
54+
5055
class Proportionally(str, Enum):
5156
THINNER = 'thinner'
5257
SAME = 'same'

0 commit comments

Comments
 (0)