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