Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

type inference failure on custom iterable class unpacking #20435

Open
randolf-scholz/mypy
#6
Labels
bugmypy got something wrong
@danmur97

Description

@danmur97

Bug Report

When unpacking acustom iterable class to build another iterable, mypy does not correctly infer the resulting type i.e.CustomIter[CustomIter[_T]] is equal toCustomIter[_T] (that should not be true)

To Reproduce

proof-of-concept

Expected Behavior

Nested iterable unpacking type checking works fine when using standard types (e.g. list[list[_T]]) however custom iterable classes should have the same behavior.

Actual Behavior

As presented on the playground proof-of-concept the issue is that mypydoes not mark the failure on this incorrectly defined function:

def case_1(iter_of_iter: CustomIter[list[int]]) -> CustomIter[int]:    # Mypy fails    #    # Mypy does not flag that the return type does not match.    # It is `CustomIter[list[int]]` instead of `CustomIter[int]`    return CustomIter.new(*iter_of_iter)

Your Environment

  • details available on the playground example.

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp