GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Crash on the numpy main branch: `AssertionError` in `check_multi_assignment_from_tuple` · Issue #21824 · python/mypy

Crash on the numpy main branch: AssertionError in check_multi_assignment_from_tuple #21824

New issue
Copy link
New issue
Copy link
Closed
#21830
Closed
Crash on the numpy main branch: AssertionError in check_multi_assignment_from_tuple#21824
#21830
Copy link
Labels
crash

Description

@jorenham
jorenham
opened on Aug 9, 2026
Issue body actions

Crash Report

On the current numpy main branch (https://github.com/numpy/numpy/tree/87310db7f2a791b4a4e8503d4111359d85052cd4), mypy crashes when a result of np.unique is assigned to a variable named _ (this name matters).

This currently causes mypy_primer to crash when running in optuna, first observed in numpy/numpy#32231 (comment).

Traceback

Traceback (most recent call last):
  File "mypy/checker.py", line 765, in accept
  File "mypy/nodes.py", line 1909, in accept
  File "mypy/checker.py", line 3367, in visit_assignment_stmt
    self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None)
  File "mypy/checker.py", line 3419, in check_assignment
    self.check_assignment_to_multiple_lvalues(
  File "mypy/checker.py", line 4182, in check_assignment_to_multiple_lvalues
    self.check_multi_assignment(lvalues, rvalue, context, infer_lvalue_type)
  File "mypy/checker.py", line 4260, in check_multi_assignment
    self.check_multi_assignment_from_tuple(
  File "mypy/checker.py", line 4411, in check_multi_assignment_from_tuple
    assert isinstance(reinferred_rvalue_type, TupleType)
AssertionError

Repro

Run mypy --no-incremental --show-traceback t.py on

# t.py
import numpy as np


def f(a: np.ndarray) -> None:
    _, ranks = np.unique(a, return_inverse=True)

with the latest numpy@main installed (e.g. https://github.com/numpy/numpy/tree/87310db7f2a791b4a4e8503d4111359d85052cd4)

Note that with --allow-redefinition this doesn't crash. It also doesn't crash when renaming _ to something else.

This isn't an issue with the latest 2.5.2 NumPy release, where np.unique counts 32 overloads instead of the current 74 overloads (each of which serve a purpose and are handwritten by me, in case you were wondering).

Your Environment

  • Mypy version used: 2.3.0 (compiled: yes), also 2.4.0+dev.5bb72b7
  • Mypy command-line flags: see above
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.12, 3.14 (doesn't matter)
  • Operating system and version: linux, but I don't think this matters
Reacted by Brian Schubert

Activity

  1. jorenham
    added
    crash
    on Aug 9, 2026
  2. jorenham commented on Aug 9, 2026

    @jorenham
    jorenham
    on Aug 9, 2026
    ContributorAuthor
    More actions

    It seems to be happening since numpy/numpy#32215

  3. brianschubert commented on Aug 9, 2026

    @brianschubert
    brianschubert
    on Aug 9, 2026
    Collaborator
    More actions

    Reproduced with numpy master (v2.6.0.dev0+git20260808.87310db) and mypy master. At the offending assert reinferred_rvalue_type is an Instance of tuple[Any, ...]

    Reacted by Joren Hammudoglu
  4. correctmost commented on Aug 10, 2026

    @correctmost
    correctmost
    on Aug 10, 2026
    More actions

    #19920 has a similar backtrace

  5. JukkaL
    closed this as completedin #21830on Aug 10, 2026
  6. pull
    added a commit that references this issue on Aug 10, 2026

    Fix crash when unpacking return value from overload (python#21830)

    This issue will close once commit 0221c80 is merged into the 'master' branch.
    0221c80
  7. hauntsaninja
    added a commit that references this issue on Aug 15, 2026

    Fix crash when unpacking return value from overload (#21830)

    This issue will close once commit 6dfa06d is merged into the 'master' branch.
    6dfa06d
  8. ilevkivskyi
    added a parent issue on Sep 19, 2026
    • Issues related to numpy #18343
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    crash

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.