2020
2121from enum import Enum , auto
2222import sys
23- from typing import List , Optional
23+ from typing import List , Optional , Union
2424
2525import circuitpython_typing
2626
@@ -189,8 +189,8 @@ def __new__(cls, clock: Pin, MOSI: Pin, MISO: Pin, **kwargs) -> "SPI":
189189 def __init__ (
190190 self ,
191191 clock : Pin ,
192- MOSI : Pin | None = None ,
193- MISO : Pin | None = None ,
192+ MOSI : Union [ Pin , None ] = None ,
193+ MISO : Union [ Pin , None ] = None ,
194194 half_duplex : bool = False ,
195195 ):
196196 """A class to mock :external:py:class:`busio.SPI`."""
@@ -297,16 +297,16 @@ class Parity(Enum):
297297
298298 def __init__ (
299299 self ,
300- tx : Pin | None = None ,
301- rx : Pin | None = None ,
300+ tx : Union [ Pin , None ] = None ,
301+ rx : Union [ Pin , None ] = None ,
302302 * ,
303- rts : Pin | None = None ,
304- cts : Pin | None = None ,
305- rs485_dir : Pin | None = None ,
303+ rts : Union [ Pin , None ] = None ,
304+ cts : Union [ Pin , None ] = None ,
305+ rs485_dir : Union [ Pin , None ] = None ,
306306 rs485_invert : bool = False ,
307307 baudrate : int = 9600 ,
308308 bits : int = 8 ,
309- parity : Parity | None = None ,
309+ parity : Union [ Parity , None ] = None ,
310310 stop : int = 1 ,
311311 timeout : float = 1 ,
312312 receiver_buffer_size : int = 64 ,
@@ -315,7 +315,7 @@ def __init__(
315315 self ._timeout = timeout
316316 super ().__init__ ()
317317
318- def read (self , nbytes : int | None = None ) -> Optional [bytes ]:
318+ def read (self , nbytes : Union [ int , None ] = None ) -> Optional [bytes ]:
319319 """A function that mocks :external:py:meth:`busio.UART.read()`.
320320
321321 .. mock-expects::
@@ -362,7 +362,7 @@ def readline(self) -> Optional[bytes]:
362362 op .assert_response (buf , 0 , len_buf )
363363 return None if buf else bytes (buf )
364364
365- def write (self , buf : circuitpython_typing .ReadableBuffer ) -> int | None :
365+ def write (self , buf : circuitpython_typing .ReadableBuffer ) -> Union [ int , None ] :
366366 """A function that mocks :external:py:meth:`busio.UART.write()`.
367367
368368 .. mock-expects::
0 commit comments