Skip to content

Extract method doesn't correctly pass positional-only arguments correctly #567

Closed
@lieryan

Description

@lieryan
Member

Describe the bug

The / syntax in parameter defines a positional-only argument:

def foo(a, /, arg):

Currently, rope doesn't handle variable scope around positional-only argument correctly.

To Reproduce

Steps to reproduce the behavior:

  1. Code before refactoring:
def foo(a, /, arg):
    print(a)
  1. Describe the refactoring you want to do: Extract refactoring

  2. Expected code after refactoring:

def foo(a, /, arg):
    extracted_method(a)

def extracted_method(a):
    print(a)
  1. Describe the error or unexpected result that you are getting
def foo(a, /, arg):
    extracted_method()

def extracted_method():
    print(a)

Editor information (please complete the following information):

  • Project Python version: 3.10
  • Rope Python version: 3.10
  • Rope version: 1.5.1

Activity

added
bugUnexpected or incorrect user-visible behavior
on Dec 2, 2022
added this to the 1.7.0 milestone on Dec 2, 2022
changed the title [-]Extract method passes incorrect keyword-only arguments around positional-only parameter[/-] [+]Extract method doesn't correctly pass keyword-only arguments around positional-only parameter[/+] on Dec 2, 2022
changed the title [-]Extract method doesn't correctly pass keyword-only arguments around positional-only parameter[/-] [+]Extract method doesn't correctly pass positional-only arguments correctly[/+] on Dec 2, 2022
added a commit that references this issue on Dec 14, 2022

Fix #567. Add posonlyargs to list of written arguments when extracting

fcbd54c
modified the milestones: 1.7.0, 1.6.0 on Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnexpected or incorrect user-visible behavior

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @lieryan

        Issue actions

          Extract method doesn't correctly pass positional-only arguments correctly · Issue #567 · python-rope/rope