flpit 0.4.0.dev3__py3-none-any.whl → 0.4.0.dev6__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.
flpit/core/linq.py CHANGED
@@ -15,6 +15,7 @@ from itertools import islice, chain, compress
15
15
  from numbers import Real as _Real
16
16
 
17
17
  from typing import (
18
+ TYPE_CHECKING,
18
19
  Any,
19
20
  Callable,
20
21
  Iterable,
@@ -35,7 +36,9 @@ from typing import (
35
36
  Sized
36
37
  )
37
38
 
38
- from flpit.json import JsonConvert, JsonSerializerOptions
39
+ if TYPE_CHECKING:
40
+ # imported lazily at runtime: JSON support must not be loaded for plain LINQ use
41
+ from flpit.json import JsonSerializerOptions
39
42
  from flpit import ZipTuple
40
43
  from flpit.core._join import JoinTuple
41
44
  from flpit.core._index import IndexTuple
@@ -1510,14 +1513,17 @@ class FlpIt[TItem](Iterable[TItem]):
1510
1513
 
1511
1514
  @classmethod
1512
1515
  def from_json[T](cls, data: str | bytes, item_type: type[T], jso: JsonSerializerOptions|None=None) -> FlpIt[T]:
1516
+ from flpit.json import JsonConvert
1513
1517
  return FlpIt[T](JsonConvert.deserialize(data, list[item_type], jso))
1514
1518
 
1515
1519
  def to_json_bytes[T](self, item_type: type[T], jso: JsonSerializerOptions|None=None) -> bytes:
1520
+ from flpit.json import JsonConvert
1516
1521
  writer = BytesIO()
1517
1522
  JsonConvert.serialize_to(self, item_type, writer, jso)
1518
1523
  return writer.getvalue()
1519
1524
 
1520
1525
  def to_json[T](self, item_type: type[T], jso: JsonSerializerOptions|None=None) -> str:
1526
+ from flpit.json import JsonConvert
1521
1527
  writer = StringIO()
1522
1528
  JsonConvert.serialize_to(self, item_type, writer, jso)
1523
1529
  return writer.getvalue()
@@ -1528,6 +1534,7 @@ class FlpIt[TItem](Iterable[TItem]):
1528
1534
  output: BinaryIO,
1529
1535
  jso: JsonSerializerOptions | None = None,
1530
1536
  ) -> None:
1537
+ from flpit.json import JsonConvert
1531
1538
  JsonConvert.serialize_to(self, item_type, output, jso)
1532
1539
 
1533
1540
 
@@ -2321,12 +2328,15 @@ class FlpList[TItem](Collection[TItem]):
2321
2328
 
2322
2329
  @classmethod
2323
2330
  def from_json[T](cls, data: str | bytes, item_type: type[T], jso: JsonSerializerOptions|None=None) -> FlpList[T]:
2331
+ from flpit.json import JsonConvert
2324
2332
  return FlpList[T](JsonConvert.deserialize(data, list[item_type], jso))
2325
2333
 
2326
2334
  def to_json_bytes[T](self, item_type: type[T], jso: JsonSerializerOptions|None=None) -> bytes:
2335
+ from flpit.json import JsonConvert
2327
2336
  return JsonConvert.serialize_bytes(self.__list.data, list[item_type], jso)
2328
2337
 
2329
2338
  def to_json[T](self, item_type: type[T], jso: JsonSerializerOptions|None=None) -> str:
2339
+ from flpit.json import JsonConvert
2330
2340
  return JsonConvert.serialize(self.__list.data, list[item_type], jso)
2331
2341
 
2332
2342
  def write_json[T](
@@ -2335,6 +2345,7 @@ class FlpList[TItem](Collection[TItem]):
2335
2345
  output: BinaryIO,
2336
2346
  jso: JsonSerializerOptions | None = None,
2337
2347
  ) -> None:
2348
+ from flpit.json import JsonConvert
2338
2349
  JsonConvert.serialize_to(self, item_type, output, jso)
2339
2350
 
2340
2351
  # I hate it, but Python being Python