Skip to content

Conversation

@kunnaall04
Copy link

(Explain how this PR changes mypy.)

Kunal Sali and others added 7 commits January 20, 2026 00:28
…us operator detection

- Add missing imports: ConditionalExpr, GeneratorExpr, ListComprehension, SetComprehension, DictionaryComprehension, SliceExpr
- Handle ConditionalExpr (ternary operator) to check cond, if_expr, and else_expr
- Handle SliceExpr to check begin_index, end_index, and stride
- Handle GeneratorExpr and comprehensions (ListComprehension, SetComprehension, DictionaryComprehension)
- Ensures comprehensive detection of assignment expressions (walrus operators) in all nested expression contexts
- Fixes CI failures related to incomplete expression type handling
- Fix DictExpr iteration: iterate over items directly (items is list[tuple[Expression | None, Expression]])
- Fix IndexExpr: remove unnecessary None check since index is always Expression, not Optional
- Addresses mypy self-check failures:
  - DictExpr has no attribute 'values'
  - Unreachable code after return statement
  - Type mismatch in zip iteration
@kunnaall04 kunnaall04 force-pushed the fix-callable-any-narrowing branch from 81ce477 to a0eb6ad Compare February 7, 2026 19:30
@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2026

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

starlette (https://github.com/encode/starlette)
+ starlette/_utils.py:42: error: "Callable[..., Any]" not callable  [operator]

sympy (https://github.com/sympy/sympy)
+ sympy/printing/smtlib.py:464: error: "Callable[..., Any]" has no attribute "__args__"  [attr-defined]

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/groupby/ops.py:200: error: "Callable[..., Any]" has no attribute "__signatures__"  [attr-defined]

aiohttp-devtools (https://github.com/aio-libs/aiohttp-devtools)
+ aiohttp_devtools/runserver/config.py:210: error: Item "Application" of "Callable[..., Any] | Application" has no attribute "__defaults__"  [union-attr]
+ aiohttp_devtools/runserver/config.py:210: note: Left operand is of type "int | Any"
+ aiohttp_devtools/runserver/config.py:215: error: Unused "type: ignore" comment  [unused-ignore]

pandera (https://github.com/pandera-dev/pandera)
+ pandera/typing/pandas.py:186: error: Incompatible types in assignment (expression has type "function", variable has type "Callable[..., Any]")  [assignment]

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant