chore: refurbish Python code by applying refurb linter rules (#8296)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import shutil
|
||||
from collections.abc import Generator
|
||||
from pathlib import Path
|
||||
|
||||
from flask import Flask
|
||||
|
||||
@@ -26,8 +27,7 @@ class LocalStorage(BaseStorage):
|
||||
folder = os.path.dirname(filename)
|
||||
os.makedirs(folder, exist_ok=True)
|
||||
|
||||
with open(os.path.join(os.getcwd(), filename), "wb") as f:
|
||||
f.write(data)
|
||||
Path(os.path.join(os.getcwd(), filename)).write_bytes(data)
|
||||
|
||||
def load_once(self, filename: str) -> bytes:
|
||||
if not self.folder or self.folder.endswith("/"):
|
||||
@@ -38,9 +38,7 @@ class LocalStorage(BaseStorage):
|
||||
if not os.path.exists(filename):
|
||||
raise FileNotFoundError("File not found")
|
||||
|
||||
with open(filename, "rb") as f:
|
||||
data = f.read()
|
||||
|
||||
data = Path(filename).read_bytes()
|
||||
return data
|
||||
|
||||
def load_stream(self, filename: str) -> Generator:
|
||||
|
Reference in New Issue
Block a user