Skip to content

[ty] Only consider a type T a subtype of a protocol P if all of P's members are fully bound on T#18466

Merged
AlexWaygood merged 2 commits intomainfrom
alex/proto-subtyping-boundness
Jun 4, 2025
Merged

[ty] Only consider a type T a subtype of a protocol P if all of P's members are fully bound on T#18466
AlexWaygood merged 2 commits intomainfrom
alex/proto-subtyping-boundness

Conversation

@AlexWaygood
Copy link
Member

Summary

Fixes astral-sh/ty#578

Test Plan

mdtests

@AlexWaygood AlexWaygood added the bug Something isn't working label Jun 4, 2025
@AlexWaygood AlexWaygood requested a review from carljm as a code owner June 4, 2025 17:42
@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Jun 4, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jun 4, 2025

mypy_primer results

Changes were detected when running on open source projects
pytest (https://github.com/pytest-dev/pytest)
- warning[possibly-unbound-attribute] src/_pytest/config/__init__.py:1212:48: Attribute `default` on type `Argument` is possibly unbound
- Found 777 diagnostics
+ Found 776 diagnostics

scikit-learn (https://github.com/scikit-learn/scikit-learn)
- warning[possibly-unbound-attribute] sklearn/cluster/tests/test_hierarchical.py:175:16: Attribute `distances_` on type `AgglomerativeClustering` is possibly unbound
- warning[possibly-unbound-attribute] sklearn/model_selection/tests/test_search.py:1567:27: Attribute `refit_time_` on type `GridSearchCV | RandomizedSearchCV` is possibly unbound
- warning[possibly-unbound-attribute] sklearn/model_selection/tests/test_search.py:1568:16: Attribute `refit_time_` on type `GridSearchCV | RandomizedSearchCV` is possibly unbound
- Found 2562 diagnostics
+ Found 2559 diagnostics

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.

Nice!

Co-authored-by: Carl Meyer <carl@astral.sh>
@AlexWaygood AlexWaygood enabled auto-merge (squash) June 4, 2025 19:36
@AlexWaygood AlexWaygood merged commit 5a8cdab into main Jun 4, 2025
32 checks passed
@AlexWaygood AlexWaygood deleted the alex/proto-subtyping-boundness branch June 4, 2025 19:39
carljm added a commit to mtshiba/ruff that referenced this pull request Jun 4, 2025
* main:
  [ty] Only consider a type `T` a subtype of a protocol `P` if all of `P`'s members are fully bound on `T` (astral-sh#18466)
  [ty] Exclude members starting with `_abc_` from a protocol interface (astral-sh#18467)
  [ty] Add subdiagnostic suggestion to `unresolved-reference` diagnostic when variable exists on `self` (astral-sh#18444)
  [ty] IDE: only provide declarations and bindings as completions (astral-sh#18456)
  [ty] ty_ide: Hotfix for `expression_scope_id` panics (astral-sh#18455)
  [ty] Improve docs for Class{Literal,Type}::instance_member (astral-sh#18454)
  [ty] Add meta-type tests for legavy TypeVars (astral-sh#18453)
  update to salsa that doesn't panic silently on cycles (astral-sh#18450)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

T & <protocol with members 'x'> should not simplify to T if T.x is possibly unbound

2 participants