Skip to content

Conversation

@InSyncWithFoo
Copy link
Contributor

Summary

Resolves #513.

Callable types are now considered to be disjoint from nominal instance types where:

  • The class is @final, and
  • Its __call__ either does not exist or is not assignable to (...) -> Unknown.

Test Plan

Markdown tests.

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

github-actions bot commented May 29, 2025

mypy_primer results

No ecosystem changes detected ✅

@InSyncWithFoo
Copy link
Contributor Author

I came across this issue while working on #18294:

graphql-core (https://github.com/graphql-python/graphql-core)
- error[invalid-argument-type] src/graphql/execution/execute.py:1901:9: Argument to function `experimental_execute_incrementally` is incorrect: Expected `((Any, /) -> bool) | None`, found `bool | None | (def assume_not_awaitable(_value: Any) -> bool)`
+ error[invalid-argument-type] src/graphql/execution/execute.py:1901:9: Argument to function `experimental_execute_incrementally` is incorrect: Expected `((Any, /) -> bool) | None`, found `(bool & ((...) -> object)) | None | (def assume_not_awaitable(_value: Any) -> bool)`

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.

Thank you!

@carljm carljm enabled auto-merge (squash) May 29, 2025 23:24
@carljm carljm merged commit 9b0dfc5 into astral-sh:main May 29, 2025
32 checks passed
@InSyncWithFoo InSyncWithFoo deleted the ty-intersection-callable-final branch May 30, 2025 02:03
dcreager added a commit that referenced this pull request May 30, 2025
* main:
  [ty] support callability of bound/constrained typevars (#18389)
  [ty] Minor tweaks to "list all members" docs and tests (#18388)
  [ty] Fix broken property tests for disjointness (#18384)
  [ty] List available members for a given type (#18251)
  [`airflow`] Add unsafe fix for module moved cases (`AIR312`) (#18363)
  Add a `SourceFile` to `OldDiagnostic` (#18356)
  Update salsa past generational id change (#18362)
  [`airflow`] Add unsafe fix for module moved cases (`AIR311`) (#18366)
  [`airflow`] Add unsafe fix for module moved cases (`AIR301`) (#18367)
  [ty] Improve tests for `site-packages` discovery (#18374)
  [ty] _typeshed.Self is not a special form (#18377)
  [ty] Callable types are disjoint from non-callable `@final` nominal instance types (#18368)
  [ty] Add diagnosis for function with no return statement but with return type annotation (#18359)
  [`airflow`] Add unsafe fix module moved cases (`AIR302`) (#18093)
  Rename `ruff_linter::Diagnostic` to `OldDiagnostic` (#18355)
  [`refurb`] Add coverage of `set` and `frozenset` calls (`FURB171`) (#18035)
@dhruvmanila dhruvmanila added the bug Something isn't working label Jun 2, 2025
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.

Intersection between @final class and Callable is not reduced to Never

4 participants