mirror of
				https://github.com/python-escpos/python-escpos
				synced 2025-10-23 09:30:00 +00:00 
			
		
		
		
	Add default value to all params + type annotations
This commit is contained in:
		@@ -129,7 +129,7 @@ class Escpos(object):
 | 
			
		||||
        self.close()
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def device(self):
 | 
			
		||||
    def device(self) -> object:
 | 
			
		||||
        """Implements a self-open mechanism.
 | 
			
		||||
 | 
			
		||||
        An attempt to get the property before open the connection
 | 
			
		||||
 
 | 
			
		||||
@@ -24,6 +24,7 @@ try:
 | 
			
		||||
    DEFAULT_HOST = cups.getServer()
 | 
			
		||||
    DEFAULT_PORT = cups.getPort()
 | 
			
		||||
except ImportError:
 | 
			
		||||
    print("Error")
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -81,7 +82,7 @@ class CupsPrinter(Escpos):
 | 
			
		||||
        return is_usable()
 | 
			
		||||
 | 
			
		||||
    @dependency_pycups
 | 
			
		||||
    def __init__(self, printer_name=None, *args, **kwargs):
 | 
			
		||||
    def __init__(self, printer_name: str = "", *args, **kwargs):
 | 
			
		||||
        """Class constructor for CupsPrinter.
 | 
			
		||||
 | 
			
		||||
        :param printer_name: CUPS printer name (Optional)
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,9 @@ class File(Escpos):
 | 
			
		||||
        """
 | 
			
		||||
        return is_usable()
 | 
			
		||||
 | 
			
		||||
    def __init__(self, devfile="/dev/usb/lp0", auto_flush=True, *args, **kwargs):
 | 
			
		||||
    def __init__(
 | 
			
		||||
        self, devfile: str = "/dev/usb/lp0", auto_flush: bool = True, *args, **kwargs
 | 
			
		||||
    ):
 | 
			
		||||
        """Initialize file printer with device file.
 | 
			
		||||
 | 
			
		||||
        :param devfile: Device file under dev filesystem
 | 
			
		||||
 
 | 
			
		||||
@@ -61,7 +61,7 @@ class LP(Escpos):
 | 
			
		||||
        """
 | 
			
		||||
        return is_usable()
 | 
			
		||||
 | 
			
		||||
    def __init__(self, printer_name: str, *args, **kwargs):
 | 
			
		||||
    def __init__(self, printer_name: str = "", *args, **kwargs):
 | 
			
		||||
        """LP class constructor.
 | 
			
		||||
 | 
			
		||||
        :param printer_name: CUPS printer name (Optional)
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,7 @@
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
import socket
 | 
			
		||||
from typing import Union
 | 
			
		||||
 | 
			
		||||
from ..escpos import Escpos
 | 
			
		||||
 | 
			
		||||
@@ -50,7 +51,14 @@ class Network(Escpos):
 | 
			
		||||
        """
 | 
			
		||||
        return is_usable()
 | 
			
		||||
 | 
			
		||||
    def __init__(self, host, port=9100, timeout=60, *args, **kwargs):
 | 
			
		||||
    def __init__(
 | 
			
		||||
        self,
 | 
			
		||||
        host: str = None,
 | 
			
		||||
        port: int = 9100,
 | 
			
		||||
        timeout: Union[int, float] = 60,
 | 
			
		||||
        *args,
 | 
			
		||||
        **kwargs
 | 
			
		||||
    ):
 | 
			
		||||
        """Initialize network printer.
 | 
			
		||||
 | 
			
		||||
        :param host:    Printer's hostname or IP address
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import functools
 | 
			
		||||
from typing import Union
 | 
			
		||||
 | 
			
		||||
from ..escpos import Escpos
 | 
			
		||||
 | 
			
		||||
@@ -73,14 +74,14 @@ class Serial(Escpos):
 | 
			
		||||
    @dependency_pyserial
 | 
			
		||||
    def __init__(
 | 
			
		||||
        self,
 | 
			
		||||
        devfile="/dev/ttyS0",
 | 
			
		||||
        baudrate=9600,
 | 
			
		||||
        bytesize=8,
 | 
			
		||||
        timeout=1,
 | 
			
		||||
        parity=None,
 | 
			
		||||
        stopbits=None,
 | 
			
		||||
        xonxoff=False,
 | 
			
		||||
        dsrdtr=True,
 | 
			
		||||
        devfile: str = "/dev/ttyS0",
 | 
			
		||||
        baudrate: int = 9600,
 | 
			
		||||
        bytesize: int = 8,
 | 
			
		||||
        timeout: Union[int, float] = 1,
 | 
			
		||||
        parity=None,  # type: str?
 | 
			
		||||
        stopbits=None,  # type: int?
 | 
			
		||||
        xonxoff: bool = False,
 | 
			
		||||
        dsrdtr: bool = True,
 | 
			
		||||
        *args,
 | 
			
		||||
        **kwargs
 | 
			
		||||
    ):
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@
 | 
			
		||||
:license: MIT
 | 
			
		||||
"""
 | 
			
		||||
import functools
 | 
			
		||||
from typing import Dict, Union
 | 
			
		||||
 | 
			
		||||
from ..escpos import Escpos
 | 
			
		||||
from ..exceptions import USBNotFoundError
 | 
			
		||||
@@ -72,12 +73,12 @@ class Usb(Escpos):
 | 
			
		||||
 | 
			
		||||
    def __init__(
 | 
			
		||||
        self,
 | 
			
		||||
        idVendor,
 | 
			
		||||
        idProduct,
 | 
			
		||||
        usb_args=None,
 | 
			
		||||
        timeout=0,
 | 
			
		||||
        in_ep=0x82,
 | 
			
		||||
        out_ep=0x01,
 | 
			
		||||
        idVendor: str = "",
 | 
			
		||||
        idProduct: str = "",
 | 
			
		||||
        usb_args: Dict[str, str] = {},
 | 
			
		||||
        timeout: Union[int, float] = 0,
 | 
			
		||||
        in_ep=0x82,  # type: int?
 | 
			
		||||
        out_ep=0x01,  # type: int?
 | 
			
		||||
        *args,
 | 
			
		||||
        **kwargs
 | 
			
		||||
    ):
 | 
			
		||||
 
 | 
			
		||||
@@ -70,7 +70,7 @@ class Win32Raw(Escpos):
 | 
			
		||||
        return is_usable()
 | 
			
		||||
 | 
			
		||||
    @dependency_win32print
 | 
			
		||||
    def __init__(self, printer_name=None, *args, **kwargs):
 | 
			
		||||
    def __init__(self, printer_name: str = "", *args, **kwargs):
 | 
			
		||||
        """Initialize default printer."""
 | 
			
		||||
        Escpos.__init__(self, *args, **kwargs)
 | 
			
		||||
        if printer_name is not None:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user