Skip to content

fix false bad-return for a generator function with Iterator[X] | T return annotation #4825 - #4827

Open
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:4825
Open

fix false bad-return for a generator function with Iterator[X] | T return annotation #4825#4827
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:4825

Conversation

@asukaminato0721

Copy link
Copy Markdown
Collaborator

Summary

Fixes #4825

Iterator and Iterable annotations now allow generator return values, while explicit Generator return types remain checked.

Test Plan

add test

@meta-cla meta-cla Bot added the cla signed label Sep 5, 2026
@github-actions github-actions Bot added the size/s label Sep 5, 2026
@meta-codesync

meta-codesync Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D118959974. (Because this pull request was imported automatically, there will not be any future comments.)

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

Diff from mypy_primer, showing the effect of this PR on open source code:

============================================================
SUMMARY
============================================================
Total: +0 new errors, -2 fixed errors
By preset: +0/-1 (default), +0/-1 (strict)

Projects with changes (2):
  spark: +0 -1
  beartype: +0 -1
============================================================

FULL DIFF DETAILS
------------------------------------------------------------

spark (https://github.com/apache/spark)
- ERROR python/pyspark/sql/tests/arrow/test_arrow_udtf.py:1046:28-36: Returned type `Iterator[Unknown]` is not assignable to declared return type `None` [bad-return]

beartype (https://github.com/beartype/beartype)
- ERROR beartype/_util/func/utilfuncframe.py:1233:17-30: Returning implicit Any from function declared to return "None" [no-any-return-implicit]

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.

false bad-return for a generator function with Iterator[X] | T return annotation

1 participant