Fix type checking
This commit is contained in:
parent
f8deb69f43
commit
0984c93975
@ -11,7 +11,7 @@
|
||||
|
||||
import functools
|
||||
import logging
|
||||
from typing import Optional, Type, Union
|
||||
from typing import Optional, Union
|
||||
|
||||
from ..escpos import Escpos
|
||||
from ..exceptions import DeviceNotFoundError
|
||||
@ -125,12 +125,13 @@ class Serial(Escpos):
|
||||
|
||||
:raises: :py:exc:`~escpos.exceptions.DeviceNotFoundError`
|
||||
"""
|
||||
if self._device and self.device.is_open:
|
||||
self.close()
|
||||
if self._device:
|
||||
if self.device and self.device.is_open:
|
||||
self.close()
|
||||
|
||||
try:
|
||||
# Open device
|
||||
self.device: Optional[Type[serial.Serial]] = serial.Serial(
|
||||
self.device: Optional[serial.Serial] = serial.Serial(
|
||||
port=self.devfile,
|
||||
baudrate=self.baudrate,
|
||||
bytesize=self.bytesize,
|
||||
|
@ -150,7 +150,7 @@ class Usb(Escpos):
|
||||
and detach_kernel_driver().
|
||||
This helps enable this library to work on Windows.
|
||||
"""
|
||||
if self._device and self.device.backend.__module__.endswith("libusb1"):
|
||||
if self.device and self.device.backend.__module__.endswith("libusb1"):
|
||||
check_driver: Optional[bool] = None
|
||||
|
||||
try:
|
||||
|
@ -114,7 +114,7 @@ class Win32Raw(Escpos):
|
||||
self.device = win32print.OpenPrinter(self.printer_name)
|
||||
if self.device:
|
||||
self.current_job = win32print.StartDocPrinter(
|
||||
self.device, 1, (job_name, None, "RAW")
|
||||
hprinter=self.device, level=1, _tuple=(job_name, None, "RAW")
|
||||
)
|
||||
win32print.StartPagePrinter(self.device)
|
||||
except (AssertionError, pywintypes.error) as e:
|
||||
|
Loading…
x
Reference in New Issue
Block a user