1
0
mirror of https://github.com/python-escpos/python-escpos synced 2025-09-13 09:09:58 +00:00

refactor set method (#547)

* add type annotations
* Update setup.cfg
* improve mypy and test config
* get_profile_class returns a baseProfile
* mute mypy type issue
* add set_with_default
* docstring
* add test for empty call
* correct type annotations in set_with_default
* improve tests
* test for exception
* sort with isort
* add default value to get call
* empty string has the same effect: will not be found --> None
* add mypy test to workflow
* explicitely call mypy
* update spelling
This commit is contained in:
Patrick Kanzler
2023-09-19 07:51:39 +02:00
committed by GitHub
parent adcde8abda
commit 6d0c475b9a
4 changed files with 236 additions and 86 deletions

View File

@@ -8,7 +8,7 @@ import time
from contextlib import ExitStack
from os import environ, path
from tempfile import mkdtemp
from typing import Any, Dict, Optional
from typing import Any, Dict, Optional, Type
import importlib_resources
import six
@@ -148,7 +148,7 @@ def get_profile(name: Optional[str] = None, **kwargs):
CLASS_CACHE = {}
def get_profile_class(name: str):
def get_profile_class(name: str) -> Type[BaseProfile]:
"""Load a profile class.
For the given profile name, load the data from the external
@@ -174,7 +174,11 @@ def clean(s):
return str(s)
class Profile(get_profile_class("default")):
# mute the mypy type issue with this dynamic base class function for now (: Any)
ProfileBaseClass: Any = get_profile_class("default")
class Profile(ProfileBaseClass):
"""Profile class for user usage.
For users, who want to provide their own profile.