python-filewrap 0.0.7__py3-none-any.whl → 0.0.7.2__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.
filewrap/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
  __author__ = "ChenyangGao <https://chenyanggao.github.io>"
5
5
  __version__ = (0, 0, 7)
6
6
  __all__ = [
7
- "SupportsRead", "SupportsWrite",
7
+ "SupportsRead", "SupportsWrite", "SupportsSeek",
8
8
  "bio_chunk_iter", "bio_chunk_async_iter",
9
9
  "bio_skip_iter", "bio_skip_async_iter",
10
10
  "bytes_iter_skip", "bytes_async_iter_skip",
@@ -14,14 +14,13 @@ __all__ = [
14
14
  ]
15
15
 
16
16
  from asyncio import to_thread, Lock as AsyncLock
17
- from collections.abc import Awaitable, AsyncIterable, Iterable
17
+ from collections.abc import Awaitable, AsyncIterable, AsyncIterator, Callable, Iterable, Iterator
18
18
  from functools import update_wrapper
19
19
  from inspect import isawaitable, iscoroutinefunction
20
20
  from itertools import chain
21
- from collections.abc import AsyncIterator, Callable, Iterator
22
21
  from shutil import COPY_BUFSIZE # type: ignore
23
22
  from threading import Lock
24
- from typing import Any, Protocol, TypeVar
23
+ from typing import runtime_checkable, Any, Protocol, TypeVar
25
24
 
26
25
  try:
27
26
  from collections.abc import Buffer # type: ignore
@@ -35,12 +34,19 @@ _T_co = TypeVar("_T_co", covariant=True)
35
34
  _T_contra = TypeVar("_T_contra", contravariant=True)
36
35
 
37
36
 
37
+ @runtime_checkable
38
38
  class SupportsRead(Protocol[_T_co]):
39
- def read(self, __length: int = ...) -> _T_co: ...
39
+ def read(self, /, __length: int = ...) -> _T_co: ...
40
40
 
41
41
 
42
+ @runtime_checkable
42
43
  class SupportsWrite(Protocol[_T_contra]):
43
- def write(self, __s: _T_contra) -> object: ...
44
+ def write(self, /, __s: _T_contra) -> object: ...
45
+
46
+
47
+ @runtime_checkable
48
+ class SupportsSeek(Protocol[_T_contra]):
49
+ def seek(self, /, __offset: int, __whence: int = 0) -> int: ...
44
50
 
45
51
 
46
52
  def bio_chunk_iter(
@@ -185,6 +191,7 @@ async def bio_skip_async_iter(
185
191
  if size == 0:
186
192
  return
187
193
  callback = ensure_async(callback) if callable(callback) else None
194
+ length: int
188
195
  try:
189
196
  seek = ensure_async(getattr(bio, "seek"))
190
197
  curpos = await seek(0, 1)
@@ -269,7 +276,7 @@ def bytes_iter_skip(
269
276
 
270
277
 
271
278
  async def bytes_async_iter_skip(
272
- it: Iterable[Buffer] | AsyncIterator[Buffer],
279
+ it: Iterable[Buffer] | AsyncIterable[Buffer],
273
280
  /,
274
281
  size: int = -1,
275
282
  callback: None | Callable[[int], Any] = None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-filewrap
3
- Version: 0.0.7
3
+ Version: 0.0.7.2
4
4
  Summary: Python file wrappers.
5
5
  Home-page: https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/python-filewrap
6
6
  License: MIT
@@ -0,0 +1,7 @@
1
+ LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
2
+ filewrap/__init__.py,sha256=6XD5ftZ6z5WDo6RDOpGONYlEp7rzBYbqulXVm9z-HnA,16773
3
+ filewrap/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ python_filewrap-0.0.7.2.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
5
+ python_filewrap-0.0.7.2.dist-info/METADATA,sha256=6yuS1eI1vZTXQUNqg4ysI4B1L0qfOqeJJuCFzJvH9ZQ,1364
6
+ python_filewrap-0.0.7.2.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
7
+ python_filewrap-0.0.7.2.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
2
- filewrap/__init__.py,sha256=X3RWnRcr2wycOIQJomqKRdwh2lA8GWUJJLZb8tDpodU,16575
3
- filewrap/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- python_filewrap-0.0.7.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
5
- python_filewrap-0.0.7.dist-info/METADATA,sha256=Tt3qu_XvzzpK7AuNBh5vPGJJpql5ezi9PYosXqctUbY,1362
6
- python_filewrap-0.0.7.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
7
- python_filewrap-0.0.7.dist-info/RECORD,,