File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 2929"""
3030
3131from abc import ABC , abstractmethod
32- from typing import Optional
32+ from typing import ClassVar
3333
3434
3535class Codec (ABC ):
3636 """Codec abstract base class."""
3737
38- # override in sub-class
39- codec_id : Optional [str ] = None
38+ codec_id : ClassVar [str ]
4039 """Codec identifier."""
4140
4241 @abstractmethod
Original file line number Diff line number Diff line change 11import gzip as _gzip
22import io
3+ from typing import ClassVar , Literal
34
45from .abc import Codec
56from .compat import ensure_bytes , ensure_contiguous_ndarray
@@ -15,12 +16,13 @@ class GZip(Codec):
1516
1617 """
1718
18- codec_id = 'gzip'
19+ codec_id : ClassVar [Literal ['gzip' ]] = 'gzip'
20+ level : int
1921
2022 def __init__ (self , level = 1 ):
2123 self .level = level
2224
23- def encode (self , buf ):
25+ def encode (self , buf ) -> bytes :
2426 # normalise inputs
2527 buf = ensure_contiguous_ndarray (buf )
2628
@@ -31,7 +33,7 @@ def encode(self, buf):
3133 return compressed .getvalue ()
3234
3335 # noinspection PyMethodMayBeStatic
34- def decode (self , buf , out = None ):
36+ def decode (self , buf , out = None ) -> bytes :
3537 # normalise inputs
3638 # BytesIO only copies if the data is not of `bytes` type.
3739 # This allows `bytes` objects to pass through without copying.
You can’t perform that action at this time.
0 commit comments