@@ -1836,18 +1836,18 @@ def write_unversioned_report(self, output_path: Path) -> None:
18361836 def normalize_dependency_name (self , name : str ) -> str :
18371837 """
18381838 Normalize dependency names to detect the same dependency referred to differently.
1839-
1839+
18401840 Examples:
18411841 - torch, pytorch, PyTorch -> pytorch
18421842 - tensorflow, TensorFlow -> tensorflow
18431843 - numpy, NumPy -> numpy
1844-
1844+
18451845 Note: This is intentionally conservative to avoid false positives.
18461846 Only normalizes well-known dependencies with common naming variations.
18471847 """
18481848 # Convert to lowercase for comparison
18491849 name_lower = name .lower ()
1850-
1850+
18511851 # Common normalization rules (ordered by specificity to avoid false matches)
18521852 normalizations = {
18531853 "tensorrt-llm" : "tensorrt-llm" ,
@@ -1861,91 +1861,95 @@ def normalize_dependency_name(self, name: str) -> str:
18611861 "nccl" : "nccl" ,
18621862 "nixl" : "nixl" ,
18631863 }
1864-
1864+
18651865 # Check if name matches any normalization rules (exact or starts with)
18661866 for key , normalized in normalizations .items ():
18671867 if name_lower == key or name_lower .startswith (key + " " ):
18681868 return normalized
1869-
1869+
18701870 # Default: return the lowercase name unchanged
18711871 # This avoids false positives from overly broad matching
18721872 return name_lower .strip ()
18731873
18741874 def detect_version_discrepancies (self ) -> List [Dict [str , any ]]:
18751875 """
18761876 Detect dependencies that appear multiple times with different versions.
1877-
1877+
18781878 Returns:
18791879 List of dictionaries containing discrepancy information:
18801880 - dependency_name: The normalized dependency name
18811881 - instances: List of {version, source_file, component} for each occurrence
18821882 """
18831883 # Group dependencies by normalized name
18841884 dependency_groups = {}
1885-
1885+
18861886 for dep in self .dependencies :
18871887 normalized_name = self .normalize_dependency_name (dep ["Dependency Name" ])
1888-
1888+
18891889 # Skip unversioned dependencies for discrepancy detection
18901890 if dep ["Version" ] in ["unspecified" , "N/A" , "" , "latest" ]:
18911891 continue
1892-
1892+
18931893 if normalized_name not in dependency_groups :
18941894 dependency_groups [normalized_name ] = []
1895-
1896- dependency_groups [normalized_name ].append ({
1897- "original_name" : dep ["Dependency Name" ],
1898- "version" : dep ["Version" ],
1899- "source_file" : dep ["Source File" ],
1900- "component" : dep ["Component" ],
1901- "category" : dep ["Category" ],
1902- "critical" : dep ["Critical" ] == "Yes" ,
1903- })
1904-
1895+
1896+ dependency_groups [normalized_name ].append (
1897+ {
1898+ "original_name" : dep ["Dependency Name" ],
1899+ "version" : dep ["Version" ],
1900+ "source_file" : dep ["Source File" ],
1901+ "component" : dep ["Component" ],
1902+ "category" : dep ["Category" ],
1903+ "critical" : dep ["Critical" ] == "Yes" ,
1904+ }
1905+ )
1906+
19051907 # Detect discrepancies: same normalized name with different versions
19061908 discrepancies = []
1907-
1909+
19081910 for normalized_name , instances in dependency_groups .items ():
19091911 # Get unique versions
19101912 versions = set (inst ["version" ] for inst in instances )
1911-
1913+
19121914 # If multiple versions exist, it's a discrepancy
19131915 if len (versions ) > 1 :
1914- discrepancies .append ({
1915- "normalized_name" : normalized_name ,
1916- "versions" : sorted (versions ),
1917- "instances" : instances ,
1918- "is_critical" : any (inst ["critical" ] for inst in instances ),
1919- })
1920-
1916+ discrepancies .append (
1917+ {
1918+ "normalized_name" : normalized_name ,
1919+ "versions" : sorted (versions ),
1920+ "instances" : instances ,
1921+ "is_critical" : any (inst ["critical" ] for inst in instances ),
1922+ }
1923+ )
1924+
19211925 return discrepancies
19221926
19231927 def _output_github_warnings (self , discrepancies : List [Dict [str , any ]]) -> None :
19241928 """
19251929 Output GitHub Actions warning annotations for version discrepancies.
1926-
1930+
19271931 This uses the GitHub Actions workflow command format:
19281932 ::warning file={file},line={line}::{message}
1929-
1933+
19301934 See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions
19311935 """
19321936 for disc in discrepancies :
19331937 normalized_name = disc ["normalized_name" ]
19341938 versions = disc ["versions" ]
19351939 is_critical = disc ["is_critical" ]
19361940 instances = disc ["instances" ]
1937-
1941+
19381942 # Create a concise message for the annotation
19391943 critical_prefix = "[CRITICAL] " if is_critical else ""
19401944 versions_str = ", " .join (versions )
1941-
1945+
19421946 # Output a warning for each source file where the dependency appears
19431947 for inst in instances :
19441948 message = (
19451949 f"{ critical_prefix } Version discrepancy detected for '{ normalized_name } ': "
19461950 f"found { inst ['version' ]} here, but also appears as { versions_str } elsewhere"
19471951 )
1948-
1952+
19491953 # Output GitHub Actions warning annotation
19501954 # Format: ::warning file={name}::{message}
19511955 print (f"::warning file={ inst ['source_file' ]} ::{ message } " )
@@ -2043,25 +2047,25 @@ def print_summary(self) -> None:
20432047 f"\n ⚠️ WARNING: Found { len (discrepancies )} dependencies with version discrepancies!"
20442048 )
20452049 print ("\n Dependencies pinned at different versions across the repo:" )
2046-
2050+
20472051 for disc in discrepancies [:10 ]: # Show first 10
20482052 critical_flag = " [CRITICAL]" if disc ["is_critical" ] else ""
20492053 print (f"\n • { disc ['normalized_name' ]} { critical_flag } " )
20502054 print (f" Versions found: { ', ' .join (disc ['versions' ])} " )
2051- print (f " Locations:" )
2052-
2055+ print (" Locations:" )
2056+
20532057 for inst in disc ["instances" ][:5 ]: # Show first 5 instances
20542058 print (
20552059 f" - { inst ['version' ]:15s} in { inst ['component' ]:10s} "
20562060 f"({ inst ['source_file' ]} )"
20572061 )
2058-
2062+
20592063 if len (disc ["instances" ]) > 5 :
20602064 print (f" ... and { len (disc ['instances' ]) - 5 } more locations" )
2061-
2065+
20622066 if len (discrepancies ) > 10 :
20632067 print (f"\n ... and { len (discrepancies ) - 10 } more discrepancies" )
2064-
2068+
20652069 print ("\n 💡 Tip: Version discrepancies can cause:" )
20662070 print (" - Runtime conflicts and crashes" )
20672071 print (" - Unexpected behavior differences between components" )
@@ -2071,7 +2075,7 @@ def print_summary(self) -> None:
20712075 "\n Consider standardizing versions across the repo or documenting why "
20722076 "differences are necessary."
20732077 )
2074-
2078+
20752079 # Output GitHub Actions warnings for CI visibility
20762080 self ._output_github_warnings (discrepancies )
20772081 else :
0 commit comments