@@ -119,6 +119,69 @@ def __repr__(self) -> str:
119119 """
120120 return f"{ self .__class__ .__name__ } ({ self ._config } )"
121121
122+ def __items__ (self ):
123+ """
124+ Iterate over the configuration items.
125+
126+ :return: Iterator over configuration items.
127+ """
128+ return self ._config .items ()
129+
130+ def __iter__ (self ):
131+ """
132+ Iterate over the configuration keys.
133+
134+ :return: Iterator over configuration keys.
135+ """
136+ return iter (self ._config )
137+
138+ def __len__ (self ) -> int :
139+ """
140+ Get the number of configuration items.
141+
142+ :return: Number of configuration items.
143+ """
144+ return len (self ._config )
145+
146+ def __getitem__ (self , key : str ) -> Any :
147+ """
148+ Get the value of a configuration key.
149+
150+ :param key: Configuration key.
151+ :return: Configuration value.
152+ """
153+ return self .get (key )
154+
155+ def __setitem__ (self , key : str , value : Any ) -> 'BaseConfig' :
156+ """
157+ Set the value of a configuration key.
158+
159+ :param key: Configuration key.
160+ :param value: Configuration value.
161+ """
162+ return self .set (key , value )
163+
164+ def __delitem__ (self , key : str ) -> 'BaseConfig' :
165+ """
166+ Remove a configuration key.
167+
168+ :param key: Configuration key.
169+ """
170+ return self .remove (key )
171+
172+ def __contains__ (self , key : str ) -> bool :
173+ """
174+ Check if a key exists in the configuration.
175+
176+ :param key: Configuration key.
177+ :return: True if the key exists, False otherwise.
178+ """
179+ try :
180+ self .get (key )
181+ return True
182+ except KeyError :
183+ return False
184+
122185class FileConfig (BaseConfig , ABC ):
123186 """
124187 File configuration management class.
0 commit comments