46
46
"""
47
47
48
48
from __future__ import annotations
49
- from typing import Iterable
49
+
50
50
import 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
+
54
67
55
- class ServerConfig (Config ): # pylint: disable=R0902
68
+ class ServerConfig (Config ):
56
69
"""Represents configuration options specific to a named Firebird server entry.
57
70
"""
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 ):
59
72
super ().__init__ (name , optional = optional , description = description )
60
73
#: Server host machine specification
61
74
self .host : StrOption = \
@@ -87,10 +100,10 @@ def __init__(self, name: str, *, optional: bool=False, description: str=None):
87
100
self .encoding_errors : StrOption = \
88
101
StrOption ('encoding_errors' , "Handler used for encoding errors" , default = 'strict' )
89
102
90
- class DatabaseConfig (Config ): # pylint: disable=R0902
103
+ class DatabaseConfig (Config ):
91
104
"""Represents configuration options specific to a named Firebird database entry, including connection and creation parameters.
92
105
"""
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 ):
94
107
super ().__init__ (name , optional = optional , description = description )
95
108
#: Name of server where database is located
96
109
self .server : StrOption = \
@@ -218,7 +231,7 @@ def __init__(self, name: str):
218
231
#: Registered databases
219
232
self .databases : ConfigListOption = \
220
233
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 ):
222
235
"""Read configuration from a filename or an iterable of filenames.
223
236
224
237
Files that cannot be opened are silently ignored; this is
@@ -249,7 +262,7 @@ def read_string(self, string: str) -> None:
249
262
parser = ConfigParser (interpolation = EnvExtendedInterpolation ())
250
263
parser .read_string (string )
251
264
self .load_config (parser )
252
- def read_dict (self , dictionary : dict ) -> None :
265
+ def read_dict (self , dictionary : dict [ str , str ] ) -> None :
253
266
"""Read configuration from a dictionary.
254
267
255
268
Keys are section names, values are dictionaries with keys and values
@@ -276,7 +289,7 @@ def get_database(self, name: str) -> DatabaseConfig:
276
289
if db .name == name :
277
290
return db
278
291
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 :
280
293
"""Register server.
281
294
282
295
Arguments:
@@ -298,7 +311,7 @@ def register_server(self, name: str, config: str=None) -> ServerConfig:
298
311
parser .read_string (config )
299
312
srv_config .load_config (parser , name )
300
313
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 :
302
315
"""Register database.
303
316
304
317
Arguments:
0 commit comments