ruff/crates/ty_python_semantic/src
David Peter 8dad58de37
[ty] Support dataclass-transform field_specifiers (#20888)
## Summary

Add support for the `field_specifiers` parameter on
`dataclass_transform` decorator calls.

closes https://github.com/astral-sh/ty/issues/1068

## Conformance test results

All true positives ✔️ 

## Ecosystem analysis

* `trio`: this is the kind of change that I would expect from this PR.
The code makes use of a dataclass `Outcome` with a `_unwrapped: bool =
attr.ib(default=False, eq=False, init=False)` field that is excluded
from the `__init__` signature, so we now see a bunch of
constructor-call-related errors going away.
* `home-assistant/core`: They have a `domain: str = attr.ib(init=False,
repr=False)` field and then use
  ```py
    @domain.default
    def _domain_default(self) -> str:
        # …
  ```
This accesses the `default` attribute on `dataclasses.Field[…]` with a
type of `default: _T | Literal[_MISSING_TYPE.MISSING]`, so we get those
"Object of type `_MISSING_TYPE` is not callable" errors. I don't really
understand how that is supposed to work. Even if `_MISSING_TYPE` would
be absent from that union, what does this try to call? pyright also
issues an error and it doesn't seem to work at runtime? So this looks
like a true positive?
* `attrs`: Similar here. There are some new diagnostics on code that
tries to access `.validator` on a field. This *does* work at runtime,
but I'm not sure how that is supposed to type-check (without a [custom
plugin](2c6c395935/mypy/plugins/attrs.py (L575-L602))).
pyright errors on this as well.
* A handful of new false positives because we don't support `alias` yet

## Test Plan

Updated tests.
2025-10-16 20:49:11 +02:00
..
module_resolver [ty] Fix panic 'missing root' when handling completion request (#20917) 2025-10-16 16:23:02 +02:00
semantic_index [ty] Add version hint for failed stdlib attribute accesses (#20909) 2025-10-16 14:07:33 +00:00
types [ty] Support dataclass-transform field_specifiers (#20888) 2025-10-16 20:49:11 +02:00
util [ty] Avoid overcounting shared memory usage (#19773) 2025-08-06 15:32:02 -04:00
ast_node_ref.rs [ty] Implement the legacy PEP-484 convention for indicating positional-only parameters (#20248) 2025-09-05 17:56:06 +01:00
db.rs [ty] Limit shown import paths to at most 5 unless ty runs with -v (#20912) 2025-10-16 13:18:09 +02:00
dunder_all.rs [ty] Integrate type context for bidirectional inference (#20337) 2025-09-11 15:19:12 -04:00
lib.rs [ty] Move class_member to member module (#20837) 2025-10-13 10:58:37 +02:00
lint.rs [ty] Add LSP debug information command (#20379) 2025-09-20 11:15:13 +00:00
list.rs Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
module_name.rs [ty] Export some stuff from ty_python_semantic 2025-09-17 13:59:28 -04:00
node_key.rs [ty] Implement the legacy PEP-484 convention for indicating positional-only parameters (#20248) 2025-09-05 17:56:06 +01:00
place.rs [ty] refactor Place (#20871) 2025-10-15 20:19:19 +02:00
program.rs [ty] Track heap usage of salsa structs (#19790) 2025-08-12 13:28:44 +02:00
pull_types.rs Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
python_platform.rs [ty] Track heap usage of salsa structs (#19790) 2025-08-12 13:28:44 +02:00
rank.rs [ty] Garbage-collect reachability constraints (#19414) 2025-07-21 14:16:27 -04:00
semantic_index.rs [ty] Implement the legacy PEP-484 convention for indicating positional-only parameters (#20248) 2025-09-05 17:56:06 +01:00
semantic_model.rs [ty] Do not re-export ide_support attributes from types (#20769) 2025-10-08 17:45:28 +02:00
site_packages.rs [ty] improve base conda distinction from child conda (#20675) 2025-10-03 13:56:06 +00:00
suppression.rs [ty] Document when a rule was added (#20859) 2025-10-14 14:33:48 +02:00
types.rs [ty] Support dataclass-transform field_specifiers (#20888) 2025-10-16 20:49:11 +02:00
unpack.rs [ty] Track heap usage of salsa structs (#19790) 2025-08-12 13:28:44 +02:00