diff options
author | robot-contrib <robot-contrib@yandex-team.ru> | 2022-05-18 00:43:36 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.ru> | 2022-05-18 00:43:36 +0300 |
commit | 9e5f436a8b2a27bcc7802e443ea3ef3e41a82a75 (patch) | |
tree | 78b522cab9f76336e62064d4d8ff7c897659b20e /contrib/python/ipython/py3/IPython/utils/ipstruct.py | |
parent | 8113a823ffca6451bb5ff8f0334560885a939a24 (diff) | |
download | ydb-9e5f436a8b2a27bcc7802e443ea3ef3e41a82a75.tar.gz |
Update contrib/python/ipython/py3 to 8.3.0
ref:e84342d4d30476f9148137f37fd0c6405fd36f55
Diffstat (limited to 'contrib/python/ipython/py3/IPython/utils/ipstruct.py')
-rw-r--r-- | contrib/python/ipython/py3/IPython/utils/ipstruct.py | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/contrib/python/ipython/py3/IPython/utils/ipstruct.py b/contrib/python/ipython/py3/IPython/utils/ipstruct.py index e2b3e8fa4c..ed112101a3 100644 --- a/contrib/python/ipython/py3/IPython/utils/ipstruct.py +++ b/contrib/python/ipython/py3/IPython/utils/ipstruct.py @@ -43,14 +43,13 @@ class Struct(dict): Parameters ---------- - args : dict, Struct + *args : dict, Struct Initialize with one dict or Struct - kw : dict + **kw : dict Initialize with key, value pairs. Examples -------- - >>> s = Struct(a=10,b=30) >>> s.a 10 @@ -68,7 +67,6 @@ class Struct(dict): Examples -------- - >>> s = Struct() >>> s['a'] = 10 >>> s.allow_new_attr(False) @@ -95,7 +93,6 @@ class Struct(dict): Examples -------- - >>> s = Struct() >>> s.a = 10 >>> s.a @@ -120,7 +117,7 @@ class Struct(dict): try: self.__setitem__(key, value) except KeyError as e: - raise AttributeError(e) + raise AttributeError(e) from e def __getattr__(self, key): """Get an attr by calling :meth:`dict.__getitem__`. @@ -130,12 +127,11 @@ class Struct(dict): Examples -------- - >>> s = Struct(a=10) >>> s.a 10 >>> type(s.get) - <... 'builtin_function_or_method'> + <...method'> >>> try: ... s.b ... except AttributeError: @@ -145,8 +141,8 @@ class Struct(dict): """ try: result = self[key] - except KeyError: - raise AttributeError(key) + except KeyError as e: + raise AttributeError(key) from e else: return result @@ -155,7 +151,6 @@ class Struct(dict): Examples -------- - >>> s = Struct(a=10,b=30) >>> s2 = Struct(a=20,c=40) >>> s += s2 @@ -170,7 +165,6 @@ class Struct(dict): Examples -------- - >>> s1 = Struct(a=10,b=30) >>> s2 = Struct(a=20,c=40) >>> s = s1 + s2 @@ -186,7 +180,6 @@ class Struct(dict): Examples -------- - >>> s1 = Struct(a=10,b=30) >>> s2 = Struct(a=40) >>> s = s1 - s2 @@ -202,7 +195,6 @@ class Struct(dict): Examples -------- - >>> s1 = Struct(a=10,b=30) >>> s2 = Struct(a=40) >>> s1 -= s2 @@ -236,7 +228,6 @@ class Struct(dict): Examples -------- - >>> s = Struct(a=10,b=30) >>> s2 = s.copy() >>> type(s2) is Struct @@ -251,7 +242,6 @@ class Struct(dict): Examples -------- - >>> s = Struct(a=10) >>> s.hasattr('a') True @@ -284,7 +274,7 @@ class Struct(dict): Parameters ---------- - __loc_data : dict, Struct + __loc_data__ : dict, Struct The data to merge into self __conflict_solve : dict The conflict policy dict. The keys are binary functions used to @@ -292,12 +282,11 @@ class Struct(dict): the keys the conflict resolution function applies to. Instead of a list of strings a space separated string can be used, like 'a b c'. - kw : dict + **kw : dict Additional key, value pairs to merge in Notes ----- - The `__conflict_solve` dict is a dictionary of binary functions which will be used to solve key conflicts. Here is an example:: @@ -338,7 +327,6 @@ class Struct(dict): Examples -------- - This show the default policy: >>> s = Struct(a=10,b=30) |