Skip to content

Commit

Permalink
Use | instead of Union and Optional
Browse files Browse the repository at this point in the history
  • Loading branch information
t20100 committed Oct 27, 2023
1 parent fd1fb65 commit ec5ce07
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
5 changes: 2 additions & 3 deletions src/silx/gui/_glutils/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@


import logging
from typing import Union
import numpy

from .. import qt
Expand Down Expand Up @@ -75,7 +74,7 @@ def getDefaultFontFamily() -> str:

def rasterTextQt(
text: str,
font: Union[str, qt.QFont],
font: str | qt.QFont,
size: int = -1,
weight: int = -1,
italic: bool = False,
Expand Down Expand Up @@ -171,7 +170,7 @@ def rasterTextQt(

def rasterText(
text: str,
font: Union[str, qt.QFont],
font: str | qt.QFont,
size: int = -1,
weight = -1,
italic: bool = False,
Expand Down
11 changes: 5 additions & 6 deletions src/silx/gui/plot/backends/BackendBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
__date__ = "21/12/2018"

from collections.abc import Callable
from typing import Optional
import weakref

from ... import qt
Expand Down Expand Up @@ -197,14 +196,14 @@ def addShape(self, x, y, shape, color, fill, overlay,

def addMarker(
self,
x: Optional[float],
y: Optional[float],
text: Optional[str],
x: float | None,
y: float | None,
text: str | None,
color: str,
symbol: Optional[str],
symbol: str | None,
linestyle: str,
linewidth: float,
constraint: Optional[Callable[[float, float], tuple[float, float]]],
constraint: Callable[[float, float], tuple[float, float]] | None,
yaxis: str,
font: qt.QFont,
) -> object:
Expand Down
3 changes: 1 addition & 2 deletions src/silx/gui/plot/backends/glutils/GLText.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@


from collections import OrderedDict
from typing import Optional
import weakref

import numpy
Expand Down Expand Up @@ -143,7 +142,7 @@ def __init__(
x: float = 0.,
y: float = 0.,
color: tuple[float, float, float, float] = (0., 0., 0., 1.),
bgColor: Optional[tuple[float, float, float, float]] = None,
bgColor: tuple[float, float, float, float] | None = None,
align: str = LEFT,
valign: str = BASELINE,
rotate: float = 0.,
Expand Down
7 changes: 3 additions & 4 deletions src/silx/gui/plot/items/marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@


import logging
from typing import Tuple, Optional

from ....utils.proxy import docstring
from .core import (Item, DraggableMixIn, ColorMixIn, LineMixIn, SymbolMixIn,
Expand Down Expand Up @@ -119,14 +118,14 @@ def setText(self, text):
self._text = text
self._updated(ItemChangedType.TEXT)

def getFont(self) -> Optional[qt.QFont]:
def getFont(self) -> qt.QFont | None:
"""Returns a copy of the QFont used to render text.
To modify the text font, use :meth:`setFont`.
"""
return None if self._font is None else qt.QFont(self._font)

def setFont(self, font: Optional[qt.QFont]):
def setFont(self, font: qt.QFont | None):
"""Set the QFont used to render text, use None for default.
A copy is stored, so further modification of the provided font are not taken into account.
Expand All @@ -149,7 +148,7 @@ def getYPosition(self):
"""
return self._y

def getPosition(self) -> Tuple[Optional[float], Optional[float]]:
def getPosition(self) -> tuple[float | None, float | None]:
"""Returns the (x, y) position of the marker in data coordinates
:rtype: 2-tuple of float or None
Expand Down
3 changes: 1 addition & 2 deletions src/silx/gui/utils/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@


import io
from typing import Union
import matplotlib
import numpy

Expand Down Expand Up @@ -77,7 +76,7 @@ def qFontToFontProperties(font: qt.QFont):

def rasterMathText(
text: str,
font: Union[str, qt.QFont],
font: str | qt.QFont,
size: int = -1,
weight: int = -1,
italic: bool = False,
Expand Down

0 comments on commit ec5ce07

Please sign in to comment.