Skip to content

Commit 0d421d6

Browse files
committed
Reverted the use of the new Union type hint (|) unsupported in py3.8 to old Union[] syntax [issue#1;issue#2]
1 parent 22d9250 commit 0d421d6

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
1010
- Dropped support for py3.7
1111

1212

13+
### Fixed
14+
15+
- Reverted the use of the new Union type hint (|) unsupported in py3.8 to old `Union[]` syntax [issue#1;issue#2]
16+
1317
## [0.1.0] - 2022-11-22
1418

1519
Initial release

src/namedpipe/_posix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os, tempfile
22
from os import path
3-
from typing import IO, Optional
3+
from typing import IO, Optional, Union
44
try:
55
from typing import Literal # type: ignore
66
except ImportError:
@@ -67,7 +67,7 @@ def __init__(
6767
):
6868
# "open" named pipe
6969
self._path = _FifoMan().make(name)
70-
self.stream: IO | None = None # I/O stream of the pipe
70+
self.stream: Union[IO, None] = None # I/O stream of the pipe
7171

7272
if 't' not in mode and 'b' not in mode:
7373
mode += 'b' # default to binary mode

src/namedpipe/_win32.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import win32pipe, win32file, win32api, winerror, win32con, pywintypes
22
from os import path
33
import io
4-
from typing import TypeVar, NewType, Literal, IO, Optional
4+
from typing import TypeVar, NewType, Literal, IO, Optional, Union
55

66
WritableBuffer = TypeVar("WritableBuffer")
77
PyHANDLE = NewType("PyHANDLE", int)
@@ -44,7 +44,7 @@ def __init__(
4444
if not isinstance(bufsize, int):
4545
raise TypeError("bufsize must be an integer")
4646

47-
self.stream: IO | None = None # I/O stream of the pipe
47+
self.stream: Union[IO, None] = None # I/O stream of the pipe
4848
self._path = _name_pipe() if name is None else rf"\\.\pipe\{name}"
4949
self._rd = any(c in mode for c in "r+")
5050
self._wr = any(c in mode for c in "wax+")
@@ -143,9 +143,7 @@ def wait(self):
143143
Wrapper = (
144144
io.BufferedRandom
145145
if self._rd and self._wr
146-
else io.BufferedReader
147-
if self._rd
148-
else io.BufferedWriter
146+
else io.BufferedReader if self._rd else io.BufferedWriter
149147
)
150148
stream = Wrapper(
151149
stream, self._bufsize if self._bufsize > 0 else io.DEFAULT_BUFFER_SIZE
@@ -207,7 +205,7 @@ def close(self) -> None:
207205

208206
super().close()
209207

210-
def readinto(self, b: WritableBuffer) -> int | None:
208+
def readinto(self, b: WritableBuffer) -> Union[int, None]:
211209
"""Read bytes into a pre-allocated, writable bytes-like object ``b`` and
212210
return the number of bytes read. For example, ``b`` might be a ``bytearray``."""
213211

0 commit comments

Comments
 (0)