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

Unexpected "incompatible type" error when chaining bytes(filter()) #12247

Open
Labels
bugmypy got something wrongtopic-type-contextType context / bidirectional inference
@ion201

Description

@ion201

Bug Report

Mypy reports a strange type error when callingbytes(filter(...)) like below.

Write the following contents to a file and run mypy:

f = filter(lambda ch: chr(ch), b"hello")bytes(f)bytes(filter(lambda ch: chr(ch), b"hello"))

Mypy reports an error on line 4 but not on lines 1/2, despite the two sections being functionally identical. The expected result is that there should be no errors in this code example.

> mypy /tmp/test.py/tmp/test.py:4: error: Argument 1 to "chr" has incompatible type "SupportsIndex"; expected "int"Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: mypy 0.931
  • Mypy command-line flags: none
  • Mypy configuration options frommypy.ini (and other config files): none
  • Python version used: python 3.10.2
  • Operating system and version: Arch linux and windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-type-contextType context / bidirectional inference

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp