Fix false positive bad-instantiation for dataclass implementing protocol with __dataclass_fields__#2492
Closed
fangyi-zhou wants to merge 2 commits intofacebook:mainfrom
Closed
Conversation
… protocol When a dataclass implements a protocol that declares `__dataclass_fields__` as a ClassVar, pyrefly incorrectly reports a bad-instantiation error because the synthesized `__dataclass_fields__` field is not visible to the abstract member check. Mark this as a known bug. Fixes: facebook#2477 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…col with __dataclass_fields__ When a @DataClass implements a Protocol that declares `__dataclass_fields__` as a ClassVar, pyrefly incorrectly reported a bad-instantiation error. The root cause was in `calculate_abstract_members`: it used `get_non_synthesized_class_member_and_defining_class` to look up fields, which skips synthesized fields. This meant the synthesized `__dataclass_fields__` from @DataClass was invisible, and the MRO traversal found the protocol's uninitialized ClassVar declaration instead — marking the field as abstract. Fix: Before the existing non-synthesized check, use `get_class_member` (which includes synthesized fields) to see if the class already has a concrete implementation. If it does (i.e., the field is not abstract and not an uninitialized ClassVar), the requirement is already satisfied and we skip it. Fixes: facebook#2477 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
__dataclass_fields__
Contributor
Author
|
I used Claude code to fix the regression and the fix looks reasonable. |
|
Diff from mypy_primer, showing the effect of this PR on open source code: jinja (https://github.com/pallets/jinja)
- ERROR tests/test_async.py:647:31-62: Cannot set item in `dict[str, ((obj: Sized, /) -> int) | ((s: Any, /) -> Markup) | ((s: Any, /) -> str) | ((env: Environment, s: str, length: int = 255, killwords: bool = False, end: str = '...', leeway: int | None = None) -> str) | ((environment: Environment, obj: Any, name: str) -> Undefined | Any) | ((environment: Environment, s: str, width: int = 79, break_long_words: bool = True, wrapstring: str | None = None, break_on_hyphens: bool = True) -> str) | ((eval_ctx: EvalContext, d: Mapping[str, Any], autospace: bool = True) -> str) | ((eval_ctx: EvalContext, s: str, old: str, new: str, count: int | None = None) -> str) | ((eval_ctx: EvalContext, value: str, trim_url_limit: int | None = None, nofollow: bool = False, target: str | None = None, rel: str | None = None, extra_schemes: Iterable[str] | None = None) -> str) | ((eval_ctx: EvalContext, value: Any, indent: int | None = None) -> Markup) | ((s: str) -> int) | ((s: str) -> str) | ((s: str, width: int | str = 4, first: bool = False, blank: bool = False) -> str) | ((value: HasHTML | str) -> Markup) | ((value: HasHTML | str) -> str) | ((value: Iterable[tuple[str, Any]] | Mapping[str, Any] | str) -> str) | ((value: float | int | str, binary: bool = False) -> str) | ((value: float, precision: int = 0, method: Literal['ceil', 'common', 'floor'] = 'common') -> float) | ((value: str) -> Markup) | ((value: str, chars: str | None = None) -> str) | ((value: str, width: int = 80) -> str) | ((value: str, *args: Any, **kwargs: Any) -> str) | ((value: Any) -> str) | ((value: Any, default: float = ...) -> float) | ((value: Any, default: int = 0, base: int = 10) -> int) | ((*args: Unknown, **kwargs: Unknown) -> Unknown) | Overload[(context: Context, value: AsyncIterable[Any] | Iterable[Any], name: str, *args: Any, **kwargs: Any) -> Iterable[Any], (context: Context, value: AsyncIterable[Any] | Iterable[Any], *, attribute: str = ..., default: Any | None = None) -> Iterable[Any]] | Overload[(value: str) -> str, [V](value: Iterable[Unknown]) -> Iterable[Unknown]] | [K, V](value: Mapping[Unknown, Unknown], case_sensitive: bool = False, by: Literal['key', 'value'] = 'key', reverse: bool = False) -> list[tuple[Unknown, Unknown]] | [K, V](value: Mapping[Unknown, Unknown] | Undefined) -> Iterator[tuple[Unknown, Unknown]] | [V](value: Iterable[Unknown], linecount: int, fill_with: Unknown | None = None) -> Iterator[list[Unknown]] | [V](value: Unknown, default_value: Unknown = ..., boolean: bool = False) -> Unknown | [V](environment: Environment, seq: Reversible[Unknown]) -> Undefined | Unknown | [V](environment: Environment, value: Iterable[Unknown], case_sensitive: bool = False, attribute: int | str | None = None) -> Undefined | Unknown | [V](context: Context, seq: Sequence[Unknown]) -> Undefined | Unknown | [V](environment: Environment, value: Iterable[Unknown], reverse: bool = False, case_sensitive: bool = False, attribute: int | str | None = None) -> list[Unknown] | [_T](x: SupportsAbs[Unknown], /) -> Unknown]` [unsupported-operation]
+ ERROR tests/test_async.py:647:31-62: Cannot set item in `dict[str, ((obj: Sized, /) -> int) | ((s: Any, /) -> Markup) | ((s: Any, /) -> str) | ((env: Environment, s: str, length: int = 255, killwords: bool = False, end: str = '...', leeway: int | None = None) -> str) | ((environment: Environment, obj: Any, name: str) -> Undefined | Any) | ((environment: Environment, s: str, width: int = 79, break_long_words: bool = True, wrapstring: str | None = None, break_on_hyphens: bool = True) -> str) | ((eval_ctx: EvalContext, d: Mapping[str, Any], autospace: bool = True) -> str) | ((eval_ctx: EvalContext, s: str, old: str, new: str, count: int | None = None) -> str) | ((eval_ctx: EvalContext, value: str, trim_url_limit: int | None = None, nofollow: bool = False, target: str | None = None, rel: str | None = None, extra_schemes: Iterable[str] | None = None) -> str) | ((eval_ctx: EvalContext, value: Any, indent: int | None = None) -> Markup) | ((s: str) -> int) | ((s: str) -> str) | ((s: str, width: int | str = 4, first: bool = False, blank: bool = False) -> str) | ((value: HasHTML | str) -> Markup) | ((value: HasHTML | str) -> str) | ((value: Iterable[tuple[str, Any]] | Mapping[str, Any] | str) -> str) | ((value: float | int | str, binary: bool = False) -> str) | ((value: float, precision: int = 0, method: Literal['ceil', 'common', 'floor'] = 'common') -> float) | ((value: str) -> Markup) | ((value: str, chars: str | None = None) -> str) | ((value: str, width: int = 80) -> str) | ((value: str, *args: Any, **kwargs: Any) -> str) | ((value: Any) -> str) | ((value: Any, default: float = ...) -> float) | ((value: Any, default: int = 0, base: int = 10) -> int) | ((*args: Unknown, **kwargs: Unknown) -> Unknown) | Overload[(context: Context, value: AsyncIterable[Any] | Iterable[Any], name: str, *args: Any, **kwargs: Any) -> Iterable[Any], (context: Context, value: AsyncIterable[Any] | Iterable[Any], *, attribute: str = ..., default: Any | None = None) -> Iterable[Any]] | Overload[(value: str) -> str, [V](value: Iterable[Unknown]) -> Iterable[Unknown]] | [K, V](value: Mapping[Unknown, Unknown] | Undefined) -> Iterator[tuple[Unknown, Unknown]] | [K, V](value: Mapping[Unknown, Unknown], case_sensitive: bool = False, by: Literal['key', 'value'] = 'key', reverse: bool = False) -> list[tuple[Unknown, Unknown]] | [V](environment: Environment, value: Iterable[Unknown], reverse: bool = False, case_sensitive: bool = False, attribute: int | str | None = None) -> list[Unknown] | [V](value: Iterable[Unknown], linecount: int, fill_with: Unknown | None = None) -> Iterator[list[Unknown]] | [V](environment: Environment, value: Iterable[Unknown], case_sensitive: bool = False, attribute: int | str | None = None) -> Undefined | Unknown | [V](value: Unknown, default_value: Unknown = ..., boolean: bool = False) -> Unknown | [V](environment: Environment, seq: Reversible[Unknown]) -> Undefined | Unknown | [V](context: Context, seq: Sequence[Unknown]) -> Undefined | Unknown | [_T](x: SupportsAbs[Unknown], /) -> Unknown]` [unsupported-operation]
- ERROR tests/test_regression.py:87:34-66: Cannot set item in `dict[str, ((obj: Sized, /) -> int) | ((s: Any, /) -> Markup) | ((s: Any, /) -> str) | ((env: Environment, s: str, length: int = 255, killwords: bool = False, end: str = '...', leeway: int | None = None) -> str) | ((environment: Environment, obj: Any, name: str) -> Undefined | Any) | ((environment: Environment, s: str, width: int = 79, break_long_words: bool = True, wrapstring: str | None = None, break_on_hyphens: bool = True) -> str) | ((eval_ctx: EvalContext, d: Mapping[str, Any], autospace: bool = True) -> str) | ((eval_ctx: EvalContext, s: str, old: str, new: str, count: int | None = None) -> str) | ((eval_ctx: EvalContext, value: str, trim_url_limit: int | None = None, nofollow: bool = False, target: str | None = None, rel: str | None = None, extra_schemes: Iterable[str] | None = None) -> str) | ((eval_ctx: EvalContext, value: Any, indent: int | None = None) -> Markup) | ((s: str) -> int) | ((s: str) -> str) | ((s: str, width: int | str = 4, first: bool = False, blank: bool = False) -> str) | ((value: HasHTML | str) -> Markup) | ((value: HasHTML | str) -> str) | ((value: Iterable[tuple[str, Any]] | Mapping[str, Any] | str) -> str) | ((value: float | int | str, binary: bool = False) -> str) | ((value: float, precision: int = 0, method: Literal['ceil', 'common', 'floor'] = 'common') -> float) | ((value: str) -> Markup) | ((value: str, chars: str | None = None) -> str) | ((value: str, width: int = 80) -> str) | ((value: str, *args: Any, **kwargs: Any) -> str) | ((value: Any) -> str) | ((value: Any, default: float = ...) -> float) | ((value: Any, default: int = 0, base: int = 10) -> int) | ((*args: Unknown, **kwargs: Unknown) -> Unknown) | Overload[(context: Context, value: AsyncIterable[Any] | Iterable[Any], name: str, *args: Any, **kwargs: Any) -> Iterable[Any], (context: Context, value: AsyncIterable[Any] | Iterable[Any], *, attribute: str = ..., default: Any | None = None) -> Iterable[Any]] | Overload[(value: str) -> str, [V](value: Iterable[Unknown]) -> Iterable[Unknown]] | [K, V](value: Mapping[Unknown, Unknown], case_sensitive: bool = False, by: Literal['key', 'value'] = 'key', reverse: bool = False) -> list[tuple[Unknown, Unknown]] | [K, V](value: Mapping[Unknown, Unknown] | Undefined) -> Iterator[tuple[Unknown, Unknown]] | [V](value: Iterable[Unknown], linecount: int, fill_with: Unknown | None = None) -> Iterator[list[Unknown]] | [V](value: Unknown, default_value: Unknown = ..., boolean: bool = False) -> Unknown | [V](environment: Environment, seq: Reversible[Unknown]) -> Undefined | Unknown | [V](environment: Environment, value: Iterable[Unknown], case_sensitive: bool = False, attribute: int | str | None = None) -> Undefined | Unknown | [V](context: Context, seq: Sequence[Unknown]) -> Undefined | Unknown | [V](environment: Environment, value: Iterable[Unknown], reverse: bool = False, case_sensitive: bool = False, attribute: int | str | None = None) -> list[Unknown] | [_T](x: SupportsAbs[Unknown], /) -> Unknown]` [unsupported-operation]
+ ERROR tests/test_regression.py:87:34-66: Cannot set item in `dict[str, ((obj: Sized, /) -> int) | ((s: Any, /) -> Markup) | ((s: Any, /) -> str) | ((env: Environment, s: str, length: int = 255, killwords: bool = False, end: str = '...', leeway: int | None = None) -> str) | ((environment: Environment, obj: Any, name: str) -> Undefined | Any) | ((environment: Environment, s: str, width: int = 79, break_long_words: bool = True, wrapstring: str | None = None, break_on_hyphens: bool = True) -> str) | ((eval_ctx: EvalContext, d: Mapping[str, Any], autospace: bool = True) -> str) | ((eval_ctx: EvalContext, s: str, old: str, new: str, count: int | None = None) -> str) | ((eval_ctx: EvalContext, value: str, trim_url_limit: int | None = None, nofollow: bool = False, target: str | None = None, rel: str | None = None, extra_schemes: Iterable[str] | None = None) -> str) | ((eval_ctx: EvalContext, value: Any, indent: int | None = None) -> Markup) | ((s: str) -> int) | ((s: str) -> str) | ((s: str, width: int | str = 4, first: bool = False, blank: bool = False) -> str) | ((value: HasHTML | str) -> Markup) | ((value: HasHTML | str) -> str) | ((value: Iterable[tuple[str, Any]] | Mapping[str, Any] | str) -> str) | ((value: float | int | str, binary: bool = False) -> str) | ((value: float, precision: int = 0, method: Literal['ceil', 'common', 'floor'] = 'common') -> float) | ((value: str) -> Markup) | ((value: str, chars: str | None = None) -> str) | ((value: str, width: int = 80) -> str) | ((value: str, *args: Any, **kwargs: Any) -> str) | ((value: Any) -> str) | ((value: Any, default: float = ...) -> float) | ((value: Any, default: int = 0, base: int = 10) -> int) | ((*args: Unknown, **kwargs: Unknown) -> Unknown) | Overload[(context: Context, value: AsyncIterable[Any] | Iterable[Any], name: str, *args: Any, **kwargs: Any) -> Iterable[Any], (context: Context, value: AsyncIterable[Any] | Iterable[Any], *, attribute: str = ..., default: Any | None = None) -> Iterable[Any]] | Overload[(value: str) -> str, [V](value: Iterable[Unknown]) -> Iterable[Unknown]] | [K, V](value: Mapping[Unknown, Unknown] | Undefined) -> Iterator[tuple[Unknown, Unknown]] | [K, V](value: Mapping[Unknown, Unknown], case_sensitive: bool = False, by: Literal['key', 'value'] = 'key', reverse: bool = False) -> list[tuple[Unknown, Unknown]] | [V](environment: Environment, value: Iterable[Unknown], reverse: bool = False, case_sensitive: bool = False, attribute: int | str | None = None) -> list[Unknown] | [V](value: Iterable[Unknown], linecount: int, fill_with: Unknown | None = None) -> Iterator[list[Unknown]] | [V](environment: Environment, value: Iterable[Unknown], case_sensitive: bool = False, attribute: int | str | None = None) -> Undefined | Unknown | [V](value: Unknown, default_value: Unknown = ..., boolean: bool = False) -> Unknown | [V](environment: Environment, seq: Reversible[Unknown]) -> Undefined | Unknown | [V](context: Context, seq: Sequence[Unknown]) -> Undefined | Unknown | [_T](x: SupportsAbs[Unknown], /) -> Unknown]` [unsupported-operation]
- ERROR tests/test_security.py:182:30-33: Cannot set item in `dict[str, ((obj: Sized, /) -> int) | ((s: Any, /) -> Markup) | ((s: Any, /) -> str) | ((env: Environment, s: str, length: int = 255, killwords: bool = False, end: str = '...', leeway: int | None = None) -> str) | ((environment: Environment, obj: Any, name: str) -> Undefined | Any) | ((environment: Environment, s: str, width: int = 79, break_long_words: bool = True, wrapstring: str | None = None, break_on_hyphens: bool = True) -> str) | ((eval_ctx: EvalContext, d: Mapping[str, Any], autospace: bool = True) -> str) | ((eval_ctx: EvalContext, s: str, old: str, new: str, count: int | None = None) -> str) | ((eval_ctx: EvalContext, value: str, trim_url_limit: int | None = None, nofollow: bool = False, target: str | None = None, rel: str | None = None, extra_schemes: Iterable[str] | None = None) -> str) | ((eval_ctx: EvalContext, value: Any, indent: int | None = None) -> Markup) | ((s: str) -> int) | ((s: str) -> str) | ((s: str, width: int | str = 4, first: bool = False, blank: bool = False) -> str) | ((value: HasHTML | str) -> Markup) | ((value: HasHTML | str) -> str) | ((value: Iterable[tuple[str, Any]] | Mapping[str, Any] | str) -> str) | ((value: float | int | str, binary: bool = False) -> str) | ((value: float, precision: int = 0, method: Literal['ceil', 'common', 'floor'] = 'common') -> float) | ((value: str) -> Markup) | ((value: str, chars: str | None = None) -> str) | ((value: str, width: int = 80) -> str) | ((value: str, *args: Any, **kwargs: Any) -> str) | ((value: Any) -> str) | ((value: Any, default: float = ...) -> float) | ((value: Any, default: int = 0, base: int = 10) -> int) | ((*args: Unknown, **kwargs: Unknown) -> Unknown) | Overload[(context: Context, value: AsyncIterable[Any] | Iterable[Any], name: str, *args: Any, **kwargs: Any) -> Iterable[Any], (context: Context, value: AsyncIterable[Any] | Iterable[Any], *, attribute: str = ..., default: Any | None = None) -> Iterable[Any]] | Overload[(value: str) -> str, [V](value: Iterable[Unknown]) -> Iterable[Unknown]] | [K, V](value: Mapping[Unknown, Unknown], case_sensitive: bool = False, by: Literal['key', 'value'] = 'key', reverse: bool = False) -> list[tuple[Unknown, Unknown]] | [K, V](value: Mapping[Unknown, Unknown] | Undefined) -> Iterator[tuple[Unknown, Unknown]] | [V](value: Iterable[Unknown], linecount: int, fill_with: Unknown | None = None) -> Iterator[list[Unknown]] | [V](value: Unknown, default_value: Unknown = ..., boolean: bool = False) -> Unknown | [V](environment: Environment, seq: Reversible[Unknown]) -> Undefined | Unknown | [V](environment: Environment, value: Iterable[Unknown], case_sensitive: bool = False, attribute: int | str | None = None) -> Undefined | Unknown | [V](context: Context, seq: Sequence[Unknown]) -> Undefined | Unknown | [V](environment: Environment, value: Iterable[Unknown], reverse: bool = False, case_sensitive: bool = False, attribute: int | str | None = None) -> list[Unknown] | [_T](x: SupportsAbs[Unknown], /) -> Unknown]` [unsupported-operation]
+ ERROR tests/test_security.py:182:30-33: Cannot set item in `dict[str, ((obj: Sized, /) -> int) | ((s: Any, /) -> Markup) | ((s: Any, /) -> str) | ((env: Environment, s: str, length: int = 255, killwords: bool = False, end: str = '...', leeway: int | None = None) -> str) | ((environment: Environment, obj: Any, name: str) -> Undefined | Any) | ((environment: Environment, s: str, width: int = 79, break_long_words: bool = True, wrapstring: str | None = None, break_on_hyphens: bool = True) -> str) | ((eval_ctx: EvalContext, d: Mapping[str, Any], autospace: bool = True) -> str) | ((eval_ctx: EvalContext, s: str, old: str, new: str, count: int | None = None) -> str) | ((eval_ctx: EvalContext, value: str, trim_url_limit: int | None = None, nofollow: bool = False, target: str | None = None, rel: str | None = None, extra_schemes: Iterable[str] | None = None) -> str) | ((eval_ctx: EvalContext, value: Any, indent: int | None = None) -> Markup) | ((s: str) -> int) | ((s: str) -> str) | ((s: str, width: int | str = 4, first: bool = False, blank: bool = False) -> str) | ((value: HasHTML | str) -> Markup) | ((value: HasHTML | str) -> str) | ((value: Iterable[tuple[str, Any]] | Mapping[str, Any] | str) -> str) | ((value: float | int | str, binary: bool = False) -> str) | ((value: float, precision: int = 0, method: Literal['ceil', 'common', 'floor'] = 'common') -> float) | ((value: str) -> Markup) | ((value: str, chars: str | None = None) -> str) | ((value: str, width: int = 80) -> str) | ((value: str, *args: Any, **kwargs: Any) -> str) | ((value: Any) -> str) | ((value: Any, default: float = ...) -> float) | ((value: Any, default: int = 0, base: int = 10) -> int) | ((*args: Unknown, **kwargs: Unknown) -> Unknown) | Overload[(context: Context, value: AsyncIterable[Any] | Iterable[Any], name: str, *args: Any, **kwargs: Any) -> Iterable[Any], (context: Context, value: AsyncIterable[Any] | Iterable[Any], *, attribute: str = ..., default: Any | None = None) -> Iterable[Any]] | Overload[(value: str) -> str, [V](value: Iterable[Unknown]) -> Iterable[Unknown]] | [K, V](value: Mapping[Unknown, Unknown] | Undefined) -> Iterator[tuple[Unknown, Unknown]] | [K, V](value: Mapping[Unknown, Unknown], case_sensitive: bool = False, by: Literal['key', 'value'] = 'key', reverse: bool = False) -> list[tuple[Unknown, Unknown]] | [V](environment: Environment, value: Iterable[Unknown], reverse: bool = False, case_sensitive: bool = False, attribute: int | str | None = None) -> list[Unknown] | [V](value: Iterable[Unknown], linecount: int, fill_with: Unknown | None = None) -> Iterator[list[Unknown]] | [V](environment: Environment, value: Iterable[Unknown], case_sensitive: bool = False, attribute: int | str | None = None) -> Undefined | Unknown | [V](value: Unknown, default_value: Unknown = ..., boolean: bool = False) -> Unknown | [V](environment: Environment, seq: Reversible[Unknown]) -> Undefined | Unknown | [V](context: Context, seq: Sequence[Unknown]) -> Undefined | Unknown | [_T](x: SupportsAbs[Unknown], /) -> Unknown]` [unsupported-operation]
jax (https://github.com/google/jax)
- ERROR jax/_src/pallas/mosaic/core.py:346:37-39: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/_src/pallas/mosaic/interpret/interpret_pallas_call.py:1677:47-49: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/_src/pallas/mosaic/pallas_call_registration.py:347:44-46: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/_src/pallas/mosaic/pallas_call_registration.py:433:44-46: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/_src/pallas/mosaic/sc_core.py:206:46-48: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/_src/pallas/mosaic/sc_core.py:310:46-48: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/_src/pallas/mosaic_gpu/core.py:1359:37-39: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/_src/pallas/mosaic_gpu/pallas_call_registration.py:70:41-43: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/_src/pallas/triton/pallas_call_registration.py:78:47-49: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/attention.py:288:43-289:55: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/attention.py:351:43-70: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/attention.py:633:45-635:10: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/attention_mgpu.py:318:43-61: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/attention_mgpu.py:601:43-61: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/attention_mgpu.py:622:41-59: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/attention_mgpu.py:790:43-792:8: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/decode_attention.py:196:41-198:6: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/layer_norm.py:111:43-64: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/layer_norm.py:257:43-64: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/layer_norm.py:289:43-64: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/layer_norm.py:325:43-326:54: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/paged_attention.py:261:43-263:8: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/ragged_dot_mgpu.py:237:43-239:8: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/rms_norm.py:88:43-64: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/rms_norm.py:224:43-64: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/rms_norm.py:256:43-64: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/rms_norm.py:292:43-294:8: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/gpu/softmax.py:83:43-84:45: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/tpu/all_gather.py:139:45-62: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/tpu/flash_attention.py:769:43-776:8: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/tpu/flash_attention.py:1132:45-1139:10: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/tpu/flash_attention.py:1467:45-1474:10: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/tpu/matmul.py:81:43-82:69: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/tpu/megablox/gmm.py:541:43-542:74: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/tpu/megablox/gmm.py:780:43-781:74: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/tpu/paged_attention/paged_attention_kernel.py:651:43-653:8: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/tpu/ragged_paged_attention/kernel.py:888:43-894:8: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/tpu/splash_attention/splash_attention_kernel.py:1158:45-1160:10: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/tpu/splash_attention/splash_attention_kernel.py:1644:45-1646:10: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
- ERROR jax/experimental/pallas/ops/tpu/splash_attention/splash_attention_kernel.py:2210:45-2212:10: Cannot instantiate `CompilerParams` because the following members are abstract: `__dataclass_fields__` [bad-instantiation]
|
|
@yangdanny97 has imported this pull request. If you are a Meta employee, you can view this in D94091926. |
kinto0
approved these changes
Feb 23, 2026
Contributor
kinto0
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
grievejia
approved these changes
Feb 23, 2026
Contributor
grievejia
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
|
@yangdanny97 merged this pull request in efba20b. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bad-instantiationerror when a@dataclassimplements aProtocolthat declares__dataclass_fields__: ClassVar[dict[str, Field[Any]]]__dataclass_fields__as aClassVarfor dataclassescalculate_abstract_membersusedget_non_synthesized_class_member_and_defining_classto look up fields, which skips synthesized fields. The dataclass's synthesized__dataclass_fields__was invisible, so the MRO traversal found the protocol's uninitializedClassVarinstead — flagging it as abstractget_class_member(which includes synthesized fields) to detect concrete implementations. If the class already has a non-abstract, non-uninitialized implementation, the requirement is satisfied and we skip itFixes #2477
Test plan
test_dataclass_protocol_dataclass_fieldsinpyrefly/lib/test/dataclasses.rstest.py🤖 Generated with Claude Code