99import re
1010from os import PathLike
1111from pathlib import Path
12- from typing import Any , Optional
12+ from typing import Any , Dict , Optional
1313
1414import networkx as nx
1515
@@ -56,30 +56,30 @@ def __init__(
5656 self ._parser = Parser (gardenlinux_root , feature_dir_name , logger )
5757 self ._feature_dir_name = Path (self ._gardenlinux_root ).joinpath (feature_dir_name )
5858
59- self .all = set ()
60- self .successful = []
61- self .whitelist = []
62- self .expected_falvors = set ()
63- self .missing_flavors = set ()
64- self .unexpected_falvors = set ()
59+ self .all : set [ str ] = set ()
60+ self .successful : set [ str ] = set ()
61+ self .whitelist : set [ str ] = set ()
62+ self .expected_falvors : set [ str ] = set ()
63+ self .missing_flavors : set [ str ] = set ()
64+ self .unexpected_falvors : set [ str ] = set ()
6565
66- def read_feature_info (self , feature : str ) -> dict [ str , Any ] :
66+ def read_feature_info (self , feature : str ) -> Any :
6767 """
6868 Read the content of the feature info.yaml
6969
7070 :param feature: The queried feature
7171
72- :return: dict [str, Any] Parsed content of the features' info.yaml file
72+ :return: Dict [str, Any] Parsed content of the features' info.yaml file
7373 :since: 1.0.0
7474 """
7575 return self ._parser .read_feature_yaml (
76- self ._feature_dir_name .joinpath (f"{ feature } /info.yaml" )
76+ str ( self ._feature_dir_name .joinpath (f"{ feature } /info.yaml" ) )
7777 )["content" ]
7878
7979 def parse (
8080 self ,
81- flavors_matrix : dict [str , list [dict [str , str ]]],
82- bare_flavors_matrix : dict [str , list [dict [str , str ]]],
81+ flavors_matrix : Dict [str , list [Dict [str , str ]]],
82+ bare_flavors_matrix : Dict [str , list [Dict [str , str ]]],
8383 diff_dir : PathLike [str ] = Path ("diffs" ),
8484 ) -> None :
8585 """
@@ -93,20 +93,16 @@ def parse(
9393 """
9494
9595 self .all = set ()
96- self .successful = []
97- self .whitelist = []
96+ self .successful = set ()
97+ self .whitelist = set ()
9898 failed = {} # {flavor: [files...]}
9999
100100 diff_dir = Path (self ._gardenlinux_root ).joinpath (diff_dir )
101101
102- self .expected_falvors = set (
103- [
104- f"{ variant ['flavor' ]} -{ variant ['arch' ]} "
105- for variant in (
106- flavors_matrix ["include" ] + bare_flavors_matrix ["include" ]
107- )
108- ]
109- )
102+ self .expected_falvors = {
103+ f"{ variant ['flavor' ]} -{ variant ['arch' ]} "
104+ for variant in (flavors_matrix ["include" ] + bare_flavors_matrix ["include" ])
105+ }
110106
111107 for flavor in os .listdir (diff_dir ):
112108 if flavor .endswith (self ._SUFFIX ):
@@ -116,38 +112,38 @@ def parse(
116112 flavor = flavor .rstrip (self ._SUFFIX )
117113 self .all .add (flavor )
118114 if content == "" :
119- self .successful .append (flavor )
115+ self .successful .add (flavor )
120116 elif content == "whitelist\n " :
121- self .successful .append (flavor )
122- self .whitelist .append (flavor )
117+ self .successful .add (flavor )
118+ self .whitelist .add (flavor )
123119 else :
124120 failed [flavor ] = content .split ("\n " )[:- 1 ]
125121
126122 self .missing_flavors = self .expected_falvors - self .all
127123 self .unexpected_falvors = self .all - self .expected_falvors
128124
129125 # Map files to flavors
130- affected : dict [str , set [str ]] = {} # {file: {flavors...}}
126+ affected : Dict [str , set [str ]] = {} # {file: {flavors...}}
131127 for flavor in failed :
132128 for file in failed [flavor ]:
133129 if file not in affected :
134130 affected [file ] = set ()
135131 affected [file ].add (flavor )
136132
137133 # Merge files affected by the same flavors by mapping flavor sets to files
138- self ._bundled : dict [frozenset [str ], set [str ]] = {} # {{flavors...}: {files...}}
134+ self ._bundled : Dict [frozenset [str ], set [str ]] = {} # {{flavors...}: {files...}}
139135 for file in affected :
140136 if frozenset (affected [file ]) not in self ._bundled :
141137 self ._bundled [frozenset (affected [file ])] = set ()
142138 self ._bundled [frozenset (affected [file ])].add (file )
143139
144140 def intersectionTrees (
145141 self ,
146- ) -> dict [frozenset [str ], tuple [frozenset [str ], nx .DiGraph ]]:
142+ ) -> Dict [frozenset [str ], tuple [frozenset [str ], nx .DiGraph ]]:
147143 """
148144 Intersects all features of the affected flavors and removes all features from unaffected flavors to identify features causing the issue
149145
150- :return: (dict [frozenset[str], tuple[frozenset[str], nx.DiGraph]]) Dict in the form of {{files...}: ({flavors..., intersectionTree})}
146+ :return: (Dict [frozenset[str], tuple[frozenset[str], nx.DiGraph]]) Dict in the form of {{files...}: ({flavors..., intersectionTree})}
151147 :since: 1.0.0
152148 """
153149
0 commit comments