Skip to content

Comments

[red-knot] visibility_constraint analysis for match cases#17077

Merged
AlexWaygood merged 12 commits intoastral-sh:mainfrom
ericmarkmartin:match-case-visibility
Apr 3, 2025
Merged

[red-knot] visibility_constraint analysis for match cases#17077
AlexWaygood merged 12 commits intoastral-sh:mainfrom
ericmarkmartin:match-case-visibility

Conversation

@ericmarkmartin
Copy link
Contributor

@ericmarkmartin ericmarkmartin commented Mar 31, 2025

Summary

Add visibility constraint analysis for pattern predicate kinds Singleton, Or, and Class.

Test Plan

update conditional/match.md

@github-actions
Copy link
Contributor

github-actions bot commented Mar 31, 2025

mypy_primer results

No ecosystem changes detected ✅

@ericmarkmartin ericmarkmartin force-pushed the match-case-visibility branch from 2a7a2ae to a7f0153 Compare March 31, 2025 03:45
@ericmarkmartin ericmarkmartin changed the title Match case visibility [red-knot] visibility_constraint analysis for match cases Mar 31, 2025
@MichaReiser MichaReiser added the ty Multi-file analysis & type inference label Mar 31, 2025
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Nice! Not a full review, but I spotted something in one branch that I suspect could apply to some of the other branches, so I'll hold off on making further comments until that's addressed.

Overall this looks great, though -- thank you!

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.

This is excellent work, thank you!!

@ericmarkmartin ericmarkmartin force-pushed the match-case-visibility branch from a678d17 to 716708e Compare April 3, 2025 03:05
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thank you, this is great!

@AlexWaygood AlexWaygood force-pushed the match-case-visibility branch from 1061ec5 to 7d1d143 Compare April 3, 2025 11:11
@AlexWaygood AlexWaygood enabled auto-merge (squash) April 3, 2025 11:13
@AlexWaygood AlexWaygood merged commit e50fc04 into astral-sh:main Apr 3, 2025
20 checks passed
dcreager added a commit that referenced this pull request Apr 3, 2025
* origin/main:
  [red-knot] Fix more [redundant-cast] false positives (#17170)
  [red-knot] Three-argument type-calls take 'str' as the first argument (#17168)
  Control flow: `return` and `raise` (#17121)
  Bump 0.11.3 (#17173)
  [red-knot] Improve `Debug` implementation for `semantic_index::SymbolTable` (#17172)
  [red-knot] Fix `str(…)` calls (#17163)
  [red-knot] visibility_constraint analysis for match cases (#17077)
  [red-knot] Fix playground crashes when diagnostics are stale (#17165)
dcreager added a commit that referenced this pull request Apr 3, 2025
* origin/main: (82 commits)
  [red-knot] Fix more [redundant-cast] false positives (#17170)
  [red-knot] Three-argument type-calls take 'str' as the first argument (#17168)
  Control flow: `return` and `raise` (#17121)
  Bump 0.11.3 (#17173)
  [red-knot] Improve `Debug` implementation for `semantic_index::SymbolTable` (#17172)
  [red-knot] Fix `str(…)` calls (#17163)
  [red-knot] visibility_constraint analysis for match cases (#17077)
  [red-knot] Fix playground crashes when diagnostics are stale (#17165)
  [red-knot] Callable types are disjoint from literals (#17160)
  [red-knot] Fix inference for `pow` between two literal integers (#17161)
  [red-knot] Add GitHub PR annotations when mdtests fail in CI (#17150)
  [red-knot] Fix equivalence of differently ordered unions that contain `Callable` types (#17145)
  [red-knot] Add initial set of tests for unreachable code (#17159)
  [`airflow`] Move `AIR302` to `AIR301` and `AIR303` to `AIR302` (#17151)
  ruff_db: simplify lifetimes on `DiagnosticDisplay`
  [red-knot] Detect division-by-zero in unions and intersections (#17157)
  [`airflow`] Add autofix infrastructure to `AIR302` name checks (#16965)
  [`flake8-bandit`] Mark `str` and `list[str]` literals as trusted input (`S603`) (#17136)
  [`airflow`] Add autofix for `AIR302` attribute checks (#16977)
  [`airflow`] Extend `AIR302` with additional symbols (#17085)
  ...
maxmynter pushed a commit to maxmynter/ruff that referenced this pull request Apr 3, 2025
…17077)

## Summary

Add visibility constraint analysis for pattern predicate kinds
`Singleton`, `Or`, and `Class`.

## Test Plan

update conditional/match.md
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.

4 participants