Skip to content

Commit

Permalink
Extend type signature to fix warnings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lucc committed Nov 17, 2023
1 parent b2d767e commit e0f0cf1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions khard/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Loading and validation of the configuration file"""

from argparse import Namespace
import io
import locale
import logging
import os
Expand All @@ -22,6 +23,10 @@


logger = logging.getLogger(__name__)
# This is the type of the config file parameter accepted by the configobj
# library:
# https://configobj.readthedocs.io/en/latest/configobj.html#reading-a-config-file
ConfigFile = Union[str, List[str], io.StringIO]


class ConfigError(Exception):
Expand Down Expand Up @@ -88,7 +93,7 @@ class Config:

supported_vcard_versions = ("3.0", "4.0")

def __init__(self, config_file: Optional[str] = None) -> None:
def __init__(self, config_file: Optional[ConfigFile] = None) -> None:
self.config: configobj.ConfigObj
self.abooks: AddressBookCollection
locale.setlocale(locale.LC_ALL, '')
Expand All @@ -97,7 +102,7 @@ def __init__(self, config_file: Optional[str] = None) -> None:
self._set_attributes()

@classmethod
def _load_config_file(cls, config_file: Optional[str]
def _load_config_file(cls, config_file: Optional[ConfigFile]
) -> configobj.ConfigObj:
"""Find and load the config file.
Expand Down

0 comments on commit e0f0cf1

Please sign in to comment.