Skip to content

Conversation

@hauntsaninja
Copy link
Collaborator

The extra condition that excluded LiteralType was introduced in #14827. I see no particular reason to have an instance check at all

I was looking at this because of this comment from Emma #15511 (comment) Previously we errored with "Literal['xy']" object is not iterable which is of course totally false

Now I issue the same error as in the str case, but restrict to cases where the unpack length does not match

Related to #20325

The extra condition that excluded LiteralType was introduced in python#14827
I see no particular reason to have an instance check at all

I was looking at this because of this comment from Emma
python#15511 (comment)
Previously we errored with `"Literal['xy']" object is not iterable`
which is of course totally false

Now I issue the same error as in the str case, but restrict to cases
where the unpack length does not match
@github-actions

This comment has been minimized.

@hauntsaninja hauntsaninja marked this pull request as draft December 2, 2025 02:59
@hauntsaninja hauntsaninja marked this pull request as ready for review December 2, 2025 03:03
@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

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

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/blocks/core.py:1204: error: R? object is not iterable  [misc]
- src/prefect/blocks/core.py:1261: error: R? object is not iterable  [misc]
- src/prefect/blocks/core.py:1264: error: R? object is not iterable  [misc]
+ src/prefect/blocks/core.py:1204: error: R? has no attribute "__iter__" (not iterable)  [attr-defined]
+ src/prefect/blocks/core.py:1261: error: R? has no attribute "__iter__" (not iterable)  [attr-defined]
+ src/prefect/blocks/core.py:1264: error: R? has no attribute "__iter__" (not iterable)  [attr-defined]
- src/prefect/server/database/query_components.py:170: error: R? object is not iterable  [misc]
+ src/prefect/server/database/query_components.py:170: error: R? has no attribute "__iter__" (not iterable)  [attr-defined]
- src/prefect/server/database/query_components.py:182: error: Cannot determine type of "scheduled_flow_runs"  [has-type]
- src/prefect/server/database/query_components.py:190: error: Cannot determine type of "scheduled_flow_runs"  [has-type]
- src/prefect/server/database/query_components.py:190: error: Cannot determine type of "join_criteria"  [has-type]
- src/prefect/server/database/query_components.py:196: error: Cannot determine type of "scheduled_flow_runs"  [has-type]
- src/prefect/server/database/query_components.py:197: error: Cannot determine type of "scheduled_flow_runs"  [has-type]

porcupine (https://github.com/Akuli/porcupine)
+ porcupine/plugins/directory_tree.py:414: error: Unsupported operand types for + ("int" and "str")  [operator]
+ porcupine/plugins/directory_tree.py:414: note: Right operand is of type "int | str"
+ porcupine/plugins/directory_tree.py:415: error: Unsupported operand types for + ("int" and "str")  [operator]
+ porcupine/plugins/directory_tree.py:415: note: Right operand is of type "int | str"

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