Skip to content

fix Pandas locindexer for dataframes inspected as unknown #1678#4214

Draft
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:1678
Draft

fix Pandas locindexer for dataframes inspected as unknown #1678#4214
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:1678

Conversation

@asukaminato0721

@asukaminato0721 asukaminato0721 commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1678

Preserve lambdas for contextual overload inference, narrow wide union hints to callable candidates, prevent unresolved generic return hints from prematurely satisfying bounded overloads.

Test Plan

add test

@github-actions

Copy link
Copy Markdown

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

cki-lib (https://gitlab.com/cki-project/cki-lib)
+ ERROR cki_lib/misc.py:536:41-59: `+` is not supported between `Literal['-']` and `bytes` [unsupported-operation]

mitmproxy (https://github.com/mitmproxy/mitmproxy)
+ ERROR mitmproxy/utils/strutils.py:103:54-78: `+` is not supported between `bytes` and `Literal['\'']` [unsupported-operation]
+ ERROR mitmproxy/utils/strutils.py:107:23-84: `+` is not supported between `bytes` and `str` [unsupported-operation]
+ ERROR mitmproxy/utils/strutils.py:107:73-83: Invalid key for dict, got `bytes` [bad-index]

dulwich (https://github.com/dulwich/dulwich)
- ERROR dulwich/diff_tree.py:395:61-397:6: `defaultdict[Unknown, list[None]]` is not assignable to `dict[bytes, list[TreeChange | None]]` [bad-assignment]

rotki (https://github.com/rotki/rotki)
+ ERROR rotkehlchen/accounting/structures/processed_event.py:158:41-56: Argument `Match[bytes]` is not assignable to parameter `matched_address` with type `Match[str]` in function `ProcessedAccountingEvent._maybe_add_label_with_address` [bad-argument-type]
- ERROR rotkehlchen/mcp/registry.py:48:18-51:6: No matching overload found for function `sorted` called with arguments: (list[(...) -> Any], key=(tool: Unknown) -> Any | None) [no-matching-overload]

steam.py (https://github.com/Gobot1234/steam.py)
- ERROR steam/chat.py:261:28-267:14: No matching overload found for function `steam.reaction.MessageReaction.__init__` called with arguments: (ConnectionState, Self@ChatMessage, Emoticon | None, Sticker | None, user=ClanMember | GroupMember | PartialMember) [no-matching-overload]
+ ERROR steam/chat.py:261:28-267:14: No matching overload found for function `steam.reaction.MessageReaction.__init__` called with arguments: (ConnectionState, Self@ChatMessage, Unknown, Unknown, user=ClanMember | GroupMember | PartialMember) [no-matching-overload]

jax (https://github.com/google/jax)
+ ERROR jax/experimental/jax2tf/tests/tf_test_util.py:238:50-63: Object of class `object` has no attribute `skip_tf_run` [missing-attribute]
+ ERROR jax/experimental/jax2tf/tests/tf_test_util.py:249:54-71: Object of class `object` has no attribute `expect_tf_error` [missing-attribute]
+ ERROR jax/experimental/jax2tf/tests/tf_test_util.py:269:54-71: Object of class `object` has no attribute `skip_comparison` [missing-attribute]
+ ERROR jax/experimental/jax2tf/tests/tf_test_util.py:275:52-97: Object of class `object` has no attribute `get_max_tolerance_limitation` [missing-attribute]
+ ERROR jax/experimental/jax2tf/tests/tf_test_util.py:283:56-71: Object of class `object` has no attribute `custom_assert` [missing-attribute]
+ ERROR jax/experimental/jax2tf/tests/tf_test_util.py:293:11-45: Object of class `object` has no attribute `custom_assert` [missing-attribute]

spark (https://github.com/apache/spark)
+ ERROR python/pyspark/pandas/tests/diff_frames_ops/test_groupby_apply.py:47:51-56: Object of class `Iterable` has no attribute `min` [missing-attribute]
+ ERROR python/pyspark/pandas/tests/diff_frames_ops/test_groupby_apply.py:55:58-63: Object of class `Iterable` has no attribute `min` [missing-attribute]
+ ERROR python/pyspark/pandas/tests/diff_frames_ops/test_groupby_apply.py:59:58-63: Object of class `Iterable` has no attribute `min` [missing-attribute]
+ ERROR python/pyspark/pandas/tests/groupby/test_apply_func.py:294:54-69: Cannot index into `Iterable[Any]` [bad-index]
+ ERROR python/pyspark/pandas/tests/groupby/test_apply_func.py:317:54-69: Cannot index into `Iterable[Any]` [bad-index]
+ ERROR python/pyspark/pandas/tests/series/test_series.py:511:32-39: Object of class `NAType` has no attribute `upper` [missing-attribute]
+ ERROR python/pyspark/pandas/tests/test_categorical.py:318:47-56: Cannot index into `Iterable[Any]` [bad-index]
+ ERROR python/pyspark/pandas/tests/test_categorical.py:326:47-51: Object of class `Iterable` has no attribute `b` [missing-attribute]
+ ERROR python/pyspark/sql/conversion.py:1987:38-48: Cannot index into `NAType` [bad-index]
+ ERROR python/pyspark/sql/conversion.py:1987:50-63: Cannot index into `NAType` [bad-index]
+ ERROR python/pyspark/sql/conversion.py:1992:45-53: Cannot index into `NAType` [bad-index]
+ ERROR python/pyspark/sql/conversion.py:1992:55-64: Cannot index into `NAType` [bad-index]
+ ERROR python/pyspark/sql/conversion.py:1997:44-52: Cannot index into `NAType` [bad-index]
+ ERROR python/pyspark/sql/conversion.py:1997:54-63: Cannot index into `NAType` [bad-index]
+ ERROR python/pyspark/streaming/dstream.py:167:43-69: Object of class `datetime` has no attribute `mapPartitionsWithIndex` [missing-attribute]
+ ERROR python/pyspark/streaming/dstream.py:215:43-58: Object of class `datetime` has no attribute `partitionBy` [missing-attribute]
+ ERROR python/pyspark/streaming/dstream.py:339:43-57: Object of class `datetime` has no attribute `groupByKey` [missing-attribute]
+ ERROR python/pyspark/streaming/dstream.py:469:43-58: Object of class `datetime` has no attribute `repartition` [missing-attribute]
+ ERROR python/pyspark/streaming/dstream.py:490:48-55: Object of class `datetime` has no attribute `union` [missing-attribute]
+ ERROR python/pyspark/streaming/dstream.py:506:26-35: Object of class `datetime` has no attribute `cogroup` [missing-attribute]
+ ERROR python/pyspark/streaming/dstream.py:524:48-54: Object of class `datetime` has no attribute `join` [missing-attribute]
+ ERROR python/pyspark/streaming/dstream.py:540:48-63: Object of class `datetime` has no attribute `leftOuterJoin` [missing-attribute]
+ ERROR python/pyspark/streaming/dstream.py:556:48-64: Object of class `datetime` has no attribute `rightOuterJoin` [missing-attribute]
+ ERROR python/pyspark/streaming/dstream.py:572:48-63: Object of class `datetime` has no attribute `fullOuterJoin` [missing-attribute]

prefect (https://github.com/PrefectHQ/prefect)
- ERROR src/prefect/cli/artifact.py:96:45-63: Object of class `Artifact` has no attribute `latest_id` [missing-attribute]
+ ERROR src/prefect/cli/artifact.py:93:31-63: No matching overload found for function `sorted` called with arguments: (list[Artifact] | list[ArtifactCollection], key=(x: Unknown) -> Unknown) [no-matching-overload]
+ ERROR src/prefect/cli/flow_run.py:265:31-81: No matching overload found for function `sorted` called with arguments: (list[FlowRun], key=(d: Unknown) -> Unknown, reverse=Literal[True]) [no-matching-overload]
- ERROR src/prefect/cli/flow_run.py:268:17-45: Object of class `NoneType` has no attribute `state_details` [missing-attribute]
- ERROR src/prefect/cli/flow_run.py:269:20-47: Object of class `NoneType` has no attribute `is_scheduled` [missing-attribute]
- ERROR src/prefect/cli/flow_run.py:270:22-46: Object of class `NoneType` has no attribute `timestamp` [missing-attribute]
- ERROR src/prefect/cli/flow_run.py:276:21-40: Object of class `NoneType` has no attribute `type` [missing-attribute]
+ ERROR src/prefect/server/services/task_run_recorder.py:225:39-69: Object of class `NoneType` has no attribute `timestamp` [missing-attribute]

materialize (https://github.com/MaterializeInc/materialize)
+ ERROR test/doc-examples/mzcompose.py:83:77-80: Argument `Literal['/']` is not assignable to parameter `bytes` with type `Buffer | None` in function `bytes.lstrip` [bad-argument-type]

freqtrade (https://github.com/freqtrade/freqtrade)
+ ERROR freqtrade/data/btanalysis/trade_parallelism.py:124:51-78: Cannot index into `int` [bad-index]
+ ERROR freqtrade/data/btanalysis/trade_parallelism.py:124:51-78: Cannot index into `str` [bad-index]
+ ERROR freqtrade/plugins/pairlist/PercentChangePairList.py:233:32-237:10: No matching overload found for function `sorted` called with arguments: (list[SymbolWithPercentage], reverse=bool, key=(t: Unknown) -> Unknown) [no-matching-overload]

pwndbg (https://github.com/pwndbg/pwndbg)
+ ERROR pwndbg/aglib/disasm/aarch64.py:331:75-86: Expected 0 positional arguments, got 2 [bad-argument-count]
+ ERROR pwndbg/aglib/disasm/aarch64.py:535:17-23: Expected 0 positional arguments, got 3 [bad-argument-count]
+ ERROR pwndbg/aglib/disasm/arm.py:267:75-86: Expected 0 positional arguments, got 2 [bad-argument-count]
+ ERROR pwndbg/aglib/disasm/arm.py:435:17-23: Expected 0 positional arguments, got 3 [bad-argument-count]
+ ERROR pwndbg/aglib/disasm/assistant.py:345:78-89: Expected 0 positional arguments, got 3 [bad-argument-count]
+ ERROR pwndbg/aglib/disasm/assistant.py:380:21-32: Expected 0 positional arguments, got 3 [bad-argument-count]
+ ERROR pwndbg/aglib/disasm/assistant.py:392:66-77: Expected 0 positional arguments, got 2 [bad-argument-count]
+ ERROR pwndbg/aglib/disasm/mips.py:233:75-86: Expected 0 positional arguments, got 2 [bad-argument-count]
+ ERROR pwndbg/aglib/disasm/riscv.py:199:75-86: Expected 0 positional arguments, got 2 [bad-argument-count]
+ ERROR pwndbg/aglib/disasm/sparc.py:103:80-83: Expected 0 positional arguments, got 1 [bad-argument-count]
+ ERROR pwndbg/aglib/disasm/x86.py:153:75-86: Expected 0 positional arguments, got 2 [bad-argument-count]
+ ERROR pwndbg/enhance.py:174:16-25: Returned type `object` is not assignable to declared return type `str` [bad-return]
+ ERROR pwndbg/enhance.py:176:62-74: No matching overload found for function `str.join` called with arguments: (tuple[object, ...]) [no-matching-overload]

apprise (https://github.com/caronc/apprise)
+ ERROR apprise/asset.py:411:46-55: Invalid key for dict, got `bytes` [bad-index]
+ ERROR apprise/asset.py:443:46-55: Invalid key for dict, got `bytes` [bad-index]
+ ERROR apprise/plugins/aprs.py:611:40-49: Invalid key for dict, got `bytes` [bad-index]
+ ERROR apprise/plugins/custom_xml.py:390:49-58: Invalid key for dict, got `bytes` [bad-index]
+ ERROR apprise/plugins/matrix/base.py:701:53-62: Invalid key for dict, got `bytes` [bad-index]
+ ERROR apprise/plugins/matrix/base.py:706:53-62: Invalid key for dict, got `bytes` [bad-index]
+ ERROR apprise/plugins/ryver.py:205:51-60: Invalid key for dict, got `bytes` [bad-index]
+ ERROR apprise/plugins/ryver.py:209:51-60: Invalid key for dict, got `bytes` [bad-index]
+ ERROR apprise/plugins/slack.py:1044:55-64: Invalid key for dict, got `bytes` [bad-index]
+ ERROR apprise/plugins/slack.py:1093:51-60: Invalid key for dict, got `bytes` [bad-index]
+ ERROR apprise/utils/templates.py:85:43-66: Cannot index into `dict[str, Unknown]` [bad-index]

ibis (https://github.com/ibis-project/ibis)
+ ERROR ibis/backends/conftest.py:268:66-68: Missing argument `backend` [missing-argument]

aiohttp (https://github.com/aio-libs/aiohttp)
+ ERROR aiohttp/helpers.py:413:39-56: `+` is not supported between `Literal['\\']` and `bytes` [unsupported-operation]
+ ERROR aiohttp/helpers.py:781:61-79: No matching overload found for function `re.Pattern.sub` called with arguments: (Literal['\\1'], bytes) [no-matching-overload]

strawberry (https://github.com/strawberry-graphql/strawberry)
+ ERROR strawberry/federation/schema.py:415:55-82: Generic attribute `__strawberry_definition__` of class `WithStrawberryDefinition` is not visible on the class
+ Object of class `StrawberryType` has no attribute `__strawberry_definition__` [missing-attribute]

zulip (https://github.com/zulip/zulip)
+ ERROR zerver/lib/export.py:3209:18-84: No matching overload found for function `sorted` called with arguments: (dict_values[int, dict[str, bool | int | str | None]], key=(export_dict: Unknown) -> Unknown) [no-matching-overload]
+ ERROR zerver/lib/topic.py:266:42-54: Unary `-` is not supported on `str` [unsupported-operation]
+ ERROR zerver/lib/topic_link_util.py:33:41-73: No matching overload found for function `dict.get` called with arguments: (bytes, bytes) [no-matching-overload]

hydpy (https://github.com/hydpy-dev/hydpy)
+ ERROR hydpy/core/seriestools.py:316:72-80: Argument `Categorical | ExtensionArray | ndarray[tuple[int]]` is not assignable to parameter with type `ndarray[tuple[Any, ...], dtype[float64]]` [bad-argument-type]

mypy (https://github.com/python/mypy)
+ ERROR mypy/strconv.py:382:52-69: `+` is not supported between `Literal['\\']` and `bytes` [unsupported-operation]

meson (https://github.com/mesonbuild/meson)
+ ERROR docs/refman/loaderbase.py:130:39-96: `VarArgs | None` is not assignable to upper bound `ArgBase | list[PosArg]` of type variable `_T` [bad-specialization]
+ ERROR mesonbuild/dependencies/cuda.py:127:75-79: Argument `str | None` is not assignable to parameter `s` with type `str` in function `mesonbuild.utils.universal.Version.__init__` [bad-argument-type]

werkzeug (https://github.com/pallets/werkzeug)
+ ERROR tests/test_exceptions.py:142:11-145:6: No matching overload found for function `sorted` called with arguments: (Generator[type[HTTPException]], key=(e: Unknown) -> Unknown) [no-matching-overload]
+ ERROR tests/test_exceptions.py:162:11-165:6: No matching overload found for function `sorted` called with arguments: (Generator[type[HTTPException]], key=(e: Unknown) -> Unknown) [no-matching-overload]
+ ERROR src/werkzeug/http.py:1437:41-50: Cannot index into `dict[bytes, bytes]` [bad-index]

core (https://github.com/home-assistant/core)
- ERROR homeassistant/components/freebox/entity.py:105:16-26: Returning implicit Any from function declared to return "int | None" [no-any-return-implicit]
+ ERROR homeassistant/util/__init__.py:106:56-76: `+` is not supported between `bytes` and `Literal['_']` [unsupported-operation]
+ ERROR homeassistant/util/__init__.py:109:59-79: `+` is not supported between `Literal['_']` and `bytes` [unsupported-operation]

paasta (https://github.com/yelp/paasta)
+ ERROR paasta_tools/contrib/render_template.py:111:37-113:14: No matching overload found for function `os._Environ.get` called with arguments: (bytes, bytes) [no-matching-overload]
+ ERROR paasta_tools/contrib/render_template.py:112:36-40: Argument `Literal['$(']` is not assignable to parameter `old` with type `Buffer` in function `bytes.replace` [bad-argument-type]
+ ERROR paasta_tools/contrib/render_template.py:112:42-44: Argument `Literal['']` is not assignable to parameter `new` with type `Buffer` in function `bytes.replace` [bad-argument-type]
+ ERROR paasta_tools/contrib/render_template.py:112:54-57: Argument `Literal[')']` is not assignable to parameter `old` with type `Buffer` in function `bytes.replace` [bad-argument-type]
+ ERROR paasta_tools/contrib/render_template.py:112:59-61: Argument `Literal['']` is not assignable to parameter `new` with type `Buffer` in function `bytes.replace` [bad-argument-type]

spack (https://github.com/spack/spack)
+ ERROR lib/spack/spack/repo_migrate.py:150:57-67: Cannot index into `dict[str, str]` [bad-index]
+ ERROR lib/spack/spack/user_environment.py:79:69-79: Cannot index into `dict[str, Unknown]` [bad-index]

optuna (https://github.com/optuna/optuna)
+ ERROR tutorial/20_recipes/002_multi_objective.py:148:68-79: `None` is not subscriptable [unsupported-operation]
+ ERROR optuna/samplers/nsgaii/_elite_population_selection_strategy.py:85:39-50: `None` is not subscriptable [unsupported-operation]

kopf (https://github.com/nolar/kopf)
+ ERROR kopf/_core/engines/admission.py:481:43-60: Object of class `bytes` has no attribute `encode` [missing-attribute]

@asukaminato0721
asukaminato0721 marked this pull request as draft July 20, 2026 15:53
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.

Pandas locindexer for dataframes inspected as unknown

1 participant