RemoveArgument - refactoring produces syntax errors at callsite if original code contains comments

未关闭
#690 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 7 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python
领域
devtools

调研方向

Reproduce with rope 1.8.0 by removing the logger argument from save_list_of_dataframes_to_xlsx using RemoveArgument, on a call site that has comments between the arguments as in the issue. Compare the output with the expected output in the issue, which keeps each argument and comment on its own line without the logger argument. Done means the call site stays valid Python with its comments in place.

由索引模型根据 Issue 内容生成。

描述

bug

Describe the bug
When removing an argument from a function, the code at the callsite goes into syntax errors if comments exist at the callsite.

To Reproduce
Steps to reproduce the behavior:

  1. Code before refactoring:
    at the callsite:
save_list_of_dataframes_to_xlsx(list_of_dfs,
                                        folder_path=folder_path,
                                        # filename=self.__class__.__name__,  # old (GIANNAM, 2021-10-21, 19:02)
                                        filename=self.xlsx_out_filename,     # new (GIANNAM, 2021-10-22, 10:19)
                                        sheetname_list=sheetname_list,
                                        logger=self.logger_obj.logger)
  1. Describe the refactoring you want to do

remove Argument - logger (on the function definition, not the callsite)

  1. Expected code after refactoring:
save_list_of_dataframes_to_xlsx(list_of_dfs,
                                        folder_path=folder_path,
                                        # filename=self.__class__.__name__,  # old (GIANNAM, 2021-10-21, 19:02)
                                        filename=self.xlsx_out_filename,     # new (GIANNAM, 2021-10-22, 10:19)
                                        sheetname_list=sheetname_list)
  1. Describe the error or unexpected result that you are getting

The code gets compressed into one line with the comments mixed in.

 save_list_of_dataframes_to_xlsx(list_of_dfs,folder_path, # filename=self.__class__.__name__,  # old (GIANNAM, 2021-10-21, 19=self.xlsx_out_filename, # new (GIANNAM, 2021-10-22, 10=sheetname_list)

Editor information (please complete the following information):

  • Project Python version: 3.7.9
  • Rope Python version: 3.7.9
  • Rope version: 1.8.0
  • Text editor/IDE and version: (no editor, using rope as a library)

Additional context
still fantastic library thanks a lot

主要语言
Python
星标
2.2k
派生
197
平均合并
2 天 13 小时
30 天内合并 PR
5

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

python-rope/rope 的其他 Issue

查看 python-rope/rope 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。