fix some typing errors
This commit is contained in:
parent
4eecac0c56
commit
9d9a625b08
|
@ -1,13 +1,13 @@
|
|||
import argparse
|
||||
import asyncio
|
||||
import contextlib
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import termios
|
||||
import tty
|
||||
from types import TracebackType
|
||||
from typing import Optional, Tuple, Type
|
||||
from typing import Any, List, Optional, Tuple, Type
|
||||
from typing_extensions import Literal
|
||||
|
||||
import serial
|
||||
import serial_asyncio
|
||||
|
@ -30,11 +30,14 @@ MODE_LOOKUP = {
|
|||
|
||||
class TtyRaw:
|
||||
__slots__ = ["isatty", "fd", "settings"]
|
||||
isatty: bool
|
||||
fd: int
|
||||
settings: List[Any]
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.isatty = False
|
||||
self.fd = None
|
||||
self.settings = None
|
||||
self.fd = 0
|
||||
self.settings = []
|
||||
|
||||
def __enter__(self) -> None:
|
||||
if sys.stdin.isatty():
|
||||
|
@ -46,9 +49,10 @@ class TtyRaw:
|
|||
|
||||
def __exit__(self, exc_type: Optional[Type[BaseException]],
|
||||
exc_value: Optional[BaseException],
|
||||
exc_traceback: Optional[TracebackType]) -> bool:
|
||||
exc_traceback: Optional[TracebackType]) -> Literal[False]:
|
||||
if self.isatty:
|
||||
termios.tcsetattr(self.fd, termios.TCSADRAIN, self.settings)
|
||||
return False
|
||||
|
||||
|
||||
async def setup_async() -> Tuple[asyncio.StreamReader, asyncio.StreamWriter]:
|
||||
|
|
Loading…
Reference in New Issue