执行 Ruff 安全自动修复
This commit is contained in:
@@ -116,7 +116,7 @@ class Envelope:
|
||||
self._parse()
|
||||
|
||||
@classmethod
|
||||
def load(cls, path: str | Path | None = None) -> "Envelope":
|
||||
def load(cls, path: str | Path | None = None) -> Envelope:
|
||||
"""加载信封模板,支持从文件加载或使用内嵌金样本。"""
|
||||
if path:
|
||||
p = Path(path)
|
||||
@@ -136,7 +136,7 @@ class Envelope:
|
||||
return cls(base64.b64decode(DEFAULT_QURL_B64))
|
||||
|
||||
@classmethod
|
||||
def _load_from_path(cls, p: Path) -> "Envelope":
|
||||
def _load_from_path(cls, p: Path) -> Envelope:
|
||||
if p.suffix == ".json":
|
||||
j = json.loads(p.read_text("utf-8"))
|
||||
q = next(
|
||||
@@ -236,7 +236,7 @@ class Envelope:
|
||||
assert self.uid_off is not None
|
||||
return struct.unpack_from(">Q", self.raw, self.uid_off)[0]
|
||||
|
||||
def patch_uid(self, uid: int) -> "Envelope":
|
||||
def patch_uid(self, uid: int) -> Envelope:
|
||||
assert self.uid_off is not None
|
||||
struct.pack_into(">Q", self.raw, self.uid_off, uid)
|
||||
return self
|
||||
@@ -246,7 +246,7 @@ class Envelope:
|
||||
assert self.cert_off is not None
|
||||
return bytes(self.raw[self.cert_off : self.cert_off + self.cert_len])
|
||||
|
||||
def patch_cert(self, cert: bytes) -> "Envelope":
|
||||
def patch_cert(self, cert: bytes) -> Envelope:
|
||||
assert self.cert_off is not None
|
||||
b64 = base64.b64encode(cert)
|
||||
if len(b64) != self.cert_len:
|
||||
@@ -256,7 +256,7 @@ class Envelope:
|
||||
self.raw[self.cert_off : self.cert_off + self.cert_len] = b64
|
||||
return self
|
||||
|
||||
def patch_session(self, session: int) -> "Envelope":
|
||||
def patch_session(self, session: int) -> Envelope:
|
||||
if self.tag4_span:
|
||||
struct.pack_into(">I", self.raw, self.tag4_span[0], session & 0xFFFFFFFF)
|
||||
d = self.raw
|
||||
|
||||
Reference in New Issue
Block a user