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

Spurious error when adding two list #15087

Open
Labels
bugmypy got something wrong
@mishamsk

Description

@mishamsk

Bug Report

Mypy reportsUnsupported operand types for + when concatenating two lists, when the second operand is a subtype of the first.

This was previously mentioned inthis comment in#5492

Below is a simple concise example

To Reproduce

classA:passclassB(A):passdeffoo(a:list[A])->None:passl1:list[A]= [A(),B()]l2:list[B]= [B()]l3=l1+l2foo(l2+l1)# OK, no errorfoo(l3)# also OKfoo(l1+l2)# ERROR: Unsupported operand types for + ("List[A]" and "List[B]")  [operator]mypy(error)

gist link

Expected Behavior
No error on the last line

Actual Behavior
Reports spurious error

Your Environment

  • Mypy version used: mypy 1.2.0
  • Mypy command-line flags: None
  • Mypy configuration options frommypy.ini (and other config files): from pyproject.toml
ignore_missing_imports = trueshow_column_numbers = truewarn_redundant_casts = truewarn_unused_ignores = truewarn_unused_configs = truefollow_imports = "normal"plugins = ["pydantic.mypy"]
  • Python version used: 3.10

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