Skip to content

Commit 356697e

Browse files
Copilotpontemonti
andauthored
Use regex for dependency version specifier parsing (#82)
* Initial plan * Use regex for parsing dependency version specifiers Co-authored-by: pontemonti <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: pontemonti <[email protected]>
1 parent c8601ae commit 356697e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

generate_dependency_diagram.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Reads pyproject.toml files and creates a Mermaid diagram showing internal package dependencies.
77
"""
88

9+
import re
910
import tomllib
1011
from pathlib import Path
1112
from typing import Dict, List, Set
@@ -34,7 +35,8 @@ def extract_dependencies(pyproject_data: Dict, package_names: Set[str]) -> Set[s
3435
if 'project' in pyproject_data and 'dependencies' in pyproject_data['project']:
3536
for dep in pyproject_data['project']['dependencies']:
3637
# Extract package name (before any version specifier)
37-
dep_name = dep.split('>=')[0].split('==')[0].split('<')[0].strip()
38+
# Use regex to handle multiple version specifiers (e.g., "package>=1.0,<2.0")
39+
dep_name = re.split(r'[><=!~]', dep)[0].strip()
3840

3941
# Only include if it's one of our internal packages
4042
if dep_name in package_names:

0 commit comments

Comments
 (0)