Skip to content

Commit

Permalink
fix: typing.List compatible with python3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
xyb committed Aug 14, 2023
1 parent 57b85ed commit a605e21
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion task/baidupcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pathlib import PurePosixPath
from time import sleep
from typing import Callable
from typing import List

from baidupcs_py.baidupcs import BaiduPCSApi
from baidupcs_py.baidupcs import BaiduPCSError
Expand Down Expand Up @@ -278,7 +279,7 @@ def list_all_sub_paths(
uk: int,
share_id: int,
bdstoken: str,
) -> list[dict]:
) -> List[dict]:
sub_paths = []
page = 1
size = 100
Expand Down
7 changes: 4 additions & 3 deletions task/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from os.path import getsize
from os.path import join
from pathlib import Path
from typing import List

from django.conf import settings
from django.db import models
Expand Down Expand Up @@ -133,7 +134,7 @@ def set_files(self, files) -> None:
file_list.append(file)
self.files = dumps(file_list)

def load_files(self) -> [dict]:
def load_files(self) -> List[dict]:
return loads(self.files or "[]") or []

def list_remote_files(self, files_only: bool = True) -> [dict]:
Expand All @@ -145,7 +146,7 @@ def list_remote_files(self, files_only: bool = True) -> [dict]:
return files

@property
def remote_files(self) -> [dict]:
def remote_files(self) -> List[dict]:
return self.list_remote_files(files_only=True)

def list_local_files(self) -> [dict]:
Expand All @@ -157,7 +158,7 @@ def list_local_files(self) -> [dict]:
yield {"file": sub_path, "size": getsize(filepath)}

@property
def local_files(self) -> [dict]:
def local_files(self) -> List[dict]:
return list(self.list_local_files())

@property
Expand Down

0 comments on commit a605e21

Please sign in to comment.