1212
1313from vunit .project import Project
1414from vunit .sim_if import OptionType
15- from vunit .ui import VUnit
16- from vunit .ui .library import Library
1715from .. import ostools
18- from vunit .source_file import SourceFile as Source_File , VHDLSourceFile
16+ from typing import TYPE_CHECKING
17+
18+ if TYPE_CHECKING :
19+ from vunit .source_file import SourceFile as Source_File
20+ from vunit .ui import VUnit
21+ from vunit .ui .library import Library
1922
2023
2124class SourceFile (object ):
2225 """
2326 A single file
2427 """
2528
26- def __init__ (self , source_file : Source_File , project : Project , ui : VUnit ) -> None :
29+ def __init__ (self , source_file : " Source_File" , project : Project , ui : " VUnit" ) -> None :
2730 self ._source_file = source_file
2831 self ._project = project
2932 self ._ui = ui
@@ -41,13 +44,16 @@ def vhdl_standard(self) -> Optional[str]:
4144 The VHDL standard applicable to the file,
4245 None if not a VHDL file
4346 """
47+ # Import here to avoid circular import problems
48+ from vunit .source_file import VHDLSourceFile
49+
4450 if isinstance (self ._source_file , VHDLSourceFile ):
4551 return str (self ._source_file .get_vhdl_standard ())
4652
4753 return None
4854
4955 @property
50- def library (self ) -> Library :
56+ def library (self ) -> " Library" :
5157 """
5258 The library of the source file
5359 """
@@ -85,7 +91,7 @@ def get_compile_option(self, name: str) -> OptionType:
8591 """
8692 return self ._source_file .get_compile_option (name )
8793
88- def add_dependency_on (self , source_file : Union [Iterable [Source_File ], Source_File ]) -> None :
94+ def add_dependency_on (self , source_file : Union [Iterable [" Source_File" ], " Source_File" ]) -> None :
8995 """
9096 Add manual dependency of this file other file(s)
9197
@@ -142,7 +148,7 @@ def add_compile_option(self, name: str, value: OptionType) -> None:
142148 for source_file in self :
143149 source_file .add_compile_option (name , value )
144150
145- def add_dependency_on (self , source_file : Source_File ) -> None :
151+ def add_dependency_on (self , source_file : " Source_File" ) -> None :
146152 """
147153 Add manual dependency of these files on other file(s)
148154
0 commit comments