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

Aberta
#690 3 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 7 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
35/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Estagnada
Stack de tecnologia
python
Domínio
devtools

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
Python
Estrelas
2.2k
Forks
197
Merge médio
2d 13h
PRs com merge (30d)
5

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de python-rope/rope

Todas as issues de python-rope/rope

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.