Skip to content

Improve bound method callable return diagnostic#4081

Open
goutamadwant wants to merge 1 commit into
facebook:mainfrom
goutamadwant:fix-classvar-callable-return-diagnostic
Open

Improve bound method callable return diagnostic#4081
goutamadwant wants to merge 1 commit into
facebook:mainfrom
goutamadwant:fix-classvar-callable-return-diagnostic

Conversation

@goutamadwant

Copy link
Copy Markdown
Contributor

Summary

Improves the diagnostic when a callable class attribute is treated as a bound method after instance access. For the ClassVar[Callable[[], int]] property-return case from #3810, Pyrefly still reports the invalid return, but now the detail explains that _factory is being bound as a method even though its callable signature has no self parameter.

Fixes #3810

Test Plan

  • cargo test -p pyrefly test_classvar_callable_return_bound_method_error -- --nocapture
  • cargo test -p pyrefly test_callable_boundmethod_subset -- --nocapture
  • cargo test -p pyrefly test::attributes:: -- --nocapture
  • cargo test -p pyrefly test::callable::
  • cargo fmt --all -- --check
  • cargo test -p pyrefly was attempted; the full package run hit test::shape_dsl::* per-test timeouts after 6202 passed; 19 failed. A representative shape DSL test, test::shape_dsl::test_shape_dsl_arg_count_too_few, passes when run directly.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confusing error message: Returned type () -> int is not assignable to declared return type () -> int

1 participant