Skip to content

fix(stubgen): extract unpack assignments#4151

Open
tobyh-canva wants to merge 1 commit into
facebook:mainfrom
tobyh-canva:stubgen-handle-extract-unpack-assignments
Open

fix(stubgen): extract unpack assignments#4151
tobyh-canva wants to merge 1 commit into
facebook:mainfrom
tobyh-canva:stubgen-handle-extract-unpack-assignments

Conversation

@tobyh-canva

Copy link
Copy Markdown
Contributor

Context

Stubgen currently skips unpack assignments, for example:

A, B = 1, 2

doesn't emit anything in stubs.

It should emit something like:

from typing import Literal

A: Literal[1]
B: Literal[2]

Here's an example in the wild where unpack assignments are used to create public ClassVar constants: WordNetCorpusReader from nltk

Changes

  • Handle unpack assignments in Stubgen's assignment extraction machinery.

Test Plan

  • Added new stubgen snapshot test describing the desired behaviour

@github-actions

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant