peek-python 25.0.7__tar.gz → 25.0.8__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: peek-python
3
- Version: 25.0.7
3
+ Version: 25.0.8
4
4
  Summary: peek - debugging and benchmarking made easy
5
5
  Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/salabim/peek
@@ -4,7 +4,7 @@
4
4
  # | .__/ \___| \___||_|\_\
5
5
  # |_| like print, but easy.
6
6
 
7
- __version__ = "25.0.7"
7
+ __version__ = "25.0.8"
8
8
 
9
9
  """
10
10
  See https://github.com/salabim/peek for details
@@ -145,6 +145,10 @@ class _Peek:
145
145
 
146
146
  codes = {}
147
147
 
148
+ # @staticmethod
149
+ # def reset(): # for Pythonista problems. Solved?
150
+ # _Peek.codes={}
151
+
148
152
  @staticmethod
149
153
  def de_alias(name):
150
154
  return _Peek.alias_name.get(name, name)
@@ -154,7 +158,7 @@ class _Peek:
154
158
  name_org = name
155
159
  name = _Peek.de_alias(name)
156
160
  if name not in _Peek.name_default:
157
- raise AttributeError(f"attribute {name} not allowed{_Peek.in_read_toml_message}")
161
+ raise AttributeError(f"attribute {name_org} not allowed{_Peek.in_read_toml_message}")
158
162
 
159
163
  if value is None:
160
164
  return
@@ -170,17 +174,17 @@ class _Peek:
170
174
  pass
171
175
  raise AttributeError("output should be a callable, str, Path or open text file.")
172
176
 
173
- if name == "serialize":
177
+ elif name == "serialize":
174
178
  if callable(value):
175
179
  return
176
180
 
177
- if name in ("color", "color_value"):
181
+ elif name in ("color", "color_value"):
178
182
  if isinstance(value, str) and value in _Peek._color_name_to_ANSI:
179
183
  return
180
184
 
181
- elif name == "delta":
182
- if isinstance(value, numbers.Number):
183
- return
185
+ elif name == "delta":
186
+ if isinstance(value, numbers.Number):
187
+ return
184
188
 
185
189
  elif name == "line_length":
186
190
  if isinstance(value, numbers.Number) and value > 0:
@@ -383,6 +387,7 @@ class _Peek:
383
387
  args = [this.separator_print.join(map(str, args))]
384
388
 
385
389
  if len(args) != 0 and not this.do_show():
390
+ # if there are no args, the checks for decorator and context manager always to be done
386
391
  if as_str:
387
392
  return ""
388
393
  else:
@@ -436,18 +441,17 @@ class _Peek:
436
441
  else:
437
442
  line_number = frame_info.lineno
438
443
 
439
- # parent_function = frame_info.function
440
- parent_function = executing.Source.executing(call_frame).code_qualname() # changed in version 1.3.10 to include class name
444
+ parent_function = executing.Source.executing(call_frame).code_qualname()
441
445
  parent_function = parent_function.replace(".<locals>.", ".")
442
446
  if parent_function == "<module>" or str(this.show_line_number) in ("n", "no parent"):
443
447
  parent_function = ""
444
448
  else:
445
449
  parent_function = f" in {parent_function}()"
446
- if 0 <= line_number - 1 < len(code):
450
+ if 0 <= line_number - 1 < len(code) - 1:
447
451
  this_line = code[line_number - 1].strip()
448
452
  else:
449
453
  this_line = ""
450
- if 0 <= line_number - 2 < len(code):
454
+ if 0 <= line_number - 2 < len(code) - 2:
451
455
  this_line_prev = code[line_number - 2].strip()
452
456
  else:
453
457
  this_line_prev = ""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: peek-python
3
- Version: 25.0.7
3
+ Version: 25.0.8
4
4
  Summary: peek - debugging and benchmarking made easy
5
5
  Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/salabim/peek
@@ -10,7 +10,7 @@ authors = [
10
10
  { name = "Ruud van der Ham", email = "rt.van.der.ham@gmail.com" },
11
11
  ]
12
12
  description = "peek - debugging and benchmarking made easy"
13
- version = "25.0.7"
13
+ version = "25.0.8"
14
14
  readme = "README.md"
15
15
  requires-python = ">=3.7"
16
16
  dependencies = [
@@ -282,12 +282,10 @@ def test_show_delta(capsys):
282
282
  assert "delta=" in out
283
283
 
284
284
 
285
- def test_as_str(capsys):
285
+ def test_as_str():
286
286
  hello = "world"
287
287
  s = peek(hello, as_str=True, color="red")
288
- peek(hello, color="red")
289
- out, err = capsys.readouterr()
290
- assert out == s
288
+ assert s == f"{red}hello='world'{reset}\n"
291
289
 
292
290
  with pytest.raises(TypeError):
293
291
 
@@ -409,6 +407,7 @@ lines=
409
407
  )
410
408
 
411
409
 
410
+ @pytest.mark.skipif(Pythonista, reason="Pythonista does not use escape sequences for color")
412
411
  def test_filter(capsys):
413
412
  def gen():
414
413
  for level, color in enumerate("- blue red green blue".split()):
@@ -1189,3 +1188,4 @@ hello='world'
1189
1188
 
1190
1189
  if __name__ == "__main__":
1191
1190
  pytest.main(["-vv", "-s", "-x", __file__])
1191
+
File without changes
File without changes
File without changes