Skip to content

Commit 00e9768

Browse files
committed
File - typeint improvement
1 parent 1ed0def commit 00e9768

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

‎UnityPy/files/File.py‎

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
1-
from ..enums import FileType
2-
from ..helpers import ImportHelper
3-
from ..streams import EndianBinaryReader, EndianBinaryWriter
1+
from __future__ import annotations
42

53
from collections import namedtuple
64
from os.path import basename
5+
from typing import TYPE_CHECKING, Dict, Optional
6+
7+
from ..helpers import ImportHelper
8+
from ..streams import EndianBinaryReader, EndianBinaryWriter
9+
10+
if TYPE_CHECKING:
11+
from ..environment import Environment
712

813
DirectoryInfo = namedtuple("DirectoryInfo", "path offset size")
914

1015

1116
class File(object):
1217
name: str
13-
files: dict
14-
environment: "Environment"
18+
files: Dict[str, File]
19+
environment: Environment
1520
cab_file: str
1621
is_changed: bool
1722
signature: str
1823
packer: str
1924
is_dependency: bool
20-
21-
# parent: File
22-
# environment: Environment
23-
24-
def __init__(self, parent=None, name: str = None, is_dependency: bool = False):
25+
parent: Optional[File]
26+
27+
def __init__(
28+
self,
29+
parent: Optional[File] = None,
30+
name: Optional[str] = None,
31+
is_dependency: bool = False,
32+
):
2533
self.files = {}
2634
self.is_changed = False
2735
self.cab_file = "CAB-UnityPy_Mod.resS"
@@ -154,4 +162,4 @@ def mark_changed(self):
154162

155163

156164
# recursive import requires the import down here
157-
from . import BundleFile, SerializedFile, WebFile, ObjectReader
165+
from . import BundleFile, ObjectReader, SerializedFile, WebFile

0 commit comments

Comments
 (0)