pythonwrench 0.4.9__tar.gz → 0.5.0__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.
Files changed (76) hide show
  1. {pythonwrench-0.4.9/src/pythonwrench.egg-info → pythonwrench-0.5.0}/PKG-INFO +4 -2
  2. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/pyproject.toml +2 -1
  3. pythonwrench-0.5.0/src/pythonwrench/__init__.py +434 -0
  4. pythonwrench-0.5.0/src/pythonwrench/collections/__init__.py +104 -0
  5. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/csv.py +14 -7
  6. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/disk_cache.py +61 -24
  7. pythonwrench-0.5.0/src/pythonwrench/typing/__init__.py +113 -0
  8. {pythonwrench-0.4.9 → pythonwrench-0.5.0/src/pythonwrench.egg-info}/PKG-INFO +4 -2
  9. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench.egg-info/SOURCES.txt +0 -1
  10. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench.egg-info/requires.txt +1 -0
  11. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_disk_cache.py +1 -1
  12. pythonwrench-0.4.9/docs/requirements.txt +0 -4
  13. pythonwrench-0.4.9/src/pythonwrench/__init__.py +0 -208
  14. pythonwrench-0.4.9/src/pythonwrench/collections/__init__.py +0 -43
  15. pythonwrench-0.4.9/src/pythonwrench/typing/__init__.py +0 -48
  16. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/LICENSE +0 -0
  17. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/README.md +0 -0
  18. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/setup.cfg +0 -0
  19. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/setup.py +0 -0
  20. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/__main__.py +0 -0
  21. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/_core.py +0 -0
  22. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/abc.py +0 -0
  23. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/argparse.py +0 -0
  24. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/cast.py +0 -0
  25. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/checksum.py +0 -0
  26. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/collections/collections.py +0 -0
  27. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/collections/prop.py +0 -0
  28. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/collections/reducers.py +0 -0
  29. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/concurrent.py +0 -0
  30. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/dataclasses.py +0 -0
  31. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/datetime.py +0 -0
  32. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/difflib.py +0 -0
  33. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/entries.py +0 -0
  34. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/enum.py +0 -0
  35. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/functools.py +0 -0
  36. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/hashlib.py +0 -0
  37. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/importlib.py +0 -0
  38. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/inspect.py +0 -0
  39. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/json.py +0 -0
  40. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/jsonl.py +0 -0
  41. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/logging.py +0 -0
  42. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/math.py +0 -0
  43. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/os.py +0 -0
  44. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/pickle.py +0 -0
  45. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/random.py +0 -0
  46. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/re.py +0 -0
  47. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/semver.py +0 -0
  48. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/typing/checks.py +0 -0
  49. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/typing/classes.py +0 -0
  50. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench/warnings.py +0 -0
  51. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench.egg-info/dependency_links.txt +0 -0
  52. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench.egg-info/entry_points.txt +0 -0
  53. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/src/pythonwrench.egg-info/top_level.txt +0 -0
  54. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_abc.py +0 -0
  55. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_argparse.py +0 -0
  56. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_cast.py +0 -0
  57. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_checksum.py +0 -0
  58. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_collections.py +0 -0
  59. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_csv.py +0 -0
  60. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_dataclasses.py +0 -0
  61. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_difflib.py +0 -0
  62. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_entries.py +0 -0
  63. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_enum.py +0 -0
  64. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_functools.py +0 -0
  65. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_hashlib.py +0 -0
  66. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_importlib.py +0 -0
  67. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_inspect.py +0 -0
  68. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_json.py +0 -0
  69. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_jsonl.py +0 -0
  70. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_logging.py +0 -0
  71. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_math.py +0 -0
  72. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_os.py +0 -0
  73. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_random.py +0 -0
  74. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_readme.py +0 -0
  75. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_semver.py +0 -0
  76. {pythonwrench-0.4.9 → pythonwrench-0.5.0}/tests/test_typing.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pythonwrench
3
- Version: 0.4.9
3
+ Version: 0.5.0
4
4
  Summary: Python library with tools for typing, manipulating collections, and more!
5
5
  Author-email: "Étienne Labbé (Labbeti)" <labbeti.pub@gmail.com>
6
6
  Maintainer-email: "Étienne Labbé (Labbeti)" <labbeti.pub@gmail.com>
@@ -50,8 +50,10 @@ Classifier: Operating System :: POSIX
50
50
  Requires-Python: <3.15,>=3.8
51
51
  Description-Content-Type: text/markdown
52
52
  License-File: LICENSE
53
+ Requires-Dist: lazy-loader>=0.4
53
54
  Requires-Dist: typing-extensions>=4.10.0
54
55
  Provides-Extra: dev
56
+ Dynamic: license-file
55
57
 
56
58
  # pythonwrench
57
59
 
@@ -31,6 +31,7 @@ maintainers = [
31
31
  ]
32
32
  dynamic = ["version"]
33
33
  dependencies = [
34
+ "lazy-loader>=0.4",
34
35
  "typing-extensions>=4.10.0",
35
36
  ]
36
37
 
@@ -67,7 +68,7 @@ version = {attr = "pythonwrench.__version__"}
67
68
 
68
69
  [tool.pyright]
69
70
  include = ["src"]
70
- exclude = ["**/__pycache__"]
71
+ exclude = ["**/__pycache__", '**/node_modules', '**/.*', '.venv']
71
72
  pythonVersion = "3.8"
72
73
 
73
74
  [tool.pytest.ini_options]
@@ -0,0 +1,434 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ """Python library with tools for typing, manipulating collections, and more!"""
5
+
6
+ __name__ = "pythonwrench"
7
+ __author__ = "Étienne Labbé (Labbeti)"
8
+ __author_email__ = "labbeti.pub@gmail.com"
9
+ __license__ = "MIT"
10
+ __maintainer__ = "Étienne Labbé (Labbeti)"
11
+ __status__ = "Development"
12
+ __version__ = "0.5.0"
13
+
14
+
15
+ from typing import TYPE_CHECKING
16
+
17
+ try:
18
+ import lazy_loader as lazy # type: ignore
19
+ except ImportError:
20
+ lazy = None
21
+
22
+
23
+ if TYPE_CHECKING or lazy is None:
24
+ # Re-import for language servers
25
+ from . import abc as abc
26
+ from . import argparse as argparse
27
+ from . import cast as cast
28
+ from . import checksum as checksum
29
+ from . import collections as collections
30
+ from . import concurrent as concurrent
31
+ from . import csv as csv
32
+ from . import dataclasses as dataclasses
33
+ from . import datetime as datetime
34
+ from . import difflib as difflib
35
+ from . import disk_cache as disk_cache
36
+ from . import entries as entries
37
+ from . import enum as enum
38
+ from . import functools as functools
39
+ from . import hashlib as hashlib
40
+ from . import importlib as importlib
41
+ from . import inspect as inspect
42
+ from . import json as json
43
+ from . import jsonl as jsonl
44
+ from . import logging as logging
45
+ from . import math as math
46
+ from . import os as os
47
+ from . import pickle as pickle
48
+ from . import random as random
49
+ from . import re as re
50
+ from . import semver as semver
51
+ from . import warnings as warnings
52
+
53
+ # Global library imports
54
+ from .abc import Singleton
55
+ from .argparse import (
56
+ parse_to,
57
+ str_to_bool,
58
+ str_to_none,
59
+ str_to_optional_bool,
60
+ str_to_optional_float,
61
+ str_to_optional_int,
62
+ str_to_optional_str,
63
+ str_to_type,
64
+ )
65
+ from .cast import as_builtin, register_as_builtin_fn
66
+ from .checksum import checksum_any, checksum_object, register_checksum_fn
67
+ from .collections import (
68
+ all_eq,
69
+ all_ne,
70
+ contained,
71
+ dict_list_to_list_dict,
72
+ dump_dict,
73
+ duplicate_list,
74
+ filter_iterable,
75
+ find,
76
+ flat_dict_of_dict,
77
+ flat_list_of_list,
78
+ flatten,
79
+ intersect,
80
+ intersect_lists,
81
+ is_full,
82
+ is_sorted,
83
+ is_unique,
84
+ list_dict_to_dict_list,
85
+ prod,
86
+ recursive_generator,
87
+ reduce_add,
88
+ reduce_and,
89
+ reduce_mul,
90
+ reduce_or,
91
+ shuffled,
92
+ sorted_dict,
93
+ sum,
94
+ unflat_dict_of_dict,
95
+ unflat_list_of_list,
96
+ union,
97
+ union_dicts,
98
+ union_lists,
99
+ unzip,
100
+ )
101
+ from .csv import dump_csv, dumps_csv, load_csv, loads_csv, read_csv, save_csv
102
+ from .dataclasses import get_defaults_values
103
+ from .datetime import get_now, get_now_iso8601
104
+ from .difflib import find_closest_in_list, sequence_matcher_ratio
105
+ from .disk_cache import disk_cache_call, disk_cache_decorator
106
+ from .enum import StrEnum
107
+ from .functools import (
108
+ Compose,
109
+ compose,
110
+ filter_and_call,
111
+ function_alias,
112
+ identity,
113
+ repeat_fn,
114
+ )
115
+ from .hashlib import hash_file
116
+ from .importlib import (
117
+ is_available_package,
118
+ is_editable_package,
119
+ reload_editable_packages,
120
+ reload_submodules,
121
+ search_submodules,
122
+ )
123
+ from .inspect import get_argnames, get_current_fn_name, get_fullname
124
+ from .json import dump_json, dumps_json, load_json, loads_json, read_json, save_json
125
+ from .jsonl import (
126
+ dump_jsonl,
127
+ dumps_jsonl,
128
+ load_jsonl,
129
+ loads_jsonl,
130
+ read_jsonl,
131
+ save_jsonl,
132
+ )
133
+ from .logging import (
134
+ VERBOSE_DEBUG,
135
+ VERBOSE_ERROR,
136
+ VERBOSE_INFO,
137
+ VERBOSE_WARNING,
138
+ MkdirFileHandler,
139
+ get_current_file_logger,
140
+ get_ipython_name,
141
+ get_null_logger,
142
+ log_once,
143
+ running_on_interpreter,
144
+ running_on_notebook,
145
+ running_on_terminal,
146
+ setup_logging_level,
147
+ setup_logging_verbose,
148
+ )
149
+ from .math import argmax, argmin, argsort, clamp, clip
150
+ from .os import get_num_cpus_available, safe_rmdir, tree_iter
151
+ from .pickle import (
152
+ dump_pickle,
153
+ dumps_pickle,
154
+ load_pickle,
155
+ loads_pickle,
156
+ read_pickle,
157
+ save_pickle,
158
+ )
159
+ from .random import randstr
160
+ from .re import (
161
+ PatternLike,
162
+ PatternListLike,
163
+ compile_patterns,
164
+ filter_with_patterns,
165
+ find_patterns,
166
+ get_key_fn,
167
+ match_patterns,
168
+ sort_with_patterns,
169
+ )
170
+ from .semver import Version
171
+ from .typing import (
172
+ BuiltinCollection,
173
+ BuiltinNumber,
174
+ BuiltinScalar,
175
+ DataclassInstance,
176
+ EllipsisType,
177
+ ListOrTuple,
178
+ NamedTupleInstance,
179
+ NoneType,
180
+ SupportsAdd,
181
+ SupportsAnd,
182
+ SupportsBool,
183
+ SupportsDiv,
184
+ SupportsGetitem,
185
+ SupportsGetitem2,
186
+ SupportsGetitemIterLen,
187
+ SupportsGetitemIterLen2,
188
+ SupportsGetitemLen,
189
+ SupportsGetitemLen2,
190
+ SupportsIterLen,
191
+ SupportsLen,
192
+ SupportsMatmul,
193
+ SupportsMul,
194
+ SupportsOr,
195
+ T_BuiltinNumber,
196
+ T_BuiltinScalar,
197
+ check_args_types,
198
+ is_builtin_collection,
199
+ is_builtin_number,
200
+ is_builtin_obj,
201
+ is_builtin_scalar,
202
+ is_dataclass_instance,
203
+ is_iterable_bool,
204
+ is_iterable_bytes_or_list,
205
+ is_iterable_float,
206
+ is_iterable_int,
207
+ is_iterable_integral,
208
+ is_iterable_str,
209
+ is_namedtuple_instance,
210
+ is_sequence_str,
211
+ is_typed_dict,
212
+ isinstance_generic,
213
+ )
214
+ from .warnings import deprecated_alias, deprecated_function, warn_once
215
+
216
+ else:
217
+ __getattr__, __dir__, __all__ = lazy.attach(
218
+ __name__,
219
+ submodules=[
220
+ "abc",
221
+ "argparse",
222
+ "cast",
223
+ "checksum",
224
+ "collections",
225
+ "concurrent",
226
+ "csv",
227
+ "dataclasses",
228
+ "datetime",
229
+ "difflib",
230
+ "disk_cache",
231
+ "entries",
232
+ "enum",
233
+ "functools",
234
+ "hashlib",
235
+ "importlib",
236
+ "inspect",
237
+ "json",
238
+ "jsonl",
239
+ "logging",
240
+ "math",
241
+ "os",
242
+ "pickle",
243
+ "random",
244
+ "re",
245
+ "semver",
246
+ "typing",
247
+ "warnings",
248
+ ],
249
+ submod_attrs={
250
+ "argparse": [
251
+ "parse_to",
252
+ "str_to_bool",
253
+ "str_to_none",
254
+ "str_to_optional_bool",
255
+ "str_to_optional_float",
256
+ "str_to_optional_int",
257
+ "str_to_optional_str",
258
+ "str_to_type",
259
+ ],
260
+ "abc": ["Singleton"],
261
+ "cast": ["as_builtin", "register_as_builtin_fn"],
262
+ "checksum": ["checksum_any", "checksum_object", "register_checksum_fn"],
263
+ "collections": [
264
+ "all_eq",
265
+ "all_ne",
266
+ "contained",
267
+ "dict_list_to_list_dict",
268
+ "dump_dict",
269
+ "duplicate_list",
270
+ "filter_iterable",
271
+ "find",
272
+ "flat_dict_of_dict",
273
+ "flat_list_of_list",
274
+ "flatten",
275
+ "intersect",
276
+ "intersect_lists",
277
+ "is_full",
278
+ "is_sorted",
279
+ "is_unique",
280
+ "list_dict_to_dict_list",
281
+ "prod",
282
+ "recursive_generator",
283
+ "reduce_add",
284
+ "reduce_and",
285
+ "reduce_mul",
286
+ "reduce_or",
287
+ "shuffled",
288
+ "sorted_dict",
289
+ "sum",
290
+ "unflat_dict_of_dict",
291
+ "unflat_list_of_list",
292
+ "union",
293
+ "union_dicts",
294
+ "union_lists",
295
+ "unzip",
296
+ ],
297
+ "csv": [
298
+ "dump_csv",
299
+ "dumps_csv",
300
+ "load_csv",
301
+ "loads_csv",
302
+ "read_csv",
303
+ "save_csv",
304
+ ],
305
+ "dataclasses": ["get_defaults_values"],
306
+ "datetime": ["get_now", "get_now_iso8601"],
307
+ "difflib": ["find_closest_in_list", "sequence_matcher_ratio"],
308
+ "disk_cache": ["disk_cache_call", "disk_cache_decorator"],
309
+ "enum": ["StrEnum"],
310
+ "functools": [
311
+ "Compose",
312
+ "compose",
313
+ "filter_and_call",
314
+ "function_alias",
315
+ "identity",
316
+ "repeat_fn",
317
+ ],
318
+ "hashlib": ["hash_file"],
319
+ "importlib": [
320
+ "is_available_package",
321
+ "is_editable_package",
322
+ "reload_editable_packages",
323
+ "reload_submodules",
324
+ "search_submodules",
325
+ ],
326
+ "inspect": ["get_argnames", "get_current_fn_name", "get_fullname"],
327
+ "json": [
328
+ "dump_json",
329
+ "dumps_json",
330
+ "load_json",
331
+ "loads_json",
332
+ "read_json",
333
+ "save_json",
334
+ ],
335
+ "jsonl": [
336
+ "dump_jsonl",
337
+ "dumps_jsonl",
338
+ "load_jsonl",
339
+ "loads_jsonl",
340
+ "read_jsonl",
341
+ "save_jsonl",
342
+ ],
343
+ "logging": [
344
+ "VERBOSE_DEBUG",
345
+ "VERBOSE_ERROR",
346
+ "VERBOSE_INFO",
347
+ "VERBOSE_WARNING",
348
+ "MkdirFileHandler",
349
+ "get_current_file_logger",
350
+ "get_ipython_name",
351
+ "get_null_logger",
352
+ "log_once",
353
+ "running_on_interpreter",
354
+ "running_on_notebook",
355
+ "running_on_terminal",
356
+ "setup_logging_level",
357
+ "setup_logging_verbose",
358
+ ],
359
+ "math": ["argmax", "argmin", "argsort", "clamp", "clip"],
360
+ "os": ["get_num_cpus_available", "safe_rmdir", "tree_iter"],
361
+ "pickle": [
362
+ "dump_pickle",
363
+ "dumps_pickle",
364
+ "load_pickle",
365
+ "loads_pickle",
366
+ "read_pickle",
367
+ "save_pickle",
368
+ ],
369
+ "random": ["randstr"],
370
+ "re": [
371
+ "PatternLike",
372
+ "PatternListLike",
373
+ "compile_patterns",
374
+ "filter_with_patterns",
375
+ "find_patterns",
376
+ "get_key_fn",
377
+ "match_patterns",
378
+ "sort_with_patterns",
379
+ ],
380
+ "semver": ["Version"],
381
+ "typing": [
382
+ "BuiltinCollection",
383
+ "BuiltinNumber",
384
+ "BuiltinScalar",
385
+ "DataclassInstance",
386
+ "EllipsisType",
387
+ "ListOrTuple",
388
+ "NamedTupleInstance",
389
+ "NoneType",
390
+ "SupportsAdd",
391
+ "SupportsAnd",
392
+ "SupportsBool",
393
+ "SupportsDiv",
394
+ "SupportsGetitem",
395
+ "SupportsGetitem2",
396
+ "SupportsGetitemIterLen",
397
+ "SupportsGetitemIterLen2",
398
+ "SupportsGetitemLen",
399
+ "SupportsGetitemLen2",
400
+ "SupportsIterLen",
401
+ "SupportsLen",
402
+ "SupportsMatmul",
403
+ "SupportsMul",
404
+ "SupportsOr",
405
+ "T_BuiltinNumber",
406
+ "T_BuiltinScalar",
407
+ "check_args_types",
408
+ "is_builtin_collection",
409
+ "is_builtin_number",
410
+ "is_builtin_obj",
411
+ "is_builtin_scalar",
412
+ "is_dataclass_instance",
413
+ "is_iterable_bool",
414
+ "is_iterable_bytes_or_list",
415
+ "is_iterable_float",
416
+ "is_iterable_int",
417
+ "is_iterable_integral",
418
+ "is_iterable_str",
419
+ "is_namedtuple_instance",
420
+ "is_sequence_str",
421
+ "is_typed_dict",
422
+ "isinstance_generic",
423
+ ],
424
+ "warnings": ["deprecated_alias", "deprecated_function", "warn_once"],
425
+ },
426
+ )
427
+
428
+ Version = __getattr__("Version")
429
+
430
+
431
+ version = __version__
432
+ version_info = Version(__version__)
433
+
434
+ del Version, TYPE_CHECKING
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ from typing import TYPE_CHECKING
5
+
6
+ try:
7
+ import lazy_loader as lazy # type: ignore
8
+ except ImportError:
9
+ lazy = None
10
+
11
+
12
+ if TYPE_CHECKING or lazy is None:
13
+ from .collections import (
14
+ SizedGenerator,
15
+ contained,
16
+ dict_list_to_list_dict,
17
+ dump_dict,
18
+ duplicate_list,
19
+ filter_iterable,
20
+ find,
21
+ flat_dict_of_dict,
22
+ flat_list_of_list,
23
+ flatten,
24
+ intersect_lists,
25
+ list_dict_to_dict_list,
26
+ recursive_generator,
27
+ shuffled,
28
+ sorted_dict,
29
+ unflat_dict_of_dict,
30
+ unflat_list_of_list,
31
+ union_dicts,
32
+ union_lists,
33
+ unzip,
34
+ )
35
+ from .prop import (
36
+ all_eq,
37
+ all_ne,
38
+ is_full,
39
+ is_sorted,
40
+ is_unique,
41
+ )
42
+ from .reducers import (
43
+ intersect,
44
+ prod,
45
+ reduce_add,
46
+ reduce_and,
47
+ reduce_matmul,
48
+ reduce_mul,
49
+ reduce_or,
50
+ sum,
51
+ union,
52
+ )
53
+
54
+ else:
55
+ __getattr__, __dir__, __all__ = lazy.attach(
56
+ __name__,
57
+ submodules=[
58
+ "collections",
59
+ "prop",
60
+ "reducers",
61
+ ],
62
+ submod_attrs={
63
+ "collections": [
64
+ "SizedGenerator",
65
+ "contained",
66
+ "dict_list_to_list_dict",
67
+ "dump_dict",
68
+ "duplicate_list",
69
+ "filter_iterable",
70
+ "find",
71
+ "flat_dict_of_dict",
72
+ "flat_list_of_list",
73
+ "flatten",
74
+ "intersect_lists",
75
+ "list_dict_to_dict_list",
76
+ "recursive_generator",
77
+ "shuffled",
78
+ "sorted_dict",
79
+ "unflat_dict_of_dict",
80
+ "unflat_list_of_list",
81
+ "union_dicts",
82
+ "union_lists",
83
+ "unzip",
84
+ ],
85
+ "prop": [
86
+ "all_eq",
87
+ "all_ne",
88
+ "is_full",
89
+ "is_sorted",
90
+ "is_unique",
91
+ ],
92
+ "reducers": [
93
+ "intersect",
94
+ "prod",
95
+ "reduce_add",
96
+ "reduce_and",
97
+ "reduce_matmul",
98
+ "reduce_mul",
99
+ "reduce_or",
100
+ "sum",
101
+ "union",
102
+ ],
103
+ },
104
+ )
@@ -189,20 +189,27 @@ def _serialize_csv(
189
189
  if to_builtins:
190
190
  data = as_builtin(data)
191
191
 
192
+ is_mapping_iterable = isinstance_generic(data, Mapping[str, Iterable])
193
+ if is_mapping_iterable:
194
+ is_iterable_mapping = False
195
+ else:
196
+ is_iterable_mapping = isinstance_generic(data, Iterable[Mapping[str, Any]])
197
+
192
198
  if header == "auto":
193
- header = isinstance_generic(
194
- data, (Mapping[str, Iterable], Iterable[Mapping[str, Any]])
195
- )
199
+ header = is_mapping_iterable or is_iterable_mapping
196
200
 
197
- if isinstance_generic(data, Mapping[str, Iterable]):
198
- data_lst = dict_list_to_list_dict(data, "same") # type: ignore
199
- elif isinstance_generic(data, Iterable[Mapping[str, Any]]):
201
+ if is_mapping_iterable:
202
+ data_lst = dict_list_to_list_dict(data, "same")
203
+ elif is_iterable_mapping:
200
204
  data_lst = [dict(data_i.items()) for data_i in data]
205
+ elif isinstance(data, str):
206
+ msg = f"Invalid argument type {type(data)}."
207
+ raise TypeError(msg)
201
208
  elif not header and isinstance_generic(data, Iterable[str]):
202
209
  data_lst = [{"0": data_i} for data_i in data]
203
210
  elif not header and isinstance_generic(data, Iterable[Iterable]):
204
211
  data_lst = [dict(zip(map(str, range(len(data_i))), data)) for data_i in data]
205
- elif not header and isinstance_generic(data, Iterable):
212
+ elif not header and isinstance(data, Iterable):
206
213
  data_lst = [{"0": data_i} for data_i in data]
207
214
  else:
208
215
  msg = f"Invalid argument type {type(data)} with {header=}."