Move _device type annotations to __init__()
This commit is contained in:
parent
da0cd8f863
commit
41eaa52397
@ -74,8 +74,6 @@ class CupsPrinter(Escpos):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_device: Union[Literal[False], Literal[None], cups.Connection] = False
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_usable() -> bool:
|
def is_usable() -> bool:
|
||||||
"""Indicate whether this printer class is usable.
|
"""Indicate whether this printer class is usable.
|
||||||
@ -105,6 +103,10 @@ class CupsPrinter(Escpos):
|
|||||||
self.job_name = ""
|
self.job_name = ""
|
||||||
self.pending_job = False
|
self.pending_job = False
|
||||||
|
|
||||||
|
self._device: Union[
|
||||||
|
Literal[False], Literal[None], Type[cups.Connection]
|
||||||
|
] = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def printers(self) -> dict:
|
def printers(self) -> dict:
|
||||||
"""Available CUPS printers."""
|
"""Available CUPS printers."""
|
||||||
|
@ -34,8 +34,6 @@ class File(Escpos):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_device: Union[Literal[False], Literal[None], IO[bytes]] = False
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_usable() -> bool:
|
def is_usable() -> bool:
|
||||||
"""Indicate whether this printer class is usable.
|
"""Indicate whether this printer class is usable.
|
||||||
@ -55,6 +53,8 @@ class File(Escpos):
|
|||||||
self.devfile = devfile
|
self.devfile = devfile
|
||||||
self.auto_flush = auto_flush
|
self.auto_flush = auto_flush
|
||||||
|
|
||||||
|
self._device: Union[Literal[False], Literal[None], IO[bytes]] = False
|
||||||
|
|
||||||
def open(self, raise_not_found: bool = True) -> None:
|
def open(self, raise_not_found: bool = True) -> None:
|
||||||
"""Open system file.
|
"""Open system file.
|
||||||
|
|
||||||
|
@ -54,8 +54,6 @@ class LP(Escpos):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_device: Union[Literal[False], Literal[None], subprocess.Popen] = False
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_usable() -> bool:
|
def is_usable() -> bool:
|
||||||
"""Indicate whether this printer class is usable.
|
"""Indicate whether this printer class is usable.
|
||||||
@ -77,6 +75,8 @@ class LP(Escpos):
|
|||||||
self.auto_flush = kwargs.get("auto_flush", False)
|
self.auto_flush = kwargs.get("auto_flush", False)
|
||||||
self._flushed = False
|
self._flushed = False
|
||||||
|
|
||||||
|
self._device: Union[Literal[False], Literal[None], subprocess.Popen] = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def printers(self) -> dict:
|
def printers(self) -> dict:
|
||||||
"""Available CUPS printers."""
|
"""Available CUPS printers."""
|
||||||
|
@ -48,8 +48,6 @@ class Network(Escpos):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_device: Union[Literal[False], Literal[None], socket.socket] = False
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_usable() -> bool:
|
def is_usable() -> bool:
|
||||||
"""Indicate whether this printer class is usable.
|
"""Indicate whether this printer class is usable.
|
||||||
@ -78,6 +76,8 @@ class Network(Escpos):
|
|||||||
self.port = port
|
self.port = port
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
|
|
||||||
|
self._device: Union[Literal[False], Literal[None], socket.socket] = False
|
||||||
|
|
||||||
def open(self, raise_not_found: bool = True) -> None:
|
def open(self, raise_not_found: bool = True) -> None:
|
||||||
"""Open TCP socket with ``socket``-library and set it as escpos device.
|
"""Open TCP socket with ``socket``-library and set it as escpos device.
|
||||||
|
|
||||||
|
@ -64,8 +64,6 @@ class Serial(Escpos):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_device: Union[Literal[False], Literal[None], serial.Serial] = False
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_usable() -> bool:
|
def is_usable() -> bool:
|
||||||
"""Indicate whether this printer class is usable.
|
"""Indicate whether this printer class is usable.
|
||||||
@ -116,6 +114,8 @@ class Serial(Escpos):
|
|||||||
self.xonxoff = xonxoff
|
self.xonxoff = xonxoff
|
||||||
self.dsrdtr = dsrdtr
|
self.dsrdtr = dsrdtr
|
||||||
|
|
||||||
|
self._device: Union[Literal[False], Literal[None], serial.Serial] = False
|
||||||
|
|
||||||
@dependency_pyserial
|
@dependency_pyserial
|
||||||
def open(self, raise_not_found: bool = True) -> None:
|
def open(self, raise_not_found: bool = True) -> None:
|
||||||
"""Set up serial port and set is as escpos device.
|
"""Set up serial port and set is as escpos device.
|
||||||
|
@ -63,8 +63,6 @@ class Usb(Escpos):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_device: Union[Literal[False], Literal[None], Type[usb.core.Device]] = False
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_usable() -> bool:
|
def is_usable() -> bool:
|
||||||
"""Indicate whether this printer class is usable.
|
"""Indicate whether this printer class is usable.
|
||||||
@ -105,6 +103,10 @@ class Usb(Escpos):
|
|||||||
if idProduct:
|
if idProduct:
|
||||||
self.usb_args["idProduct"] = idProduct
|
self.usb_args["idProduct"] = idProduct
|
||||||
|
|
||||||
|
self._device: Union[
|
||||||
|
Literal[False], Literal[None], Type[usb.core.Device]
|
||||||
|
] = False
|
||||||
|
|
||||||
@dependency_usb
|
@dependency_usb
|
||||||
def open(self, raise_not_found: bool = True) -> None:
|
def open(self, raise_not_found: bool = True) -> None:
|
||||||
"""Search device on USB tree and set it as escpos device.
|
"""Search device on USB tree and set it as escpos device.
|
||||||
|
@ -65,10 +65,6 @@ class Win32Raw(Escpos):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_device: Union[
|
|
||||||
Literal[False], Literal[None], "_win32typing.PyPrinterHANDLE" # noqa: F821
|
|
||||||
] = False
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_usable() -> bool:
|
def is_usable() -> bool:
|
||||||
"""Indicate whether this printer class is usable.
|
"""Indicate whether this printer class is usable.
|
||||||
@ -85,6 +81,10 @@ class Win32Raw(Escpos):
|
|||||||
self.printer_name = printer_name
|
self.printer_name = printer_name
|
||||||
self.job_name = ""
|
self.job_name = ""
|
||||||
|
|
||||||
|
self._device: Union[
|
||||||
|
Literal[False], Literal[None], "_win32typing.PyPrinterHANDLE" # noqa: F821
|
||||||
|
] = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@dependency_win32print
|
@dependency_win32print
|
||||||
def printers(self) -> dict:
|
def printers(self) -> dict:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user