peek-python 1.5.1__tar.gz → 1.5.2__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.1
2
2
  Name: peek-python
3
- Version: 1.5.1
3
+ Version: 1.5.2
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/ycecream
@@ -985,17 +985,15 @@ The parent function can be suppressed by setting `show_line_number` or `sln` to
985
985
 
986
986
  # Configuring at import time
987
987
 
988
- It can be useful to configure peek at import time. This can be done by providing a `peek.json` file which
988
+ It can be useful to configure peek at import time. This can be done by providing a `peek.toml` file which
989
989
  can contain any attribute configuration overriding the standard settings.
990
- E.g. if there is an `peek.json` file with the following contents
990
+ E.g. if there is an `peek.toml` file with the following contents
991
991
 
992
992
  ```
993
- {
994
- "o": "stderr",
995
- "show_time": true,
996
- "line_length": 80`
997
- 'compact' : true
998
- }
993
+ outpout = "stderr"
994
+ show_time = true
995
+ ll = 160
996
+ compact = true
999
997
  ```
1000
998
  in the same folder as the application, this program:
1001
999
  ```
@@ -1006,24 +1004,21 @@ will print to stderr (rather than stdout):
1006
1004
  ```
1007
1005
  @ 14:53:41.392190 ==> hello='world'
1008
1006
  ```
1009
- At import time the sys.path will be searched for, in that order, to find a `peek.json` file and use that. This means that
1010
- you can place a `peek.json` file in the site-packages folder where `peek` is installed to always use
1011
- these modified settings.
1007
+ At import time current directory will be searched for `peek.toml` and if not found, one level up, etc. until the root directory is reached.
1012
1008
 
1013
- Please observe that json values are slightly different from their Python equivalents:
1009
+ Please observe that toml values are slightly different from their Python equivalents:
1014
1010
  ```
1015
- -------------------------------
1016
- Python json
1017
- -------------------------------
1011
+ -----------------------------------
1012
+ Python toml
1013
+ -----------------------------------
1018
1014
  True true
1019
1015
  False false
1020
- None none
1021
- strings always double quoted
1022
- -------------------------------
1016
+ strings preferably double quoted
1017
+ -----------------------------------
1023
1018
  ```
1024
1019
  Note that not-specified attributes will remain the default settings.
1025
1020
 
1026
- For obvious reasons, it is not possible to specify `serialize` in an peek.json file.
1021
+ For obvious reasons, it is not possible to specify `serialize` in a peek.toml file.
1027
1022
 
1028
1023
  # Working with multiple instances of peek
1029
1024
 
@@ -1037,10 +1032,10 @@ THere are several ways to obtain a new instance of peek:
1037
1032
  * by using `peek.new()`
1038
1033
 
1039
1034
  With this a new peek object is created with the default attributes
1040
- and possibly peek.json overrides.
1041
- * by using `peek.new(ignore_json=True)`
1035
+ and possibly peek.toml overrides.
1036
+ * by using `peek.new(ignore_toml=True)`
1042
1037
 
1043
- With this a new peekobject is created with the default attibutes. Any peek.json files asre ignored.
1038
+ With this a new peekobject is created with the default attibutes. Any peek.toml files asre ignored.
1044
1039
  * by using `peek.fork()`
1045
1040
 
1046
1041
  With this a new peek object is created with the same attributes as the object it is created ('the parent') from. Note that any non set attributes are copied (propagated) from the parent.
@@ -1083,22 +1078,22 @@ hello == 'world'
1083
1078
  peek_cm exit in 0.001843 seconds
1084
1079
  ```
1085
1080
 
1086
- ## ignore_json
1087
- With `peek.new(ignore_json=True)` an instance of peek without having applied any json configuration file will be returned. That can be useful when guaranteeing the same output in several setups.
1081
+ ## ignore_toml
1082
+ With `peek.new(ignore_toml=True)` an instance of peek without having applied any toml configuration file will be returned. That can be useful when guaranteeing the same output in several setups.
1088
1083
 
1089
1084
  ### Example
1090
- Suppose we have a `peek.json` file in the current directory with the contents
1085
+ Suppose we have a `peek.toml` file in the current directory with the contents
1091
1086
  ```
1092
1087
  {prefix="==>"}
1093
1088
  ```
1094
1089
  Then
1095
1090
  ```
1096
- peek_post_json = peek.new()
1097
- peek_ignore_json = peek.new(ignore_json=True)
1091
+ peek_post_toml = peek.new()
1092
+ peek_ignore_toml = peek.new(ignore_toml=True)
1098
1093
  hello = "world"
1099
1094
  peek(hello)
1100
- peek_post_json(hello)
1101
- peek_ignore_json(hello)
1095
+ peek_post_toml(hello)
1096
+ peek_ignore_toml(hello)
1102
1097
  ```
1103
1098
  prints
1104
1099
  ```
@@ -1192,9 +1187,8 @@ supports compact, indent,
1192
1187
  and underscore_numbers
1193
1188
  parameters of pprint yes **) no
1194
1189
  use from a REPL limited functionality no
1195
- external configuration via json file no
1190
+ external configuration via toml file no
1196
1191
  observes line_length correctly yes no
1197
- default line length 160 80
1198
1192
  benchmarking functionality yes no
1199
1193
  suppress f-strings at left hand optional no
1200
1194
  indentation 4 blanks (overridable) dependent on length of prefix
@@ -971,17 +971,15 @@ The parent function can be suppressed by setting `show_line_number` or `sln` to
971
971
 
972
972
  # Configuring at import time
973
973
 
974
- It can be useful to configure peek at import time. This can be done by providing a `peek.json` file which
974
+ It can be useful to configure peek at import time. This can be done by providing a `peek.toml` file which
975
975
  can contain any attribute configuration overriding the standard settings.
976
- E.g. if there is an `peek.json` file with the following contents
976
+ E.g. if there is an `peek.toml` file with the following contents
977
977
 
978
978
  ```
979
- {
980
- "o": "stderr",
981
- "show_time": true,
982
- "line_length": 80`
983
- 'compact' : true
984
- }
979
+ outpout = "stderr"
980
+ show_time = true
981
+ ll = 160
982
+ compact = true
985
983
  ```
986
984
  in the same folder as the application, this program:
987
985
  ```
@@ -992,24 +990,21 @@ will print to stderr (rather than stdout):
992
990
  ```
993
991
  @ 14:53:41.392190 ==> hello='world'
994
992
  ```
995
- At import time the sys.path will be searched for, in that order, to find a `peek.json` file and use that. This means that
996
- you can place a `peek.json` file in the site-packages folder where `peek` is installed to always use
997
- these modified settings.
993
+ At import time current directory will be searched for `peek.toml` and if not found, one level up, etc. until the root directory is reached.
998
994
 
999
- Please observe that json values are slightly different from their Python equivalents:
995
+ Please observe that toml values are slightly different from their Python equivalents:
1000
996
  ```
1001
- -------------------------------
1002
- Python json
1003
- -------------------------------
997
+ -----------------------------------
998
+ Python toml
999
+ -----------------------------------
1004
1000
  True true
1005
1001
  False false
1006
- None none
1007
- strings always double quoted
1008
- -------------------------------
1002
+ strings preferably double quoted
1003
+ -----------------------------------
1009
1004
  ```
1010
1005
  Note that not-specified attributes will remain the default settings.
1011
1006
 
1012
- For obvious reasons, it is not possible to specify `serialize` in an peek.json file.
1007
+ For obvious reasons, it is not possible to specify `serialize` in a peek.toml file.
1013
1008
 
1014
1009
  # Working with multiple instances of peek
1015
1010
 
@@ -1023,10 +1018,10 @@ THere are several ways to obtain a new instance of peek:
1023
1018
  * by using `peek.new()`
1024
1019
 
1025
1020
  With this a new peek object is created with the default attributes
1026
- and possibly peek.json overrides.
1027
- * by using `peek.new(ignore_json=True)`
1021
+ and possibly peek.toml overrides.
1022
+ * by using `peek.new(ignore_toml=True)`
1028
1023
 
1029
- With this a new peekobject is created with the default attibutes. Any peek.json files asre ignored.
1024
+ With this a new peekobject is created with the default attibutes. Any peek.toml files asre ignored.
1030
1025
  * by using `peek.fork()`
1031
1026
 
1032
1027
  With this a new peek object is created with the same attributes as the object it is created ('the parent') from. Note that any non set attributes are copied (propagated) from the parent.
@@ -1069,22 +1064,22 @@ hello == 'world'
1069
1064
  peek_cm exit in 0.001843 seconds
1070
1065
  ```
1071
1066
 
1072
- ## ignore_json
1073
- With `peek.new(ignore_json=True)` an instance of peek without having applied any json configuration file will be returned. That can be useful when guaranteeing the same output in several setups.
1067
+ ## ignore_toml
1068
+ With `peek.new(ignore_toml=True)` an instance of peek without having applied any toml configuration file will be returned. That can be useful when guaranteeing the same output in several setups.
1074
1069
 
1075
1070
  ### Example
1076
- Suppose we have a `peek.json` file in the current directory with the contents
1071
+ Suppose we have a `peek.toml` file in the current directory with the contents
1077
1072
  ```
1078
1073
  {prefix="==>"}
1079
1074
  ```
1080
1075
  Then
1081
1076
  ```
1082
- peek_post_json = peek.new()
1083
- peek_ignore_json = peek.new(ignore_json=True)
1077
+ peek_post_toml = peek.new()
1078
+ peek_ignore_toml = peek.new(ignore_toml=True)
1084
1079
  hello = "world"
1085
1080
  peek(hello)
1086
- peek_post_json(hello)
1087
- peek_ignore_json(hello)
1081
+ peek_post_toml(hello)
1082
+ peek_ignore_toml(hello)
1088
1083
  ```
1089
1084
  prints
1090
1085
  ```
@@ -1178,9 +1173,8 @@ supports compact, indent,
1178
1173
  and underscore_numbers
1179
1174
  parameters of pprint yes **) no
1180
1175
  use from a REPL limited functionality no
1181
- external configuration via json file no
1176
+ external configuration via toml file no
1182
1177
  observes line_length correctly yes no
1183
- default line length 160 80
1184
1178
  benchmarking functionality yes no
1185
1179
  suppress f-strings at left hand optional no
1186
1180
  indentation 4 blanks (overridable) dependent on length of prefix
@@ -4,7 +4,7 @@
4
4
  # | .__/ \___| \___||_|\_\
5
5
  # |_| like print, but easy.
6
6
 
7
- __version__ = "1.5.1"
7
+ __version__ = "1.5.2"
8
8
 
9
9
  """
10
10
  See https://github.com/salabim/peek for details
@@ -110,6 +110,29 @@ copy_contents(
110
110
  ),
111
111
  ),
112
112
  )
113
+ copy_contents(
114
+ package="tomli",
115
+ prefer_installed=False,
116
+ filecontents=(
117
+ ("tomli/py.typed", b"eJxTVvBNLMpOLVJIy8xJVUjLL1IIcA1QMDUz5AIAbpoHmA=="),
118
+ (
119
+ "tomli/_parser.py",
120
+ b"eJzFPGlz20aW3/UrOvAHkjHESLK9M2GtpoqR6QlrJNklyTvZlVgwCDZFRCDA4LCkaPTf973XB7px8LDWs6yyRQLd7+53dQOv2OWn97/tn4YBjzO+P57xOA/nIU8H7Gx8tfdK3P4QRvwkWT2m4e0iv+IP+YAdHRwdsis/5lHIfi3u7sKYxzBcApqxPGGfLj+wIp7xlPnsJInzNJwWeZKy4W3K+RIQ9ff25mmyZJ43L/Ii5Z7HwuUqSXPmx3GS+3mYxJkcEyRRxAO60vengRo4znnqTyO+J39ngCW+FVPyxxXP1MAzf7WCO5/S5OHxCm7oIXBRA/vosmH86LJzf8lnV8UK4IpxfS/lalR3j8HnYuS9H16NrsZnI1ddOP14Mjy1rpx/PvtldCF+Lv08WHh54s38nOfhklcuR0ngRw3X42I55am711OkWHz9gwO9n/w04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mt9hierTgaCBCJFJvYVCCBmy+FTNFpygz5+eQQMD50bpoPEbmG1Oy5wbdxLRxS0rzUdLnicdVjYX340Gx9fRkwD3Nbh0OuDuYnoKVvx2fLcFtvXQLRY+Mbsm+2sP/t/g76Fn/pfN0ZAd5l/X6EdNh0g5/qisciY+GsPP1JtCAr7xQt2InR8tsvjFM+2CsdBxaXSPb7iYmkuieOsi3jb8Adyhx6w==",
125
+ ),
126
+ (
127
+ "tomli/_types.py",
128
+ b"eJw9jcFqw0AMRO/7FYJcHdPmGOghuJiENmCID4Xgw6ZWXJG1tGhlyP59N23pdd7MmxWcuteP9Tt9IidcH0ZkoyuhbuF46N3qF7cUsJGYlaYv6/FuW9g8bZ6h94yBYL/cbsTIpf4nGsEEulMLC4+o4KERNqXLYqKwmxRxLke1c1eVGSxH4glojqIGO84VND4EfwlYQb/EgK6o+xwRPLOYNxJOrvOasA3iDV7+B+dzMh2qh2Vwb5gL+jE84grquh5cJ6mkxOa+AVIUVMo=",
129
+ ),
130
+ (
131
+ "tomli/__init__.py",
132
+ b"eJxdUE1rwkAQvedXPOKlBQ02R6EHMREX4ge4Qj0tazLqYrIbJpvW/vtu1FMvMw/mvTfzZoT9LvuaFKYk29FEVGS9ORviGdZCRqPneGlqWrj2l83l6iXd/QzpNP2A1JZqg1V/uxlLNtBfRhW8w26/RG8rYmgsnPVsTr13jPmFiZqwKIkipXRdK4VPvMW101UXj/EAQ5fbdZFR6SrKmR3H74H+TdwZZx+SOE2mSRoDI2RbbLYSeSYk5ErsUYhNjvV8c5gXxTFBkUuc+qZNX3ocpCiEPA7CkDM6s2uQqFZzF+41TevY49/+MYbDnrWLQtgdkycbsl5NB7qX1PrB+kd3KJm0D2+4ElMS/TNKlGpc1df0SKGU1U2A0R/S13++",
133
+ ),
134
+ ),
135
+ )
113
136
  del copy_contents
114
137
 
115
138
  import inspect
@@ -119,7 +142,6 @@ import time
119
142
  import textwrap
120
143
  import contextlib
121
144
  import functools
122
- import json
123
145
  import logging
124
146
  import collections
125
147
  import numbers
@@ -132,6 +154,11 @@ import types
132
154
  import pprint
133
155
  import builtins
134
156
 
157
+ try:
158
+ import tomlib
159
+ except ModuleNotFoundError:
160
+ import tomli as tomlib
161
+
135
162
  nv = object()
136
163
 
137
164
 
@@ -219,7 +246,7 @@ def set_defaults():
219
246
  default.show_exit = True
220
247
  default.show_traceback = False
221
248
  default.enabled = True
222
- default.line_length = 160
249
+ default.line_length = 80
223
250
  default.compact = False
224
251
  default.indent = 1
225
252
  default.depth = 1000000
@@ -235,36 +262,31 @@ def set_defaults():
235
262
  default.start_time = perf_counter()
236
263
 
237
264
 
238
- def apply_json():
239
- peek_name = "peek"
240
-
241
- config = {}
242
- for path in sys.path:
243
- json_file = os.path.join(path, peek_name + ".json")
244
- if os.path.isfile(json_file):
245
- with open(json_file, "r") as f:
246
- config = json.load(f)
247
- break
248
- json_dir = os.path.join(path, peek_name)
249
- json_file = os.path.join(json_dir, peek_name + ".json")
250
- if os.path.isfile(json_file):
251
- with open(json_file, "r") as f:
252
- config = json.load(f)
253
- break
254
-
255
- for k, v in config.items():
256
- if k in ("serialize", "start_time"):
257
- raise ValueError("error in {json_file}: key {k} not allowed".format(json_file=json_file, k=k))
258
-
259
- if k in shortcut_to_name:
260
- k = shortcut_to_name[k]
261
- if hasattr(default, k):
262
- setattr(default, k, v)
263
- else:
264
- if k == "delta":
265
- setattr(default, "start_time", perf_counter() - v)
265
+ def apply_toml():
266
+ def process(config):
267
+
268
+ for k, v in config.items():
269
+ if k in ("serialize", "start_time"):
270
+ raise ValueError("error in {toml_file}: key {k} not allowed".format(toml_file=toml_file, k=k))
271
+
272
+ if k in shortcut_to_name:
273
+ k = shortcut_to_name[k]
274
+ if hasattr(default, k):
275
+ setattr(default, k, v)
266
276
  else:
267
- raise ValueError("error in {json_file}: key {k} not recognized".format(json_file=json_file, k=k))
277
+ if k == "delta":
278
+ setattr(default, "start_time", perf_counter() - v)
279
+ else:
280
+ raise ValueError("error in {toml_file}: key {k} not recognized".format(toml_file=toml_file, k=k))
281
+
282
+ this_path = Path(".").resolve()
283
+ for i in range(len(this_path.parts), 0, -1):
284
+ toml_file = Path(this_path.parts[0]).joinpath(*this_path.parts[1:i], "peek.toml")
285
+ if toml_file.is_file():
286
+ with open(toml_file, "rb") as f:
287
+ config = tomlib.load(f)
288
+ process(config)
289
+ return # stop searching
268
290
 
269
291
 
270
292
  def no_source_error(s=None):
@@ -479,7 +501,7 @@ class _Peek:
479
501
  code = codes[filename]
480
502
  frame_info = inspect.getframeinfo(call_frame, context=1)
481
503
 
482
- # parent_function = frame_info.function
504
+ # parent_function = frame_info.function
483
505
  parent_function = Source.executing(call_frame).code_qualname() # changed in version 1.3.10 to include class name
484
506
  parent_function = parent_function.replace(".<locals>.", ".")
485
507
  if parent_function == "<module>" or str(this.show_line_number) in ("n", "no parent"):
@@ -702,9 +724,9 @@ class _Peek:
702
724
  self.check()
703
725
  return self
704
726
 
705
- def new(self, ignore_json=False, **kwargs):
706
- if ignore_json:
707
- return _Peek(_parent=default_pre_json, **kwargs)
727
+ def new(self, ignore_toml=False, **kwargs):
728
+ if ignore_toml:
729
+ return _Peek(_parent=default_pre_toml, **kwargs)
708
730
  else:
709
731
  return _Peek(**kwargs)
710
732
 
@@ -865,14 +887,13 @@ class _Peek:
865
887
  codes = {}
866
888
 
867
889
  set_defaults()
868
- default_pre_json = copy.copy(default)
869
- apply_json()
890
+ default_pre_toml = copy.copy(default)
891
+ apply_toml()
870
892
  peek = _Peek()
871
893
  builtins.peek = peek
872
894
  p = peek.fork()
873
895
 
874
896
 
875
-
876
897
  class PeekModule(types.ModuleType):
877
898
  def __call__(self, *args, **kwargs):
878
899
  return peek(*args, **kwargs)
@@ -886,3 +907,4 @@ class PeekModule(types.ModuleType):
886
907
 
887
908
  if __name__ != "__main__":
888
909
  sys.modules["peek"].__class__ = PeekModule
910
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: peek-python
3
- Version: 1.5.1
3
+ Version: 1.5.2
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/ycecream
@@ -985,17 +985,15 @@ The parent function can be suppressed by setting `show_line_number` or `sln` to
985
985
 
986
986
  # Configuring at import time
987
987
 
988
- It can be useful to configure peek at import time. This can be done by providing a `peek.json` file which
988
+ It can be useful to configure peek at import time. This can be done by providing a `peek.toml` file which
989
989
  can contain any attribute configuration overriding the standard settings.
990
- E.g. if there is an `peek.json` file with the following contents
990
+ E.g. if there is an `peek.toml` file with the following contents
991
991
 
992
992
  ```
993
- {
994
- "o": "stderr",
995
- "show_time": true,
996
- "line_length": 80`
997
- 'compact' : true
998
- }
993
+ outpout = "stderr"
994
+ show_time = true
995
+ ll = 160
996
+ compact = true
999
997
  ```
1000
998
  in the same folder as the application, this program:
1001
999
  ```
@@ -1006,24 +1004,21 @@ will print to stderr (rather than stdout):
1006
1004
  ```
1007
1005
  @ 14:53:41.392190 ==> hello='world'
1008
1006
  ```
1009
- At import time the sys.path will be searched for, in that order, to find a `peek.json` file and use that. This means that
1010
- you can place a `peek.json` file in the site-packages folder where `peek` is installed to always use
1011
- these modified settings.
1007
+ At import time current directory will be searched for `peek.toml` and if not found, one level up, etc. until the root directory is reached.
1012
1008
 
1013
- Please observe that json values are slightly different from their Python equivalents:
1009
+ Please observe that toml values are slightly different from their Python equivalents:
1014
1010
  ```
1015
- -------------------------------
1016
- Python json
1017
- -------------------------------
1011
+ -----------------------------------
1012
+ Python toml
1013
+ -----------------------------------
1018
1014
  True true
1019
1015
  False false
1020
- None none
1021
- strings always double quoted
1022
- -------------------------------
1016
+ strings preferably double quoted
1017
+ -----------------------------------
1023
1018
  ```
1024
1019
  Note that not-specified attributes will remain the default settings.
1025
1020
 
1026
- For obvious reasons, it is not possible to specify `serialize` in an peek.json file.
1021
+ For obvious reasons, it is not possible to specify `serialize` in a peek.toml file.
1027
1022
 
1028
1023
  # Working with multiple instances of peek
1029
1024
 
@@ -1037,10 +1032,10 @@ THere are several ways to obtain a new instance of peek:
1037
1032
  * by using `peek.new()`
1038
1033
 
1039
1034
  With this a new peek object is created with the default attributes
1040
- and possibly peek.json overrides.
1041
- * by using `peek.new(ignore_json=True)`
1035
+ and possibly peek.toml overrides.
1036
+ * by using `peek.new(ignore_toml=True)`
1042
1037
 
1043
- With this a new peekobject is created with the default attibutes. Any peek.json files asre ignored.
1038
+ With this a new peekobject is created with the default attibutes. Any peek.toml files asre ignored.
1044
1039
  * by using `peek.fork()`
1045
1040
 
1046
1041
  With this a new peek object is created with the same attributes as the object it is created ('the parent') from. Note that any non set attributes are copied (propagated) from the parent.
@@ -1083,22 +1078,22 @@ hello == 'world'
1083
1078
  peek_cm exit in 0.001843 seconds
1084
1079
  ```
1085
1080
 
1086
- ## ignore_json
1087
- With `peek.new(ignore_json=True)` an instance of peek without having applied any json configuration file will be returned. That can be useful when guaranteeing the same output in several setups.
1081
+ ## ignore_toml
1082
+ With `peek.new(ignore_toml=True)` an instance of peek without having applied any toml configuration file will be returned. That can be useful when guaranteeing the same output in several setups.
1088
1083
 
1089
1084
  ### Example
1090
- Suppose we have a `peek.json` file in the current directory with the contents
1085
+ Suppose we have a `peek.toml` file in the current directory with the contents
1091
1086
  ```
1092
1087
  {prefix="==>"}
1093
1088
  ```
1094
1089
  Then
1095
1090
  ```
1096
- peek_post_json = peek.new()
1097
- peek_ignore_json = peek.new(ignore_json=True)
1091
+ peek_post_toml = peek.new()
1092
+ peek_ignore_toml = peek.new(ignore_toml=True)
1098
1093
  hello = "world"
1099
1094
  peek(hello)
1100
- peek_post_json(hello)
1101
- peek_ignore_json(hello)
1095
+ peek_post_toml(hello)
1096
+ peek_ignore_toml(hello)
1102
1097
  ```
1103
1098
  prints
1104
1099
  ```
@@ -1192,9 +1187,8 @@ supports compact, indent,
1192
1187
  and underscore_numbers
1193
1188
  parameters of pprint yes **) no
1194
1189
  use from a REPL limited functionality no
1195
- external configuration via json file no
1190
+ external configuration via toml file no
1196
1191
  observes line_length correctly yes no
1197
- default line length 160 80
1198
1192
  benchmarking functionality yes no
1199
1193
  suppress f-strings at left hand optional no
1200
1194
  indentation 4 blanks (overridable) dependent on length of prefix
@@ -8,7 +8,7 @@ authors = [
8
8
  {name = "Ruud van der Ham", email = "rt.van.der.ham@gmail.com"}
9
9
  ]
10
10
  description = "peek - debugging and benchmarking made easy"
11
- version = "1.5.1"
11
+ version = "1.5.2"
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.6"
14
14
  dependencies = [
@@ -13,8 +13,8 @@ os.chdir(file_folder)
13
13
  sys.path.insert(0, file_folder + "/../peek")
14
14
 
15
15
  import peek
16
- import peek as peek_module
17
16
 
17
+ peek.set_defaults()
18
18
  import tempfile
19
19
 
20
20
 
@@ -152,76 +152,74 @@ def test_calls():
152
152
  peek(a=1)
153
153
 
154
154
 
155
- def test_output(capsys):
156
- with tempfile.TemporaryDirectory() as tmpdir: # we can't use tmpdir from pytest because of Python 2.7 compatibity
157
- g.result = ""
155
+ def test_output(capsys, tmpdir):
156
+ g.result = ""
158
157
 
159
- def my_output(s):
160
- g.result += s + "\n"
158
+ def my_output(s):
159
+ g.result += s + "\n"
161
160
 
162
- hello = "world"
163
- peek(hello, output=print)
164
- out, err = capsys.readouterr()
165
- assert out == "hello='world'\n"
166
- assert err == ""
167
- peek(hello, output=sys.stdout)
168
- out, err = capsys.readouterr()
169
- assert out == "hello='world'\n"
170
- assert err == ""
171
- peek(hello, output="stdout")
172
- out, err = capsys.readouterr()
173
- assert out == "hello='world'\n"
174
- assert err == ""
175
- peek(hello, output="")
176
- out, err = capsys.readouterr()
177
- assert out == ""
178
- assert err == ""
179
- peek(hello, output="null")
180
- out, err = capsys.readouterr()
181
- assert out == ""
182
- assert err == ""
183
- peek(hello, output=print)
184
- out, err = capsys.readouterr()
185
- assert out == "hello='world'\n"
186
- assert err == ""
187
-
188
- if True:
189
- path = Path(tmpdir) / "x0"
190
- peek(hello, output=path)
191
- out, err = capsys.readouterr()
192
- assert out == ""
193
- assert err == ""
194
- with path.open("r") as f:
195
- assert f.read() == "hello='world'\n"
196
-
197
- path = Path(tmpdir) / "x1"
198
- peek(hello, output=path)
199
- out, err = capsys.readouterr()
200
- assert out == ""
201
- assert err == ""
202
- with path.open("r") as f:
203
- assert f.read() == "hello='world'\n"
204
-
205
- path = Path(tmpdir) / "x2"
206
- with path.open("a+") as f:
207
- peek(hello, output=f)
208
- with pytest.raises(TypeError): # closed file
209
- peek(hello, output=f)
210
- out, err = capsys.readouterr()
211
- assert out == ""
212
- assert err == ""
213
- with path.open("r") as f:
214
- assert f.read() == "hello='world'\n"
161
+ hello = "world"
162
+ peek(hello, output=print)
163
+ out, err = capsys.readouterr()
164
+ assert out == "hello='world'\n"
165
+ assert err == ""
166
+ peek(hello, output=sys.stdout)
167
+ out, err = capsys.readouterr()
168
+ assert out == "hello='world'\n"
169
+ assert err == ""
170
+ peek(hello, output="stdout")
171
+ out, err = capsys.readouterr()
172
+ assert out == "hello='world'\n"
173
+ assert err == ""
174
+ peek(hello, output="")
175
+ out, err = capsys.readouterr()
176
+ assert out == ""
177
+ assert err == ""
178
+ peek(hello, output="null")
179
+ out, err = capsys.readouterr()
180
+ assert out == ""
181
+ assert err == ""
182
+ peek(hello, output=print)
183
+ out, err = capsys.readouterr()
184
+ assert out == "hello='world'\n"
185
+ assert err == ""
215
186
 
216
- with pytest.raises(TypeError):
217
- peek(hello, output=1)
187
+ path = Path(tmpdir) / "x0"
188
+ peek(hello, output=path)
189
+ out, err = capsys.readouterr()
190
+ assert out == ""
191
+ assert err == ""
192
+ with path.open("r") as f:
193
+ assert f.read() == "hello='world'\n"
218
194
 
219
- peek(hello, output=my_output)
220
- peek(1, output=my_output)
221
- out, err = capsys.readouterr()
222
- assert out == ""
223
- assert out == ""
224
- assert g.result == "hello='world'\n1\n"
195
+ path = Path(tmpdir) / "x1"
196
+ peek(hello, output=path)
197
+ out, err = capsys.readouterr()
198
+ assert out == ""
199
+ assert err == ""
200
+ with path.open("r") as f:
201
+ assert f.read() == "hello='world'\n"
202
+
203
+ path = Path(tmpdir) / "x2"
204
+ with path.open("a+") as f:
205
+ peek(hello, output=f)
206
+ with pytest.raises(TypeError): # closed file
207
+ peek(hello, output=f)
208
+ out, err = capsys.readouterr()
209
+ assert out == ""
210
+ assert err == ""
211
+ with path.open("r") as f:
212
+ assert f.read() == "hello='world'\n"
213
+
214
+ with pytest.raises(TypeError):
215
+ peek(hello, output=1)
216
+
217
+ peek(hello, output=my_output)
218
+ peek(1, output=my_output)
219
+ out, err = capsys.readouterr()
220
+ assert out == ""
221
+ assert out == ""
222
+ assert g.result == "hello='world'\n1\n"
225
223
 
226
224
  def test_serialize(capsys):
227
225
  def serialize(s):
@@ -308,7 +306,7 @@ def test_multiline():
308
306
  # fmt: off
309
307
  s = peek((a, b),
310
308
  [ll,
311
- ll], as_str=True, line_length=80)
309
+ ll], as_str=True)
312
310
  # fmt: on
313
311
  assert (
314
312
  s
@@ -336,9 +334,10 @@ lines=
336
334
 
337
335
 
338
336
  def test_decorator(capsys):
339
- peek_module.fix_perf_counter(0)
337
+ peek.fix_perf_counter(0)
340
338
 
341
339
  with pytest.raises(TypeError):
340
+
342
341
  @peek
343
342
  def mul(x, y):
344
343
  return x * y
@@ -373,11 +372,11 @@ returned 5 from add(2, 3) in 0.000000 seconds
373
372
  called sub(10, 2)
374
373
  """
375
374
  )
376
- peek_module.fix_perf_counter(None)
375
+ peek.fix_perf_counter(None)
377
376
 
378
377
 
379
378
  def test_decorator_edge_cases(capsys):
380
- peek_module.fix_perf_counter(0)
379
+ peek.fix_perf_counter(0)
381
380
 
382
381
  @peek()
383
382
  def mul(x, y, factor=1):
@@ -398,7 +397,7 @@ called mul(5, 6, factor=10)
398
397
  returned 300 from mul(5, 6, factor=10) in 0.000000 seconds
399
398
  """
400
399
  )
401
- peek_module.fix_perf_counter(None)
400
+ peek.fix_perf_counter(None)
402
401
 
403
402
 
404
403
  def test_decorator_with_methods(capsys):
@@ -438,9 +437,35 @@ called __mul__(Number(2), Number(3))
438
437
  )
439
438
 
440
439
 
440
+ def test_read_toml1():
441
+ toml_filename0 = Path("peek.toml")
442
+ with open(toml_filename0, "w") as f:
443
+ print("line_length = -1", file=f)
444
+ print("sln = true", file=f)
445
+
446
+ peek.set_defaults()
447
+ peek.apply_toml()
448
+ assert peek.default.line_length == -1
449
+ assert peek.default.show_line_number == True
450
+
451
+ peek.set_defaults()
452
+ assert peek.default.line_length == 80
453
+ assert peek.default.show_line_number == False
454
+
455
+ with open(toml_filename0, "w") as f:
456
+ print("error = 0", file=f)
457
+
458
+ with pytest.raises(ValueError):
459
+ peek.set_defaults()
460
+ peek.apply_toml()
461
+
462
+ toml_filename0.unlink()
463
+ peek.set_defaults()
464
+
465
+
441
466
  @pytest.mark.skipif(Pythonista, reason="Pythonista problem")
442
467
  def test_context_manager(capsys):
443
- peek_module.fix_perf_counter(0)
468
+ peek.fix_perf_counter(0)
444
469
  with peek():
445
470
  peek(3)
446
471
  out, err = capsys.readouterr()
@@ -452,7 +477,7 @@ enter
452
477
  exit in 0.000000 seconds
453
478
  """
454
479
  )
455
- peek_module.fix_perf_counter(None)
480
+ peek.fix_perf_counter(None)
456
481
 
457
482
 
458
483
  def test_return_none(capsys):
@@ -471,108 +496,6 @@ a=2, a=2
471
496
  )
472
497
 
473
498
 
474
- def test_read_json1():
475
- with tempfile.TemporaryDirectory() as tmpdir: # we can't use tmpdir from pytest because of Python 2.7 compatibity
476
- json_filename0 = Path(tmpdir) / "peek.json"
477
- with open(str(json_filename0), "w") as f:
478
- print('{"line_length":-1}', file=f)
479
- tmpdir1 = Path(tmpdir) / "peek"
480
- tmpdir1.mkdir()
481
- json_filename1 = Path(tmpdir1) / "peek.json"
482
- with open(str(json_filename1), "w") as f:
483
- print('{"line_length":-2}', file=f)
484
- save_sys_path = sys.path
485
-
486
- sys.path = [tmpdir] + [tmpdir1]
487
- peek_module.set_defaults()
488
- peek_module.apply_json()
489
- assert peek_module.default.line_length == -1
490
-
491
- sys.path = [str(tmpdir1)] + [tmpdir]
492
- peek_module.set_defaults()
493
- peek_module.apply_json()
494
- assert peek_module.default.line_length == -2
495
-
496
- sys.path = []
497
- peek_module.set_defaults()
498
- peek_module.apply_json()
499
- assert peek_module.default.line_length == 160
500
-
501
- with open(str(json_filename0), "w") as f:
502
- print('{"error":0}', file=f)
503
-
504
- sys.path = [tmpdir]
505
- with pytest.raises(ValueError):
506
- peek_module.set_defaults()
507
- peek_module.apply_json()
508
-
509
- sys.path = save_sys_path
510
-
511
-
512
- def test_read_json2():
513
- with tempfile.TemporaryDirectory() as tmpdir:
514
- json_filename = Path(tmpdir) / "peek.json"
515
- with open(str(json_filename), "w") as f:
516
- print('{"prefix": "xxx", "delta": 10}', file=f)
517
-
518
- sys.path = [tmpdir] + sys.path
519
- peek_module.set_defaults()
520
- peek_module.apply_json()
521
- sys.path.pop(0)
522
-
523
- y1 = peek.new()
524
-
525
- s = y1(3, as_str=True)
526
- assert s == "xxx3\n"
527
- assert 10 < y1.delta < 11
528
-
529
- with open(str(json_filename), "w") as f:
530
- print('{"prefix1": "xxx"}', file=f)
531
-
532
- sys.path = [tmpdir] + sys.path
533
- with pytest.raises(ValueError):
534
- peek_module.set_defaults()
535
- peek_module.apply_json()
536
- sys.path.pop(0)
537
-
538
- with open(str(json_filename), "w") as f:
539
- print('{"serialize": "xxx"}', file=f)
540
-
541
- sys.path = [tmpdir] + sys.path
542
- with pytest.raises(ValueError):
543
- peek_module.set_defaults()
544
- peek_module.apply_json()
545
-
546
- sys.path.pop(0)
547
-
548
- tmpdir = Path(tmpdir) / "peek"
549
- tmpdir.mkdir()
550
- json_filename = Path(tmpdir) / "peek.json"
551
- with open(str(json_filename), "w") as f:
552
- print('{"prefix": "yyy"}', file=f)
553
-
554
- sys.path = [str(tmpdir)] + sys.path
555
- peek_module.set_defaults()
556
- peek_module.apply_json()
557
- sys.path.pop(0)
558
-
559
- y1 = peek.new()
560
-
561
- s = y1(3, as_str=True)
562
- assert s == "yyy3\n"
563
-
564
- tmpdir = Path(tmpdir) / "peek"
565
- tmpdir.mkdir()
566
- json_filename = Path(tmpdir) / "peek.json"
567
- with open(str(json_filename), "w") as f:
568
- print("{}", file=f)
569
-
570
- sys.path = [str(tmpdir)] + sys.path
571
- peek_module.set_defaults()
572
- peek_module.apply_json()
573
- sys.path.pop(0)
574
-
575
-
576
499
  @pytest.mark.skipif(Pythonista, reason="Pythonista problem")
577
500
  def test_wrapping(capsys):
578
501
  l0 = "".join(" {c}".format(c=c) for c in "12345678") + "\n" + "".join(".........0" for c in "12345678")
@@ -581,8 +504,7 @@ def test_wrapping(capsys):
581
504
  ccc = cccc = 3 * ["12345678123456789012"]
582
505
  ccc0 = [cccc[0] + "0"] + cccc[1:]
583
506
  with peek.preserve():
584
- peek.prefix="peek| "
585
- peek.line_length=80
507
+ peek.prefix = "peek| "
586
508
  peek(ccc)
587
509
  peek(cccc)
588
510
  peek(ccc0)
@@ -609,8 +531,7 @@ peek|
609
531
  b = bb = 9 * ["123"]
610
532
  print(l0)
611
533
  with peek.preserve():
612
- peek.prefix="peek| "
613
- peek.line_length=80
534
+ peek.prefix = "peek| "
614
535
  peek(a, b)
615
536
  peek(a, bb)
616
537
  out, err = capsys.readouterr()
@@ -632,8 +553,7 @@ peek|
632
553
  e = "a\nb"
633
554
  print(l0)
634
555
  with peek.preserve():
635
- peek.prefix="peek| "
636
- peek.line_length=80
556
+ peek.prefix = "peek| "
637
557
  peek(a, dddd)
638
558
  peek(a, ddddd)
639
559
  peek(e)
@@ -658,7 +578,7 @@ peek|
658
578
  a = aa = 2 * ["0123456789ABC"]
659
579
  print(l0)
660
580
  with peek.preserve():
661
- peek.prefix="peek| "
581
+ peek.prefix = "peek| "
662
582
  peek(a, line_length=40)
663
583
  peek(aa, line_length=40)
664
584
  peek(aa, line_length=41)
@@ -682,8 +602,8 @@ peek|
682
602
 
683
603
  def test_compact(capsys):
684
604
  a = 9 * ["0123456789"]
685
- peek(a, ll=80)
686
- peek(a, compact=True, ll=80)
605
+ peek(a)
606
+ peek(a, compact=True)
687
607
  out, err = capsys.readouterr()
688
608
  assert (
689
609
  out
@@ -708,8 +628,8 @@ a=
708
628
  def test_depth_indent(capsys):
709
629
  s = "=============================================="
710
630
  a = [s + "1", [s + "2", [s + "3", [s + "4"]]], s + "1"]
711
- peek(a, indent=4,ll=80)
712
- peek(a, depth=2, indent=4,ll=80)
631
+ peek(a, indent=4)
632
+ peek(a, depth=2, indent=4)
713
633
  out, err = capsys.readouterr()
714
634
  assert (
715
635
  out
@@ -783,18 +703,15 @@ def test_enabled2(capsys):
783
703
  assert s2 == "'s2'\n"
784
704
 
785
705
 
786
-
787
706
  def test_multiple_as():
788
707
  with pytest.raises(TypeError):
789
708
  peek(1, decorator=True, context_manager=True)
790
709
 
791
710
 
792
-
793
711
  def test_wrap_indent():
794
712
  s = 4 * ["*******************"]
795
713
  with peek.preserve():
796
- peek.prefix="peek| "
797
- peek.line_length=80
714
+ peek.prefix = "peek| "
798
715
  res = peek(s, compact=True, as_str=True)
799
716
  assert res.splitlines()[1].startswith(" s")
800
717
  res = peek(s, compact=True, as_str=True, wrap_indent="....")
@@ -829,8 +746,7 @@ def test_traceback(capsys):
829
746
  def test_enforce_line_length(capsys):
830
747
  s = 80 * "*"
831
748
  with peek.preserve():
832
- peek.prefix="peek| "
833
- peek.line_length=80
749
+ peek.prefix = "peek| "
834
750
  peek(s)
835
751
  peek(s, enforce_line_length=True)
836
752
  out, err = capsys.readouterr()
@@ -859,7 +775,7 @@ peek|
859
775
  assert len(res) == 20
860
776
 
861
777
 
862
- def test_check_output(capsys):
778
+ def test_check_output(capsys, tmpdir):
863
779
  """special Pythonista code, as that does not reload x1 and x2"""
864
780
  if "x1" in sys.modules:
865
781
  del sys.modules["x1"]
@@ -867,14 +783,14 @@ def test_check_output(capsys):
867
783
  del sys.modules["x2"]
868
784
  del sys.modules["peek"]
869
785
  import peek
786
+ peek.set_defaults()
870
787
 
871
788
  """ end of special Pythonista code """
872
789
  with peek.preserve():
873
- with tempfile.TemporaryDirectory() as tmpdir:
874
- x1_file = Path(tmpdir) / "x1.py"
875
- with open(str(x1_file), "w") as f:
876
- print(
877
- """\
790
+ x1_file = tmpdir / "x1.py"
791
+ with open(str(x1_file), "w") as f:
792
+ print(
793
+ """\
878
794
  def check_output():
879
795
  import x2
880
796
 
@@ -914,13 +830,13 @@ def check_output():
914
830
 
915
831
  x()
916
832
  """,
917
- file=f,
918
- )
833
+ file=f,
834
+ )
919
835
 
920
- x2_file = Path(tmpdir) / "x2.py"
921
- with open(str(x2_file), "w") as f:
922
- print(
923
- """\
836
+ x2_file = tmpdir / "x2.py"
837
+ with open(str(x2_file), "w") as f:
838
+ print(
839
+ """\
924
840
 
925
841
  def test():
926
842
  @peek()
@@ -932,13 +848,13 @@ def test():
932
848
  with peek():
933
849
  pass
934
850
  """,
935
- file=f,
936
- )
937
- sys.path = [tmpdir] + sys.path
938
- import x1
851
+ file=f,
852
+ )
853
+ sys.path = [str(tmpdir)] + sys.path
854
+ import x1
939
855
 
940
- x1.check_output()
941
- sys.path.pop(0)
856
+ x1.check_output()
857
+ sys.path.pop(0)
942
858
  out, err = capsys.readouterr()
943
859
  assert (
944
860
  out
File without changes
File without changes