Skip to content

[ty] Recognize __dataclass_transform__ to support SQLModel#23070

Merged
sharkdp merged 3 commits intoastral-sh:mainfrom
rayzeller:fix/dataclass-transform-dunder-name
Feb 5, 2026
Merged

[ty] Recognize __dataclass_transform__ to support SQLModel#23070
sharkdp merged 3 commits intoastral-sh:mainfrom
rayzeller:fix/dataclass-transform-dunder-name

Conversation

@rayzeller
Copy link
Contributor

@rayzeller rayzeller commented Feb 4, 2026

Summary

For backwards compatibility with pre-3.11 Python, ty now recognizes any function named __dataclass_transform__ as equivalent to typing.dataclass_transform, regardless of which module it is defined in.

This matches pyright's behavior and enables proper type checking for libraries like SQLModel that use this pattern to support older Python versions. The name matches the attribute set at runtime by the decorator.

Reference: https://typing.python.org/en/latest/spec/dataclasses.html#runtime-behavior

closes astral-sh/ty#1329

Test plan

  • Added test for __dataclass_transform__ recognition in dataclass_transform.md
  • Updated sqlmodel.md external tests to verify the fix works with real SQLModel patterns

🤖 Generated with Claude Code

@rayzeller rayzeller force-pushed the fix/dataclass-transform-dunder-name branch from 39e2de7 to 1bb0c47 Compare February 4, 2026 14:21
For backwards compatibility with pre-3.11 Python, ty now recognizes
any function named `__dataclass_transform__` as equivalent to
`typing.dataclass_transform`, regardless of which module it is
defined in. This matches pyright's behavior and enables proper
type checking for libraries like SQLModel that use this pattern.

See: microsoft/pyright#5402

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Contributor

@sharkdp sharkdp 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! This is not a standardized feature, but was apparently previously part of the spec (microsoft/pyright#1782 (comment)). I see no harm in supporting it.

Only a few minor comments.

Comment on lines 1592 to 1595
// Special case: `__dataclass_transform__` is recognized as `DataclassTransform`
// regardless of module, for backwards compatibility with pre-3.11 libraries
// like SQLModel. The name matches the attribute set at runtime by the decorator.
// See: https://typing.python.org/en/latest/spec/dataclasses.html#runtime-behavior
Copy link
Contributor

Choose a reason for hiding this comment

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

That section does mention __dataclass_transform__, but only the attribute on the dataclass-transformer. Not a special-cased function name. So maybe we should just link to https://github.com/microsoft/pyright/blob/321c1825ab6badb7c8b8ccfd12558910a6d75450/packages/pyright-internal/src/analyzer/decorators.ts#L167-L168 here? And maybe research if mypy has a similar special case.

@sharkdp sharkdp marked this pull request as ready for review February 4, 2026 16:02
@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 4, 2026

Typing conformance results

No changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 4, 2026

mypy_primer results

Changes were detected when running on open source projects
spack (https://github.com/spack/spack)
- lib/spack/spack/vendor/jsonschema/_types.py:169:5: error[too-many-positional-arguments] Too many positional arguments to bound method `__init__`: expected 1, got 2
+ lib/spack/spack/vendor/jsonschema/_types.py:169:5: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 1
- lib/spack/spack/vendor/jsonschema/validators.py:101:5: error[unknown-argument] Argument `type_checkers` does not match any known parameter of bound method `__init__`
+ lib/spack/spack/vendor/jsonschema/validators.py:101:5: error[unknown-argument] Argument `type_checkers` does not match any known parameter
- lib/spack/spack/vendor/jsonschema/validators.py:238:13: error[unknown-argument] Argument `type_checkers` does not match any known parameter of bound method `__init__`
+ lib/spack/spack/vendor/jsonschema/validators.py:238:13: error[unknown-argument] Argument `type_checkers` does not match any known parameter
+ lib/spack/spack/vendor/jsonschema/validators.py:709:17: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 1
+ lib/spack/spack/vendor/jsonschema/validators.py:779:53: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 1
+ lib/spack/spack/vendor/jsonschema/validators.py:814:21: error[too-many-positional-arguments] Too many positional arguments: expected 0, got 1
- Found 4340 diagnostics
+ Found 4343 diagnostics

check-jsonschema (https://github.com/python-jsonschema/check-jsonschema)
- src/check_jsonschema/schema_loader/resolver.py:29:9: error[unknown-argument] Argument `retrieve` does not match any known parameter of bound method `__init__`
- Found 28 diagnostics
+ Found 27 diagnostics

Expression (https://github.com/cognitedata/Expression)
- tests/test_compose.py:21:16: error[invalid-assignment] Object of type `(Never, /) -> Never` is not assignable to `(int, /) -> int`
- Found 201 diagnostics
+ Found 200 diagnostics

setuptools (https://github.com/pypa/setuptools)
+ setuptools/_distutils/command/install.py:719:42: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[Never]`, found `map[str]`
- Found 1138 diagnostics
+ Found 1139 diagnostics

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/input/run_input.py:672:20: error[invalid-return-type] Return type does not match returned value: expected `T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler]`, found `T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler] | Coroutine[Any, Any, T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler]]`
+ src/prefect/input/run_input.py:672:20: error[invalid-return-type] Return type does not match returned value: expected `T@GetAutomaticInputHandler | AutomaticRunInput[T@GetAutomaticInputHandler]`, found `Unknown | Coroutine[Any, Any, Unknown]`

materialize (https://github.com/MaterializeInc/materialize)
- misc/python/materialize/cli/mz_workload_anonymize.py:251:13: error[no-matching-overload] No overload of bound method `join` matches arguments
- Found 535 diagnostics
+ Found 534 diagnostics

sympy (https://github.com/sympy/sympy)
- sympy/algebras/tests/test_quaternion.py:422:33: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/codegen/tests/test_matrix_nodes.py:27:21: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/eigen.py:1202:37: error[unresolved-attribute] Object of type `T2'return@call_highest_priority | T1'return@call_highest_priority` has no attribute `pow`
- sympy/matrices/expressions/tests/test_blockmatrix.py:235:13: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/expressions/tests/test_blockmatrix.py:235:33: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/expressions/tests/test_blockmatrix.py:235:53: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/expressions/tests/test_blockmatrix.py:459:12: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/expressions/tests/test_derivatives.py:551:26: error[unsupported-operator] Operator `+` is not supported between two objects of type `MatrixBase | Expr`
- sympy/matrices/expressions/tests/test_matadd.py:36:12: error[unsupported-operator] Operator `+` is not supported between objects of type `MatrixBase` and `MatrixBase | Expr`
- sympy/matrices/expressions/tests/test_matpow.py:124:47: error[unsupported-operator] Operator `+` is not supported between two objects of type `ImmutableDenseMatrix`
- sympy/matrices/inverse.py:385:11: error[unsupported-operator] Operator `-` is not supported between objects of type `MatrixBase` and `MatrixBase | Expr | Unknown`
- sympy/matrices/inverse.py:393:11: error[unsupported-operator] Operator `+` is not supported between objects of type `MatrixBase` and `MatrixBase | Expr | Unknown`
- sympy/matrices/matrixbase.py:979:18: error[unsupported-operator] Operator `+` is not supported between two objects of type `Self@_eval_wilkinson`
- sympy/matrices/matrixbase.py:2957:16: error[invalid-return-type] Return type does not match returned value: expected `Self@_eval_pow_by_cayley`, found `Self@_eval_pow_by_cayley | T2'return@call_highest_priority | T1'return@call_highest_priority`
- sympy/matrices/matrixbase.py:3256:16: error[invalid-return-type] Return type does not match returned value: expected `MatrixBase`, found `T2'return@call_highest_priority | T1'return@call_highest_priority`
- sympy/matrices/matrixbase.py:3256:29: error[invalid-argument-type] Argument is incorrect: Expected `T2'return@call_highest_priority | T1'return@call_highest_priority`, found `MatrixBase`
- sympy/matrices/matrixbase.py:3310:16: error[unsupported-operator] Operator `+` is not supported between two objects of type `MatrixBase`
- sympy/matrices/matrixbase.py:3314:16: error[invalid-return-type] Return type does not match returned value: expected `Tmat@__sub__`, found `MatrixBase`
- sympy/matrices/matrixbase.py:4386:16: error[unsupported-operator] Operator `+` is not supported between two objects of type `Self@add`
- sympy/matrices/matrixbase.py:4923:16: error[invalid-return-type] Return type does not match returned value: expected `Self@analytic_func`, found `Self@analytic_func | T2'return@call_highest_priority | T1'return@call_highest_priority`
- sympy/matrices/repmatrix.py:321:17: error[unsupported-operator] Operator `-` is not supported between two objects of type `Self@_eval_is_symmetric`
- sympy/matrices/tests/test_commonmatrix.py:1249:31: error[unsupported-operator] Operator `+` is not supported between objects of type `MutableDenseMatrix` and `ImmutableDenseNDimArray`
- sympy/matrices/tests/test_eigen.py:406:20: error[invalid-argument-type] Argument to function `max` is incorrect: Expected `Iterable[Unknown]`, found `MatrixBase | Unknown`
- sympy/matrices/tests/test_immutable.py:105:23: error[unsupported-operator] Operator `+` is not supported between two objects of type `ImmutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:121:12: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:123:32: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:141:12: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:2179:22: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:2207:26: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:2908:21: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:2921:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:2936:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:2937:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:2948:14: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:3471:21: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrices.py:3478:12: warning[possibly-missing-attribute] Attribute `rank` may be missing on object of type `MatrixBase | MatrixExpr | Unknown`
- sympy/matrices/tests/test_matrices.py:3479:12: warning[possibly-missing-attribute] Attribute `rank` may be missing on object of type `MatrixBase | MatrixExpr | Unknown`
- sympy/matrices/tests/test_matrixbase.py:491:12: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:493:32: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:544:12: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:823:31: error[unsupported-operator] Operator `+` is not supported between objects of type `MutableDenseMatrix` and `ImmutableDenseNDimArray`
- sympy/matrices/tests/test_matrixbase.py:876:12: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:878:32: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:900:12: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:2931:22: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:2959:26: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:3610:21: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:3624:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:3639:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:3640:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_matrixbase.py:3652:14: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_reductions.py:377:21: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_reductions.py:384:12: warning[possibly-missing-attribute] Attribute `rank` may be missing on object of type `MatrixBase | MatrixExpr | Unknown`
- sympy/matrices/tests/test_reductions.py:385:12: warning[possibly-missing-attribute] Attribute `rank` may be missing on object of type `MatrixBase | MatrixExpr | Unknown`
- sympy/matrices/tests/test_solvers.py:68:13: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/matrices/tests/test_sparse.py:573:12: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableSparseMatrix`
- sympy/matrices/tests/test_sparse.py:577:52: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableSparseMatrix`
- sympy/matrices/tests/test_sparse.py:593:17: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableSparseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:13:6: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:16:38: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:16:84: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:16:131: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:21:44: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:21:90: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:21:137: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:25:37: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:25:83: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/parsing/autolev/test-examples/ruletest5.py:25:130: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/physics/control/tests/test_lti.py:3733:31: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/physics/control/tests/test_lti.py:3733:38: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/physics/mechanics/lagrange.py:222:23: error[unsupported-operator] Operator `-` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/physics/mechanics/lagrange.py:346:17: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/physics/mechanics/linearize.py:217:28: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/physics/mechanics/linearize.py:229:29: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/physics/mechanics/linearize.py:241:29: error[unsupported-operator] Operator `+` is not supported between two objects of type `Unknown | MutableDenseMatrix`
- sympy/physics/mechanics/tests/test_jointsmethod.py:247:17: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/physics/mechanics/tests/test_jointsmethod.py:249:17: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- sympy/physics/quantum/tests/test_represent.py:89:17: error[unsupported-operator] Operator `+` is not supported between objects of type `MatrixBase | Expr` and `MatrixBase`
- sympy/physics/quantum/tests/test_represent.py:91:24: error[unsupported-operator] Operator `-` is not supported between two objects of type `MatrixBase | Expr`
- sympy/physics/quantum/tests/test_represent.py:93:28: error[unsupported-operator] Operator `+` is not supported between two objects of type `MatrixBase | Expr`
- sympy/physics/vector/functions.py:380:21: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Iterable[Unknown]`, found `MatrixBase | Unknown`
- sympy/solvers/tests/test_numeric.py:137:11: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/solvers/tests/test_solvers.py:722:19: error[unsupported-operator] Operator `-` is not supported between two objects of type `MatrixBase | Expr`
- sympy/solvers/tests/test_solvers.py:723:19: error[unsupported-operator] Operator `-` is not supported between two objects of type `MatrixBase | Expr`
- sympy/solvers/tests/test_solvers.py:724:19: error[unsupported-operator] Operator `-` is not supported between two objects of type `MatrixBase | Expr`
- sympy/solvers/tests/test_solvers.py:724:30: error[unsupported-operator] Operator `-` is not supported between two objects of type `MatrixBase | Expr`
- sympy/stats/tests/test_symbolic_multivariate.py:84:36: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/stats/tests/test_symbolic_multivariate.py:84:84: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/stats/tests/test_symbolic_multivariate.py:85:36: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/tensor/tests/test_tensor.py:1693:19: error[unsupported-operator] Operator `+` is not supported between two objects of type `MutableDenseMatrix`
- sympy/tensor/tests/test_tensor.py:1694:23: error[unsupported-operator] Operator `-` is not supported between two objects of type `MutableDenseMatrix`
- Found 15903 diagnostics
+ Found 15812 diagnostics

No memory usage changes detected ✅

@sharkdp sharkdp self-assigned this Feb 4, 2026
@sharkdp
Copy link
Contributor

sharkdp commented Feb 4, 2026

The test failures seem to indicate that this fix doesn't really work?

@carljm carljm removed their request for review February 4, 2026 18:20
@rayzeller rayzeller force-pushed the fix/dataclass-transform-dunder-name branch from b65e269 to c9a7f22 Compare February 4, 2026 19:43
This changes how we extract parameters from `dataclass_transform()` calls
from positional pattern matching to named parameter lookup. This allows
custom `__dataclass_transform__` functions (like SQLModel's) with different
signatures to work correctly.

The previous code used `if let [6 params]` which silently failed for
functions with fewer parameters. Named lookup with defaults is more robust
and matches how Python interprets the keyword-only parameters.

Also adds a fallback from `field_descriptors` to `field_specifiers` for
SQLModel compatibility.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@rayzeller rayzeller force-pushed the fix/dataclass-transform-dunder-name branch from c9a7f22 to 0bf0818 Compare February 4, 2026 20:21
@rayzeller
Copy link
Contributor Author

The test failures seem to indicate that this fix doesn't really work?

thanks for the review! i think the issue was that the original code used positional pattern matching expecting exactly 6 params, but SQLModel's signature only has 4...so it silently failed to match.

tried to keep this minimal:

  • switched from positional to named parameter lookup so it should handle custom signatures
  • [unchanged] also recognizes __dataclass_transform__ as an alias for dataclass_transform

local tests pass but waiting on CI to confirm. open to more refactoring for code hygiene too, whatever conforms to the long term vision

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 4, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
unsupported-operator 0 79 0
invalid-parameter-default 0 0 7
invalid-argument-type 0 4 1
invalid-return-type 0 4 0
possibly-missing-attribute 0 4 0
too-many-positional-arguments 3 0 1
unknown-argument 0 1 2
invalid-assignment 0 0 1
unresolved-attribute 0 1 0
Total 3 93 12

Full report with detailed diff (timing results)

@ntBre ntBre added the ty Multi-file analysis & type inference label Feb 5, 2026
Copy link
Contributor

@sharkdp sharkdp 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 very much!

if to_bool(frozen_default, false) {
flags |= DataclassTransformerFlags::FROZEN_DEFAULT;
}
// Try both "field_specifiers" (typing spec) and "field_descriptors" (SQLModel)
Copy link
Contributor

Choose a reason for hiding this comment

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

and "field_descriptors" (SQLModel)

oh, that is unfortunate :-|. But I guess it's a small exception. Pyright also has this older name of the parameter hard-coded in their codebase.

@sharkdp sharkdp changed the title [ty] Recognize __dataclass_transform__ as dataclass_transform [ty] Recognize __dataclass_transform__ to support SQLModel Feb 5, 2026
@sharkdp sharkdp enabled auto-merge (squash) February 5, 2026 08:37
@sharkdp sharkdp merged commit 4898ae9 into astral-sh:main Feb 5, 2026
44 checks passed
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.

Ty misses required-field diagnostic for SQLModel (works for BaseModel)

3 participants