4646"""
4747
4848from __future__ import annotations
49- from typing import Iterable
49+
5050import os
51- from firebird .base .config import Config , StrOption , IntOption , BoolOption , EnumOption , \
52- ConfigListOption , ListOption , ConfigParser , EnvExtendedInterpolation
53- from .types import NetProtocol , DecfloatRound , DecfloatTraps
51+ from collections .abc import Iterable
52+
53+ from firebird .base .config import (
54+ BoolOption ,
55+ Config ,
56+ ConfigListOption ,
57+ ConfigParser ,
58+ EnumOption ,
59+ EnvExtendedInterpolation ,
60+ IntOption ,
61+ ListOption ,
62+ StrOption ,
63+ )
64+
65+ from .types import DecfloatRound , DecfloatTraps , NetProtocol
66+
5467
55- class ServerConfig (Config ): # pylint: disable=R0902
68+ class ServerConfig (Config ):
5669 """Represents configuration options specific to a named Firebird server entry.
5770 """
58- def __init__ (self , name : str , * , optional : bool = False , description : str = None ):
71+ def __init__ (self , name : str , * , optional : bool = False , description : str | None = None ):
5972 super ().__init__ (name , optional = optional , description = description )
6073 #: Server host machine specification
6174 self .host : StrOption = \
@@ -87,10 +100,10 @@ def __init__(self, name: str, *, optional: bool=False, description: str=None):
87100 self .encoding_errors : StrOption = \
88101 StrOption ('encoding_errors' , "Handler used for encoding errors" , default = 'strict' )
89102
90- class DatabaseConfig (Config ): # pylint: disable=R0902
103+ class DatabaseConfig (Config ):
91104 """Represents configuration options specific to a named Firebird database entry, including connection and creation parameters.
92105 """
93- def __init__ (self , name : str , * , optional : bool = False , description : str = None ):
106+ def __init__ (self , name : str , * , optional : bool = False , description : str | None = None ):
94107 super ().__init__ (name , optional = optional , description = description )
95108 #: Name of server where database is located
96109 self .server : StrOption = \
@@ -218,7 +231,7 @@ def __init__(self, name: str):
218231 #: Registered databases
219232 self .databases : ConfigListOption = \
220233 ConfigListOption ('databases' , DatabaseConfig , "Registered databases" )
221- def read (self , filenames : str | Iterable , encoding : str = None ):
234+ def read (self , filenames : str | Iterable , encoding : str | None = None ):
222235 """Read configuration from a filename or an iterable of filenames.
223236
224237 Files that cannot be opened are silently ignored; this is
@@ -249,7 +262,7 @@ def read_string(self, string: str) -> None:
249262 parser = ConfigParser (interpolation = EnvExtendedInterpolation ())
250263 parser .read_string (string )
251264 self .load_config (parser )
252- def read_dict (self , dictionary : dict ) -> None :
265+ def read_dict (self , dictionary : dict [ str , str ] ) -> None :
253266 """Read configuration from a dictionary.
254267
255268 Keys are section names, values are dictionaries with keys and values
@@ -276,7 +289,7 @@ def get_database(self, name: str) -> DatabaseConfig:
276289 if db .name == name :
277290 return db
278291 return None
279- def register_server (self , name : str , config : str = None ) -> ServerConfig :
292+ def register_server (self , name : str , config : str | None = None ) -> ServerConfig :
280293 """Register server.
281294
282295 Arguments:
@@ -298,7 +311,7 @@ def register_server(self, name: str, config: str=None) -> ServerConfig:
298311 parser .read_string (config )
299312 srv_config .load_config (parser , name )
300313 return srv_config
301- def register_database (self , name : str , config : str = None ) -> DatabaseConfig :
314+ def register_database (self , name : str , config : str | None = None ) -> DatabaseConfig :
302315 """Register database.
303316
304317 Arguments:
0 commit comments