From 66f3c4865d3124bf974e869439fdab5ad00e664d Mon Sep 17 00:00:00 2001 From: clavedeluna Date: Wed, 25 Oct 2023 15:11:02 -0300 Subject: [PATCH] review feedback --- src/codemodder/context.py | 1 + .../project_analysis/file_parsers/setup_cfg_file_parser.py | 4 ++-- .../project_analysis/file_parsers/setup_py_file_parser.py | 4 ++-- src/codemodder/project_analysis/file_parsers/utils.py | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/codemodder/context.py b/src/codemodder/context.py index 15f71d059..3f97f89ac 100644 --- a/src/codemodder/context.py +++ b/src/codemodder/context.py @@ -33,6 +33,7 @@ class CodemodExecutionContext: # pylint: disable=too-many-instance-attributes dry_run: bool = False verbose: bool = False registry: CodemodRegistry + repo_manager: PythonRepoManager def __init__( self, diff --git a/src/codemodder/project_analysis/file_parsers/setup_cfg_file_parser.py b/src/codemodder/project_analysis/file_parsers/setup_cfg_file_parser.py index 5a6cb3f87..5f7156810 100644 --- a/src/codemodder/project_analysis/file_parsers/setup_cfg_file_parser.py +++ b/src/codemodder/project_analysis/file_parsers/setup_cfg_file_parser.py @@ -10,7 +10,7 @@ class SetupCfgParser(BaseParser): def file_name(self): return "setup.cfg" - def _parse_dependencies_from_toml(self, config: configparser.ConfigParser): + def _parse_dependencies_from_cfg(self, config: configparser.ConfigParser): # todo: handle cases for # 1. no dependencies, no options dict # setup_requires, tests_require, extras_require @@ -32,6 +32,6 @@ def _parse_file(self, file: Path): return PackageStore( type=self.file_name, file=str(file), - dependencies=self._parse_dependencies_from_toml(config), + dependencies=self._parse_dependencies_from_cfg(config), py_versions=self._parse_py_versions(config), ) diff --git a/src/codemodder/project_analysis/file_parsers/setup_py_file_parser.py b/src/codemodder/project_analysis/file_parsers/setup_py_file_parser.py index a80efdcd1..2fbd78d79 100644 --- a/src/codemodder/project_analysis/file_parsers/setup_py_file_parser.py +++ b/src/codemodder/project_analysis/file_parsers/setup_py_file_parser.py @@ -31,7 +31,7 @@ def _parse_py_versions(self, version_str): return [clean_simplestring(version_str)] def _parse_file(self, file: Path): - visitor = SetupCallVisotor() + visitor = SetupCallVisitor() with open(str(file), "r", encoding="utf-8") as f: # todo: handle failure in parsing module = cst.parse_module(f.read()) @@ -47,7 +47,7 @@ def _parse_file(self, file: Path): ) -class SetupCallVisotor(cst.CSTVisitor): +class SetupCallVisitor(cst.CSTVisitor): def __init__(self): self.python_requires = None self.install_requires = None diff --git a/src/codemodder/project_analysis/file_parsers/utils.py b/src/codemodder/project_analysis/file_parsers/utils.py index 60e1da33e..4513523e1 100644 --- a/src/codemodder/project_analysis/file_parsers/utils.py +++ b/src/codemodder/project_analysis/file_parsers/utils.py @@ -4,4 +4,4 @@ def clean_simplestring(node: cst.SimpleString | str) -> str: if isinstance(node, str): return node.strip('"') - return node.value.strip('"') + return node.raw_value