Skip to content

Allow string unpacking again. #13823

Open
@JulienPalard

Description

@JulienPalard

String unpacking has been disallowed in #6406, where some comments ask for it to be allowed again. I'm opening an issue to track this better than comments in a closed issue.

Bug Report

I think mypy should allow string unpacking, as it's normal Python semantic.

To Reproduce

QUOTE_PAIRS = [
    "''",
    '""',
    "<>",
    "()",
    "[]",
    "{}",
]

for opening, closing in QUOTE_PAIRS:
    print(opening, closing)

Expected Behavior

I expected this to pass.

Actual Behavior

$ mypy pairs.py 
pairs.py:10: error: Unpacking a string is disallowed
pairs.py:11: error: Cannot determine type of "opening"
pairs.py:11: error: Cannot determine type of "closing"
Found 3 errors in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: mypy 0.971 (compiled: yes)
  • Mypy command-line flags: ø
  • Mypy configuration options from mypy.ini (and other config files): ø
  • Python version used: irrelevant, but reproduced in 3.9, 3.10, 3.11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions