ruff/crates
David Peter 1f4f8d9950
[ty] Fix flow of associated member states during star imports (#21776)
## Summary

Star-imports can not just affect the state of symbols that they pull in,
they can also affect the state of members that are associated with those
symbols. For example, if `obj.attr` was previously narrowed from `int |
None` to `int`, and a star-import now overwrites `obj`, then the
narrowing on `obj.attr` should be "reset".

This PR keeps track of the state of associated members during star
imports and properly models the flow of their corresponding state
through the control flow structure that we artificially create for
star-imports.

See [this
comment](https://github.com/astral-sh/ty/issues/1355#issuecomment-3607125005)
for an explanation why this caused ty to see certain `asyncio` symbols
as not being accessible on Python 3.14.

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

## Ecosystem impact

```diff
async-utils (https://github.com/mikeshardmind/async-utils)
- src/async_utils/bg_loop.py:115:31: error[invalid-argument-type] Argument to bound method `set_task_factory` is incorrect: Expected `_TaskFactory | None`, found `def eager_task_factory[_T_co](loop: AbstractEventLoop | None, coro: Coroutine[Any, Any, _T_co@eager_task_factory], *, name: str | None = None, context: Context | None = None) -> Task[_T_co@eager_task_factory]`
- Found 30 diagnostics
+ Found 29 diagnostics

mitmproxy (https://github.com/mitmproxy/mitmproxy)
+ mitmproxy/utils/asyncio_utils.py:96:60: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- test/conftest.py:37:31: error[invalid-argument-type] Argument to bound method `set_task_factory` is incorrect: Expected `_TaskFactory | None`, found `def eager_task_factory[_T_co](loop: AbstractEventLoop | None, coro: Coroutine[Any, Any, _T_co@eager_task_factory], *, name: str | None = None, context: Context | None = None) -> Task[_T_co@eager_task_factory]`
```

All of these seem to be correct, they give us a different type for
`asyncio` symbols that are now imported from different
`sys.version_info` branches (where we previously failed to recognize
some of these as statically true/false).

```diff
dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/contrib/internal/asyncio/patch.py:39:12: error[invalid-argument-type] Argument to function `unwrap` is incorrect: Expected `WrappedFunction`, found `def create_task[_T](self, coro: Coroutine[Any, Any, _T@create_task] | Generator[Any, None, _T@create_task], *, name: object = None) -> Task[_T@create_task]`
+ ddtrace/contrib/internal/asyncio/patch.py:39:12: error[invalid-argument-type] Argument to function `unwrap` is incorrect: Expected `WrappedFunction`, found `def create_task[_T](self, coro: Generator[Any, None, _T@create_task] | Coroutine[Any, Any, _T@create_task], *, name: object = None) -> Task[_T@create_task]`
```

Similar, but only results in a diagnostic change.

## Test Plan

Added a regression test
2025-12-03 17:52:31 +01:00
..
ruff Bump 0.14.7 (#21684) 2025-11-28 14:34:27 -06:00
ruff_annotate_snippets Only render hyperlinks for terminals known to support them (#21519) 2025-11-19 10:02:58 +01:00
ruff_benchmark Move `Token`, `TokenKind` and `Tokens` to `ruff-python-ast` (#21760) 2025-12-02 20:10:46 +01:00
ruff_cache Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_db [ty] Enable LRU collection for parsed module (#21749) 2025-12-03 12:16:18 +01:00
ruff_dev Update Rust toolchain to 1.91 (#21179) 2025-11-01 01:50:58 +00:00
ruff_diagnostics [ty] Add code action to ignore diagnostic on the current line (#21595) 2025-11-29 15:41:54 +01:00
ruff_formatter [ty] Use "cannot" consistently over "can not" (#21255) 2025-11-03 10:38:20 -05:00
ruff_graph `analyze`: Add option to skip over imports in `TYPE_CHECKING` blocks (#21472) 2025-11-16 12:30:24 +00:00
ruff_index Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
ruff_linter [syntax-error] Default type parameter followed by non-default type parameter (#21657) 2025-12-03 12:01:31 +05:30
ruff_macros Document when a rule was added (#21035) 2025-10-23 14:48:41 -04:00
ruff_memory_usage [ty] Enable LRU collection for parsed module (#21749) 2025-12-03 12:16:18 +01:00
ruff_notebook [ty] Respect notebook cell boundaries when adding an auto import (#21322) 2025-11-13 18:58:08 +01:00
ruff_options_metadata Update Rust toolchain to 1.89 (#19807) 2025-08-07 18:21:50 +02:00
ruff_python_ast Add token based `parenthesized_ranges` implementation (#21738) 2025-12-03 08:15:17 +00:00
ruff_python_ast_integration_tests Add token based `parenthesized_ranges` implementation (#21738) 2025-12-03 08:15:17 +00:00
ruff_python_codegen Move `Token`, `TokenKind` and `Tokens` to `ruff-python-ast` (#21760) 2025-12-02 20:10:46 +01:00
ruff_python_formatter Move `Token`, `TokenKind` and `Tokens` to `ruff-python-ast` (#21760) 2025-12-02 20:10:46 +01:00
ruff_python_importer Move `Token`, `TokenKind` and `Tokens` to `ruff-python-ast` (#21760) 2025-12-02 20:10:46 +01:00
ruff_python_index Move `Token`, `TokenKind` and `Tokens` to `ruff-python-ast` (#21760) 2025-12-02 20:10:46 +01:00
ruff_python_literal Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_parser [syntax-error] Default type parameter followed by non-default type parameter (#21657) 2025-12-03 12:01:31 +05:30
ruff_python_semantic Add rule to detect unnecessary class properties (#21535) 2025-11-26 09:31:22 +01:00
ruff_python_stdlib [`ruff`] Extend FA102 with listed PEP 585-compatible APIs (#20659) 2025-10-03 09:45:32 -04:00
ruff_python_trivia Handle t-string prefixes in `SimpleTokenizer` (#20578) 2025-09-25 14:33:37 -05:00
ruff_python_trivia_integration_tests Handle t-string prefixes in `SimpleTokenizer` (#20578) 2025-09-25 14:33:37 -05:00
ruff_server Set severity for non-rule diagnostics (#21559) 2025-11-21 17:42:35 +01:00
ruff_source_file Move diff rendering to `ruff_db` (#20006) 2025-08-21 09:47:00 -04:00
ruff_text_size [ty] Fix subtraction overflow bug 2025-11-21 15:07:37 -05:00
ruff_wasm Bump 0.14.7 (#21684) 2025-11-28 14:34:27 -06:00
ruff_workspace `analyze`: Add option to skip over imports in `TYPE_CHECKING` blocks (#21472) 2025-11-16 12:30:24 +00:00
ty Add token based `parenthesized_ranges` implementation (#21738) 2025-12-03 08:15:17 +00:00
ty_combine [ty] Disallow std::env and io methods in most ty crates (#20046) 2025-08-22 11:13:47 -07:00
ty_completion_eval [ty] Exclude `typing_extensions` from completions unless it's really available 2025-12-01 11:24:16 -05:00
ty_ide [ty] Sync vendored typeshed stubs (#21715) 2025-12-03 15:49:51 +00:00
ty_project [ty] Enable LRU collection for parsed module (#21749) 2025-12-03 12:16:18 +01:00
ty_python_semantic [ty] Fix flow of associated member states during star imports (#21776) 2025-12-03 17:52:31 +01:00
ty_server [ty] Fix auto-import code action to handle pre-existing import 2025-12-01 14:20:47 -05:00
ty_static [ty] improve base conda distinction from child conda (#20675) 2025-10-03 13:56:06 +00:00
ty_test [ty] add tests for workspaces (#21741) 2025-12-02 06:43:41 -05:00
ty_vendored [ty] Sync vendored typeshed stubs (#21715) 2025-12-03 15:49:51 +00:00
ty_wasm [ty] Add code action to ignore diagnostic on the current line (#21595) 2025-11-29 15:41:54 +01:00