Skip to content

Conversation

@mtshiba
Copy link
Contributor

@mtshiba mtshiba commented Mar 19, 2025

Summary

From #16641

The previous PR attempted to fix the errors presented in this PR, but as discussed in the conversation, it was concluded that the approach was undesirable and that further work would be needed to fix the errors with a correct general solution.

In this PR, I instead add the test cases from the previous PR as TODOs, as a starting point for future work.

Test Plan

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Mar 19, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2025

mypy_primer results

No ecosystem changes detected ✅

@AlexWaygood AlexWaygood removed their request for review March 19, 2025 19:38
Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!

Comment on lines +697 to +700
# TODO: This should be `Never`
reveal_type(a) # revealed: Literal[True]
# TODO: This should be `Never`
reveal_type(b) # revealed: Literal[False]
Copy link
Contributor

Choose a reason for hiding this comment

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

These two seem higher priority to follow up on, because we don't just fail to simplify the intersection, we simplify it to a plainly incorrect type.

Comment on lines +50 to +54
# TODO: No errors
# error: [static-assert-error]
static_assert(is_gradual_equivalent_to(Unknown, Unknown | Any))
# error: [static-assert-error]
static_assert(is_gradual_equivalent_to(Unknown, Intersection[Unknown, Any]))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the dynamic type reduction from your previous PR, which would fix these cases, is pretty solid (not overly special-cased) and could be put up as a separate PR?

@carljm carljm enabled auto-merge (squash) March 20, 2025 17:13
@carljm carljm merged commit 23382f5 into astral-sh:main Mar 20, 2025
22 checks passed
dcreager added a commit that referenced this pull request Mar 21, 2025
* main: (26 commits)
  Use the common `OperatorPrecedence` for the parser (#16747)
  [red-knot] Check subtype relation between callable types (#16804)
  [red-knot] Check whether two callable types are equivalent (#16698)
  [red-knot] Ban most `Type::Instance` types in type expressions (#16872)
  Special-case value-expression inference of special form subscriptions (#16877)
  [syntax-errors] Fix star annotation before Python 3.11 (#16878)
  Recognize `SyntaxError:` as an error code for ecosystem checks (#16879)
  [red-knot] add test cases result in false positive errors (#16856)
  Bump 0.11.1 (#16871)
  Allow discovery of venv in VIRTUAL_ENV env variable (#16853)
  Split git pathspecs in change determination onto separate lines (#16869)
  Use the correct base commit for change determination (#16857)
  Separate `BitXorOr` into `BitXor` and `BitOr` precedence (#16844)
  Server: Allow `FixAll` action in presence of version-specific syntax errors (#16848)
  [`refurb`] Fix starred expressions fix (`FURB161`) (#16550)
  [`flake8-executable`] Add pytest and uv run to help message for `shebang-missing-python` (`EXE003`) (#16855)
  Show more precise messages in invalid type expressions (#16850)
  [`flake8-executables`] Allow `uv run` in shebang line for `shebang-missing-python` (`EXE003`) (#16849)
  Add `--exit-non-zero-on-format` (#16009)
  [red-knot] Ban list literals in most contexts in type expressions (#16847)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants