Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dots between module names in from .. import x statement #559

Closed
lieryan opened this issue Nov 30, 2022 · 0 comments · Fixed by #560
Closed

Dots between module names in from .. import x statement #559

lieryan opened this issue Nov 30, 2022 · 0 comments · Fixed by #560
Assignees
Labels
bug Unexpected or incorrect user-visible behavior
Milestone

Comments

@lieryan
Copy link
Member

lieryan commented Nov 30, 2022

Describe the bug

Context: found during discussion of #538

You can add spaces between the dots of import statement, this is valid Python code:

from xml . etree import cElementTree
from . . . pkg . mod import something

But because ast normalises the module name when parsing, node.module == "xml.etree" the current sorted_children would require there being no whitespaces between the module names and dots; so rope currently would error out on above code.

To Reproduce
Steps to reproduce the behavior:

  1. Code before refactoring:
from xml . etree import cElementTree
from . . . pkg . mod import something
  1. Use one of the refactoring that uses patchedast, like extract code

  2. Refactoring should be successful instead of currently producing error like

pylsp: error: pylsp-rope: Token <..> at (1, 4) cannot be matched

Editor information (please complete the following information):

  • Project Python version: 3.10
  • Rope Python version: 3.10
  • Rope version: 1.5.1
@lieryan lieryan added the bug Unexpected or incorrect user-visible behavior label Nov 30, 2022
@lieryan lieryan self-assigned this Nov 30, 2022
lieryan added a commit that referenced this issue Nov 30, 2022
…-whitespace

Fix #559 Whitespace around import statements
@lieryan lieryan added this to the 1.6.0 milestone Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or incorrect user-visible behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant