Deprecate pywin32-stubs, too

This commit is contained in:
belono 2023-10-14 00:44:50 +02:00
parent 72a1a10faa
commit 8f54dfed00
3 changed files with 6 additions and 9 deletions

View File

@ -68,13 +68,11 @@ cups =
pycups; platform_system!='Windows' pycups; platform_system!='Windows'
win32 = win32 =
pywin32; platform_system=='Windows' pywin32; platform_system=='Windows'
pywin32-stubs; platform_system=='Windows'
all = all =
pyusb>=1.0.0 pyusb>=1.0.0
pyserial pyserial
pycups; platform_system!='Windows' pycups; platform_system!='Windows'
pywin32; platform_system=='Windows' pywin32; platform_system=='Windows'
pywin32-stubs; platform_system=='Windows'
[flake8] [flake8]
exclude = .git,.tox,.github,.eggs,__pycache__,doc/conf.py,build,dist,capabilities-data,test,src/escpos/constants.py exclude = .git,.tox,.github,.eggs,__pycache__,doc/conf.py,build,dist,capabilities-data,test,src/escpos/constants.py

View File

@ -10,7 +10,7 @@
import functools import functools
import logging import logging
from typing import Literal, Optional, Union from typing import Literal, Optional, Type, Union
from ..escpos import Escpos from ..escpos import Escpos
from ..exceptions import DeviceNotFoundError from ..exceptions import DeviceNotFoundError
@ -20,8 +20,6 @@ _DEP_WIN32PRINT = False
try: try:
import pywintypes
import win32helper.win32typing as _win32typing # pywin32-stubs package
import win32print import win32print
_DEP_WIN32PRINT = True _DEP_WIN32PRINT = True
@ -83,7 +81,9 @@ class Win32Raw(Escpos):
self.job_name = "" self.job_name = ""
self._device: Union[ self._device: Union[
Literal[False], Literal[None], "_win32typing.PyPrinterHANDLE" Literal[False],
Literal[None],
Type[win32print.OpenPrinter],
] = False ] = False
@property @property
@ -118,14 +118,14 @@ class Win32Raw(Escpos):
assert self.printer_name in self.printers, "Incorrect printer name" assert self.printer_name in self.printers, "Incorrect printer name"
# Open device # Open device
self.device: Optional[ self.device: Optional[
"_win32typing.PyPrinterHANDLE" Type[win32print.OpenPrinter]
] = win32print.OpenPrinter(self.printer_name) ] = 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") self.device, 1, (job_name, None, "RAW")
) )
win32print.StartPagePrinter(self.device) win32print.StartPagePrinter(self.device)
except (AssertionError, pywintypes.error) as e: except AssertionError as e:
# Raise exception or log error and cancel # Raise exception or log error and cancel
self.device = None self.device = None
if raise_not_found: if raise_not_found:

View File

@ -57,7 +57,6 @@ deps = mypy
types-appdirs types-appdirs
types-Pillow types-Pillow
types-pyserial types-pyserial
; types-pywin32
hypothesis>=6.83 hypothesis>=6.83
jaconv jaconv
commands = mypy src test commands = mypy src test