File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -128,11 +128,16 @@ def __getitem__(self, key):
128128
129129 def __setitem__ (self , key , value ):
130130 try :
131- setattr (self , key , value )
131+ self .__setattr__ (key , value )
132+ except AttributeError as err :
133+ raise KeyError (* err .args ) from None
134+
135+ def __delitem__ (self , key ):
136+ try :
137+ self .__delattr__ (key )
132138 except AttributeError as err :
133139 raise KeyError (* err .args ) from None
134140
135- __delitem__ = __delattr__
136141 _ipython_key_completions_ = __dir__ # config["<TAB>
137142
138143 # Go ahead and make it a `collections.abc.Mapping`
Original file line number Diff line number Diff line change @@ -169,6 +169,10 @@ class FlexibleConfig(Config, strict=False):
169169 del cfg ["y" ]
170170 assert len (cfg ) == 0
171171 assert list (cfg ) == []
172+ with pytest .raises (AttributeError , match = "y" ):
173+ del cfg .y
174+ with pytest .raises (KeyError , match = "y" ):
175+ del cfg ["y" ]
172176 with pytest .raises (TypeError , match = "missing 1 required keyword-only" ):
173177 FlexibleConfig ()
174178 # Be strict when first creating the config object
You can’t perform that action at this time.
0 commit comments