Skip to content

Conversation

@AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Dec 1, 2025
@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 1, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

Comment on lines +1500 to +1508
@dataclass_transform(kw_only_default=True)
def sequence3(cls: type[U]) -> type[U]:
# TODO: should reveal `type[U@sequence3]`
return reveal_type(dataclass(cls)) # revealed: Unknown

@dataclass_transform(kw_only_default=True)
def sequence4(cls: type) -> type:
# TODO: should reveal `type`
return reveal_type(dataclass(cls)) # revealed: Unknown
Copy link
Member Author

@AlexWaygood AlexWaygood Dec 1, 2025

Choose a reason for hiding this comment

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

these Unknowns are just us failing to solve the generic overloads in typeshed's signature for dataclasses.dataclass, I think

@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 1, 2025

mypy_primer results

Changes were detected when running on open source projects
attrs (https://github.com/python-attrs/attrs)
- tests/test_make.py:675:13: error[call-non-callable] Object of type `<decorator produced by dataclass-like function>` is not callable
- tests/test_make.py:2873:17: error[call-non-callable] Object of type `<decorator produced by dataclass-like function>` is not callable
- tests/test_make.py:2876:17: error[call-non-callable] Object of type `<decorator produced by dataclass-like function>` is not callable
- tests/test_slots.py:116:15: error[call-non-callable] Object of type `<decorator produced by dataclass-like function>` is not callable
- tests/test_slots.py:210:15: error[call-non-callable] Object of type `<decorator produced by dataclass-like function>` is not callable
- Found 606 diagnostics
+ Found 601 diagnostics

Expression (https://github.com/cognitedata/Expression)
- expression/core/tagged_union.py:43:15: error[call-non-callable] Object of type `<decorator produced by dataclass-like function>` is not callable
- Found 211 diagnostics
+ Found 210 diagnostics

pandera (https://github.com/pandera-dev/pandera)
- pandera/dtypes.py:116:27: error[call-non-callable] Object of type `<decorator produced by dataclass-like function>` is not callable
- Found 1635 diagnostics
+ Found 1634 diagnostics

strawberry (https://github.com/strawberry-graphql/strawberry)
- strawberry/types/object_type.py:104:12: error[call-non-callable] Object of type `<decorator produced by dataclass-like function>` is not callable
- Found 400 diagnostics
+ Found 399 diagnostics

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
- pandas-stubs/_typing.pyi:1207:16: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- Found 5810 diagnostics
+ Found 5809 diagnostics

No memory usage changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 1, 2025

ecosystem-analyzer results

Lint rule Added Removed Changed
call-non-callable 0 8 0
unused-ignore-comment 2 0 0
unsupported-base 1 0 0
Total 3 8 0

Full report with detailed diff (timing results)

@AlexWaygood AlexWaygood force-pushed the alex/callable-dataclass branch from 0594850 to 8dfa0d0 Compare December 1, 2025 14:52
@AlexWaygood AlexWaygood marked this pull request as ready for review December 1, 2025 14:53
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.

Looks great, thank you!

@AlexWaygood AlexWaygood merged commit c5b8d55 into main Dec 3, 2025
41 checks passed
@AlexWaygood AlexWaygood deleted the alex/callable-dataclass branch December 3, 2025 08:05
dcreager added a commit that referenced this pull request Dec 3, 2025
* origin/main:
  [ty] Improve `@override`, `@final` and Liskov checks in cases where there are multiple reachable definitions (#21767)
  [ty] Extend `invalid-explicit-override` to also cover properties decorated with `@override` that do not override anything (#21756)
  [ty] Enable LRU collection for parsed module (#21749)
  [ty] Support typevar-specialized dynamic types in generic type aliases (#21730)
  Add token based `parenthesized_ranges` implementation (#21738)
  [ty] Default-specialization of generic type aliases (#21765)
  [ty] Suppress false positives when `dataclasses.dataclass(...)(cls)` is called imperatively (#21729)
  [syntax-error] Default type parameter followed by non-default type parameter (#21657)
  new module for parsing ranged suppressions (#21441)
  [ty] `type[T]` is assignable to an inferable typevar (#21766)
  Fix syntax error false positives for `await` outside functions (#21763)
  [ty] Improve diagnostics for unsupported comparison operations (#21737)
  Move `Token`, `TokenKind` and `Tokens` to `ruff-python-ast` (#21760)
  [ty] Don't confuse multiple occurrences of `typing.Self` when binding bound methods (#21754)
  Use our org-wide Renovate preset (#21759)
  Delete `my-script.py` (#21751)
  [ty] Move `all_members`, and related types/routines, out of `ide_support.rs` (#21695)
dcreager added a commit that referenced this pull request Dec 3, 2025
* origin/main:
  [ty] Reachability constraints: minor documentation fixes (#21774)
  [ty] Fix non-determinism in `ConstraintSet.specialize_constrained` (#21744)
  [ty] Improve `@override`, `@final` and Liskov checks in cases where there are multiple reachable definitions (#21767)
  [ty] Extend `invalid-explicit-override` to also cover properties decorated with `@override` that do not override anything (#21756)
  [ty] Enable LRU collection for parsed module (#21749)
  [ty] Support typevar-specialized dynamic types in generic type aliases (#21730)
  Add token based `parenthesized_ranges` implementation (#21738)
  [ty] Default-specialization of generic type aliases (#21765)
  [ty] Suppress false positives when `dataclasses.dataclass(...)(cls)` is called imperatively (#21729)
  [syntax-error] Default type parameter followed by non-default type parameter (#21657)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ecosystem-analyzer ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calling dataclasses.dataclass imperatively (as opposed to as a decorator) produces errors

3 participants