@@ -516,15 +516,7 @@ async def create_locally(
516
516
return True
517
517
518
518
@classmethod
519
- async def new (cls , service : Optional [InfrahubServices ] = None , ** kwargs ):
520
- service = service or InfrahubServices ()
521
- self = cls (service = service , ** kwargs )
522
- await self .create_locally ()
523
- log .info ("Created the new project locally." , repository = self .name )
524
- return self
525
-
526
- @classmethod
527
- async def init (cls , service : Optional [InfrahubServices ] = None , ** kwargs ):
519
+ async def init (cls , service : Optional [InfrahubServices ] = None , ** kwargs : Any ):
528
520
service = service or InfrahubServices ()
529
521
self = cls (service = service , ** kwargs )
530
522
self .validate_local_directories ()
@@ -861,7 +853,7 @@ async def get_conflicts(self, source_branch: str, dest_branch: str) -> List[str]
861
853
862
854
return conflict_files
863
855
864
- async def import_objects_from_files (self , branch_name : str , commit : Optional [str ] = None ):
856
+ async def import_objects_from_files (self , branch_name : str , commit : Optional [str ] = None ) -> None :
865
857
if not commit :
866
858
commit = self .get_commit_value (branch_name = branch_name )
867
859
@@ -878,7 +870,9 @@ async def import_objects_from_files(self, branch_name: str, commit: Optional[str
878
870
await self .import_jinja2_transforms (branch_name = branch_name , commit = commit , config_file = config_file )
879
871
await self .import_artifact_definitions (branch_name = branch_name , commit = commit , config_file = config_file )
880
872
881
- async def import_jinja2_transforms (self , branch_name : str , commit : str , config_file : InfrahubRepositoryConfig ):
873
+ async def import_jinja2_transforms (
874
+ self , branch_name : str , commit : str , config_file : InfrahubRepositoryConfig
875
+ ) -> None :
882
876
log .debug ("Importing all Jinja2 transforms" , repository = self .name , branch = branch_name , commit = commit )
883
877
884
878
schema = await self .sdk .schema .get (kind = InfrahubKind .TRANSFORMJINJA2 , branch = branch_name )
@@ -986,7 +980,9 @@ async def update_jinja2_transform(
986
980
987
981
await existing_transform .save ()
988
982
989
- async def import_artifact_definitions (self , branch_name : str , commit : str , config_file : InfrahubRepositoryConfig ):
983
+ async def import_artifact_definitions (
984
+ self , branch_name : str , commit : str , config_file : InfrahubRepositoryConfig
985
+ ) -> None :
990
986
log .debug ("Importing all Artifact Definitions" , repository = self .name , branch = branch_name , commit = commit )
991
987
992
988
schema = await self .sdk .schema .get (kind = InfrahubKind .ARTIFACTDEFINITION , branch = branch_name )
@@ -1770,7 +1766,9 @@ async def compare_python_transform(
1770
1766
return False
1771
1767
return True
1772
1768
1773
- async def import_all_python_files (self , branch_name : str , commit : str , config_file : InfrahubRepositoryConfig ):
1769
+ async def import_all_python_files (
1770
+ self , branch_name : str , commit : str , config_file : InfrahubRepositoryConfig
1771
+ ) -> None :
1774
1772
await self .import_python_check_definitions (branch_name = branch_name , commit = commit , config_file = config_file )
1775
1773
await self .import_python_transforms (branch_name = branch_name , commit = commit , config_file = config_file )
1776
1774
await self .import_generator_definitions (branch_name = branch_name , commit = commit , config_file = config_file )
@@ -1820,7 +1818,7 @@ async def get_file(self, commit: str, location: str) -> str:
1820
1818
1821
1819
return path .read_text (encoding = "UTF-8" )
1822
1820
1823
- async def render_jinja2_template (self , commit : str , location : str , data : dict ):
1821
+ async def render_jinja2_template (self , commit : str , location : str , data : dict ) -> str :
1824
1822
commit_worktree = self .get_commit_worktree (commit = commit )
1825
1823
1826
1824
self .validate_location (commit = commit , worktree_directory = commit_worktree .directory , file_path = location )
@@ -1831,7 +1829,7 @@ async def render_jinja2_template(self, commit: str, location: str, data: dict):
1831
1829
template = templateEnv .get_template (location )
1832
1830
return template .render (** data )
1833
1831
except Exception as exc :
1834
- log .error (exc , exc_info = True , repository = self .name , commit = commit , location = location )
1832
+ log .error (str ( exc ) , exc_info = True , repository = self .name , commit = commit , location = location )
1835
1833
raise TransformError (repository_name = self .name , commit = commit , location = location , message = str (exc )) from exc
1836
1834
1837
1835
async def execute_python_check (
@@ -1894,7 +1892,7 @@ async def execute_python_check(
1894
1892
1895
1893
except Exception as exc :
1896
1894
log .critical (
1897
- exc ,
1895
+ str ( exc ) ,
1898
1896
exc_info = True ,
1899
1897
repository = self .name ,
1900
1898
branch = branch_name ,
@@ -2090,7 +2088,7 @@ class InfrahubRepository(InfrahubRepositoryBase):
2090
2088
"""
2091
2089
2092
2090
def get_commit_value (self , branch_name : str , remote : bool = False ) -> str :
2093
- branches = None
2091
+ branches = {}
2094
2092
if remote :
2095
2093
branches = self .get_branches_from_remote ()
2096
2094
else :
@@ -2265,6 +2263,14 @@ async def rebase(self, branch_name: str, source_branch: str = "main", push_remot
2265
2263
2266
2264
return response
2267
2265
2266
+ @classmethod
2267
+ async def new (cls , service : Optional [InfrahubServices ] = None , ** kwargs : Any ) -> InfrahubRepository :
2268
+ service = service or InfrahubServices ()
2269
+ self = cls (service = service , ** kwargs )
2270
+ await self .create_locally ()
2271
+ log .info ("Created the new project locally." , repository = self .name )
2272
+ return self
2273
+
2268
2274
2269
2275
class InfrahubReadOnlyRepository (InfrahubRepositoryBase ):
2270
2276
"""
@@ -2278,7 +2284,7 @@ class InfrahubReadOnlyRepository(InfrahubRepositoryBase):
2278
2284
)
2279
2285
2280
2286
@classmethod
2281
- async def new (cls , service : Optional [InfrahubServices ] = None , ** kwargs ) :
2287
+ async def new (cls , service : Optional [InfrahubServices ] = None , ** kwargs : Any ) -> InfrahubReadOnlyRepository :
2282
2288
service = service or InfrahubServices ()
2283
2289
2284
2290
if "ref" not in kwargs or "infrahub_branch_name" not in kwargs :
0 commit comments