Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[red-knot] Fix bug where union of two iterable types was not recognised as iterable #13992

Merged
merged 3 commits into from
Oct 30, 2024

Conversation

AlexWaygood
Copy link
Member

Fixes #13990. My favourite kind of bugfix: more accuracy for less code!

@AlexWaygood AlexWaygood enabled auto-merge (squash) October 30, 2024 11:51
@AlexWaygood AlexWaygood merged commit 42c7069 into main Oct 30, 2024
19 checks passed
@AlexWaygood AlexWaygood deleted the alex/iter-bug branch October 30, 2024 11:54
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check encountered linter errors. (no lint changes; 1 project error)

pandas-dev/pandas (+0 -0 violations, +0 -0 fixes)


pypa/setuptools (error)

ruff failed
  Cause: Failed to parse /home/runner/work/ruff/ruff/checkouts/pypa:setuptools/ruff.toml
  Cause: TOML parse error at line 1, column 11
  |
1 | include = "pyproject.toml"
  |           ^^^^^^^^^^^^^^^^
invalid type: string "pyproject.toml", expected a sequence

Linter (preview)

ℹ️ ecosystem check encountered linter errors. (no lint changes; 1 project error)

pypa/setuptools (error)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

ruff failed
  Cause: Failed to parse /home/runner/work/ruff/ruff/checkouts/pypa:setuptools/ruff.toml
  Cause: TOML parse error at line 1, column 11
  |
1 | include = "pyproject.toml"
  |           ^^^^^^^^^^^^^^^^
invalid type: string "pyproject.toml", expected a sequence

@AlexWaygood AlexWaygood added the red-knot Multi-file analysis & type inference label Oct 30, 2024
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to also have a test where one type is iterable and the other is not. E.g. iterator over str | int.

This should work as expected today but I think the fix you pushed now would have regressed the diagnostic precision when our errors distinguish between a non-iterable and an iterator missing the __next__ method.

@AlexWaygood
Copy link
Member Author

This should work as expected today

in fact, it does not... great catch!

@carljm
Copy link
Contributor

carljm commented Oct 30, 2024

in fact, it does not

Should we capture this in an issue?

@AlexWaygood
Copy link
Member Author

in fact, it does not

Should we capture this in an issue?

I am working on a fix. But if I do not succeed in putting up the fix, I will write up an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[red-knot] Union incorrectly reported as not iterable
3 participants