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

Mypy 1.7.0 Tuple unpacking gives errors #16478

Closed
shreyasvinaya opened this issue Nov 13, 2023 · 1 comment
Closed

Mypy 1.7.0 Tuple unpacking gives errors #16478

shreyasvinaya opened this issue Nov 13, 2023 · 1 comment
Labels
bug mypy got something wrong

Comments

@shreyasvinaya
Copy link

Bug Report

Tuple unpacking gives error: Never object is not iterable

To Reproduce

from typing import TypeVar, Union, Tuple, Any, Sequence

T = TypeVar("T")
OneOrMany = Union[T, Sequence[T]]


def create_dataset(inputs: Union[OneOrMany[str], Tuple[Any]], ):
    if isinstance(inputs, tuple):
        if len(inputs) == 1:
            input_files = inputs[0]
            if isinstance(inputs, str):
                input_files = [inputs]
        elif len(inputs) == 2:
            input_files, labels = inputs
        elif len(inputs) == 3:
            input_files, labels, weights = inputs

Expected Behavior

No errors, gave no errors in mypy 1.6.1 release

Actual Behavior

sample.py:14: error: Never object is not iterable  [misc]
sample.py:16: error: Never object is not iterable  [misc]

Your Environment

  • Mypy version used: 1.7.0
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.10.10
@shreyasvinaya shreyasvinaya added the bug mypy got something wrong label Nov 13, 2023
@AlexWaygood
Copy link
Member

AlexWaygood commented Nov 13, 2023

Thanks for the bug report! This was fixed yesterday, in efa5dcb (this issue is a duplicate of #16468).

The fix will be released in either mypy 1.7.1 or mypy 1.8 (follow #16341 for updates on possible patch releases for mypy 1.7)

@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants