diff --git a/examples/weather.py b/examples/weather.py index 795d092..f920305 100644 --- a/examples/weather.py +++ b/examples/weather.py @@ -18,8 +18,8 @@ import calendar import json import os import time -from urllib.request import urlopen from datetime import datetime +from urllib.request import urlopen from escpos.printer import Usb diff --git a/src/escpos/cli.py b/src/escpos/cli.py index 2b91634..e7cc826 100644 --- a/src/escpos/cli.py +++ b/src/escpos/cli.py @@ -578,9 +578,7 @@ def main() -> None: if not args_dict: parser.print_help() sys.exit() - command_arguments = dict( - [k, v] for k, v in args_dict.items() if v is not None - ) + command_arguments = dict([k, v] for k, v in args_dict.items() if v is not None) # If version should be printed, do this, then exit print_version = command_arguments.pop("version", None) diff --git a/src/escpos/config.py b/src/escpos/config.py index 3682c23..5b72764 100644 --- a/src/escpos/config.py +++ b/src/escpos/config.py @@ -46,7 +46,7 @@ class Config: self._printer_name = None self._printer_config = None - def load(self, config_path = None): + def load(self, config_path=None): """Load and parse the configuration file using pyyaml. :param config_path: An optional file path, file handle, or byte string diff --git a/src/escpos/constants.py b/src/escpos/constants.py index fb05502..c435bcc 100644 --- a/src/escpos/constants.py +++ b/src/escpos/constants.py @@ -46,9 +46,7 @@ HW_RESET: bytes = ESC + b"\x3f\x0a\x00" # Reset printer hardware # (TODO: Where is this specified?) # Cash Drawer (ESC p ) -_CASH_DRAWER = ( - lambda m, t1="", t2="": ESC + b"p" + m + bytes((t1, t2)) -) +_CASH_DRAWER = lambda m, t1="", t2="": ESC + b"p" + m + bytes((t1, t2)) #: decimal cash drawer kick sequence CD_KICK_DEC_SEQUENCE = ( diff --git a/src/escpos/escpos.py b/src/escpos/escpos.py index 8816c98..36d4303 100644 --- a/src/escpos/escpos.py +++ b/src/escpos/escpos.py @@ -16,7 +16,7 @@ import warnings from abc import ABCMeta, abstractmethod # abstract base class support from re import match as re_match from types import TracebackType -from typing import List, Literal, Optional, Union, Any +from typing import Any, List, Literal, Optional, Union import barcode import qrcode @@ -857,7 +857,7 @@ class Escpos(object, metaclass=ABCMeta): image = my_code.writer._image self.image(image, impl=impl, center=center) - def text(self, txt:str) -> None: + def text(self, txt: str) -> None: """Print alpha-numeric text. The text has to be encoded in the currently selected codepage. @@ -1297,7 +1297,7 @@ class Escpos(object, metaclass=ABCMeta): return False return not (status[0] & RT_MASK_ONLINE) - def paper_status(self) -> int: # could be IntEnum + def paper_status(self) -> int: # could be IntEnum """Query the paper status of the printer. Returns 2 if there is plenty of paper, 1 if the paper has arrived to @@ -1443,15 +1443,12 @@ class EscposIO: """ self.printer.close() - def __enter__(self, **kwargs: Any) -> 'EscposIO': + def __enter__(self, **kwargs: Any) -> "EscposIO": """Enter context.""" return self def __exit__( - self, - type: type[BaseException], - value: BaseException, - traceback: TracebackType + self, type: type[BaseException], value: BaseException, traceback: TracebackType ) -> None: """Cut and close if configured. diff --git a/src/escpos/exceptions.py b/src/escpos/exceptions.py index d8e28cc..2b3e98c 100644 --- a/src/escpos/exceptions.py +++ b/src/escpos/exceptions.py @@ -39,7 +39,7 @@ class Error(Exception): """ - def __init__(self, msg:str, status: Optional[int] = None) -> None: + def __init__(self, msg: str, status: Optional[int] = None) -> None: """Initialize Error object.""" Exception.__init__(self) self.msg = msg diff --git a/src/escpos/image.py b/src/escpos/image.py index 6907078..6be9f0f 100644 --- a/src/escpos/image.py +++ b/src/escpos/image.py @@ -10,7 +10,7 @@ This module contains the image format handler :py:class:`EscposImage`. import math -from typing import Union, Iterator +from typing import Iterator, Union from PIL import Image, ImageOps diff --git a/src/escpos/printer/cups.py b/src/escpos/printer/cups.py index faae161..527523a 100644 --- a/src/escpos/printer/cups.py +++ b/src/escpos/printer/cups.py @@ -11,7 +11,7 @@ import functools import logging import tempfile -from typing import Literal, Optional, Type, Union, List +from typing import List, Literal, Optional, Type, Union from ..escpos import Escpos from ..exceptions import DeviceNotFoundError