cdxcore 0.1.10__py3-none-any.whl → 0.1.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cdxcore might be problematic. Click here for more details.

cdxcore/err.py CHANGED
@@ -95,6 +95,11 @@ def _fmt( text : str, args = None, kwargs = None, f : Callable = None ) -> str:
95
95
  return text % tuple(args)
96
96
  except TypeError as e:
97
97
  raise TypeError(e, text, args)
98
+
99
+ # no keyword arguments --> must be plain text
100
+ if kwargs is None:
101
+ return text
102
+
98
103
  # text
99
104
  # python 2 and 3 mode
100
105
  kwargs = dict() if kwargs is None else kwargs
@@ -117,7 +122,7 @@ def fmt(text : str|Callable, * args, ** kwargs) -> str:
117
122
  one = 1
118
123
  fmt(lambda : f"one {one:d}) # using a lambda function
119
124
  fmt("one {one:d}", one=one) # using python 3 string.format()
120
- fmt("one %{one}ld", one=one) # using python 2 style
125
+ fmt("one %(one)ld", one=one) # using python 2 style
121
126
  fmt("one %ld", one) # using c-style
122
127
 
123
128
  As shown, do not use f-strings directly as they are immediately executed in the scope they are typed in
@@ -164,7 +169,7 @@ def error( text : str|Callable, *args, exception : Exception = RuntimeError, **k
164
169
  one = 1
165
170
  error(lambda : f"one {one:d}") # wrapped f-string
166
171
  error("one {one:d}", one=one) # using python 3 string.format()
167
- error("one %{one}ld", one=one) # using python 2 style
172
+ error("one %(one)ld", one=one) # using python 2 style
168
173
  error("one %ld", one) # using c-style
169
174
 
170
175
  As shown, do not use f-strings directly as they are immediately executed in the scope they are typed in
@@ -214,7 +219,7 @@ def verify( cond : bool, text : str|Callable, *args, exception : Exception = Run
214
219
  good = False # some condition
215
220
  verify(good, lambda : f"one {one:d}") # wrapped f-string
216
221
  verify(good, "one {one:d}", one=one) # using python 3 string.format()
217
- verify(good, "one %{one}ld", one=one) # using python 2 style
222
+ verify(good, "one %(one)ld", one=one) # using python 2 style
218
223
  verify(good, "one %ld", one) # using c-style
219
224
 
220
225
  As shown, do not use f-strings directly as they are immediately executed in the scope they are typed in
@@ -268,7 +273,7 @@ def warn( text : str|Callable, *args, warning = RuntimeWarning, stack_level : in
268
273
  one = 1
269
274
  warn(lambda : f"one {one:d}") # wrapped f-string
270
275
  warn("one {one:d}", one=one) # using python 3 string.format()
271
- warn("one %{one}ld", one=one) # using python 2 style
276
+ warn("one %(one)ld", one=one) # using python 2 style
272
277
  warn("one %ld", one) # using c-style
273
278
 
274
279
  As shown, do not use f-strings directly as they are immediately executed in the scope they are typed in
@@ -322,7 +327,7 @@ def warn_if( cond : bool, text : str|Callable, *args, warning = RuntimeWarning,
322
327
  bad = True # some conditon
323
328
  warn_if(bad,lambda : f"one {one:d}") # wrapped f-string
324
329
  warn_if(bad,"one {one:d}", one=one) # using python 3 string.format()
325
- warn_if(bad,"one %{one}ld", one=one) # using python 2 style
330
+ warn_if(bad,"one %(one)ld", one=one) # using python 2 style
326
331
  warn_if(bad,"one %ld", one) # using c-style
327
332
 
328
333
  As shown, do not use f-strings directly as they are immediately executed in the scope they are typed in