Skip to content

ValueError: not enough values to unpack (expected 2, got 1) in break_up_import #326

@gabe-sherman

Description

@gabe-sherman

The following call to fix_code fails with a ValueError: not enough values to unpack (expected 2, got 1) message. This occurs at line 533 in autoflake.py. The carriage return (\r) seems to be a necessary part of the input in order to trigger this.

import autoflake

s = '''
from t import (
\r  a,
    b,
)
from t import (
    a,
    b,
)
'''

autoflake.fix_code(s)

Setup Info

Version: 2.31
Commit: b87ff10

Trace Report

Traceback (most recent call last):
  File "rep.py", line 14, in <module>
    autoflake.fix_code(s)
  File "lib/python3.10/site-packages/autoflake.py", line 924, in fix_code
    "".join(
  File "lib/python3.10/site-packages/autoflake.py", line 622, in filter_code
    result = filter_unused_import(
  File "lib/python3.10/site-packages/autoflake.py", line 697, in filter_unused_import
    return break_up_import(line)
  File "lib/python3.10/site-packages/autoflake.py", line 533, in break_up_import
    (indentation, imports) = re.split(
ValueError: not enough values to unpack (expected 2, got 1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions