Commit Graph

13653 Commits

Author SHA1 Message Date
renovate[bot]
371d60cff1 Update dependency ruff to v0.14.13 (#22697)
This PR contains the following updates:

| Package | Change |
[Age](https://docs.renovatebot.com/merge-confidence/) |
[Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [ruff](https://docs.astral.sh/ruff)
([source](https://redirect.github.com/astral-sh/ruff),
[changelog](https://redirect.github.com/astral-sh/ruff/blob/main/CHANGELOG.md))
| `==0.14.11` → `==0.14.13` |
![age](https://developer.mend.io/api/mc/badges/age/pypi/ruff/0.14.13?slim=true)
|
![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/ruff/0.14.11/0.14.13?slim=true)
|

---

### Release Notes

<details>
<summary>astral-sh/ruff (ruff)</summary>

###
[`v0.14.13`](https://redirect.github.com/astral-sh/ruff/blob/HEAD/CHANGELOG.md#01413)

Released on 2026-01-15.

This is a follow-up release to 0.14.12. Because of an issue publishing
the WASM packages, there is no GitHub release or Git tag for 0.14.12,
although the package was published to PyPI. The contents of the 0.14.13
release are identical to 0.14.12.

###
[`v0.14.12`](https://redirect.github.com/astral-sh/ruff/blob/HEAD/CHANGELOG.md#01412)

Released on 2026-01-15.

##### Preview features

- \[`flake8-blind-except`] Allow more logging methods (`BLE001`)
([#&#8203;22057](https://redirect.github.com/astral-sh/ruff/pull/22057))
- \[`ruff`] Respect `lint.pydocstyle.property-decorators` in `RUF066`
([#&#8203;22515](https://redirect.github.com/astral-sh/ruff/pull/22515))

##### Bug fixes

- Fix configuration path in `--show-settings`
([#&#8203;22478](https://redirect.github.com/astral-sh/ruff/pull/22478))
- Respect `fmt: skip` for multiple statements on the same logical line
([#&#8203;22119](https://redirect.github.com/astral-sh/ruff/pull/22119))

##### Rule changes

- \[`pydocstyle`] Update Rust crate imperative to v1.0.7 (`D401`)
([#&#8203;22519](https://redirect.github.com/astral-sh/ruff/pull/22519))
- \[`isort`] Insert imports in alphabetical order (`I002`)
([#&#8203;22493](https://redirect.github.com/astral-sh/ruff/pull/22493))

##### Documentation

- Add llms.txt support for documentation
([#&#8203;22463](https://redirect.github.com/astral-sh/ruff/pull/22463))
- Use prek in documentation and CI
([#&#8203;22505](https://redirect.github.com/astral-sh/ruff/pull/22505))
- \[`flake8-pytest-style`] Add `check` parameter example to `PT017` docs
([#&#8203;22546](https://redirect.github.com/astral-sh/ruff/pull/22546))
- \[`ruff`] Make example error out-of-the-box (`RUF103`)
([#&#8203;22558](https://redirect.github.com/astral-sh/ruff/pull/22558))
- \[`ruff`] document `RUF100` trailing comment fix behavior
([#&#8203;22479](https://redirect.github.com/astral-sh/ruff/pull/22479))

##### Other changes

- wasm: Require explicit logging initialization
([#&#8203;22587](https://redirect.github.com/astral-sh/ruff/pull/22587))

##### Contributors

- [@&#8203;terror](https://redirect.github.com/terror)
- [@&#8203;harupy](https://redirect.github.com/harupy)
- [@&#8203;Jkhall81](https://redirect.github.com/Jkhall81)
- [@&#8203;dhruvmanila](https://redirect.github.com/dhruvmanila)
- [@&#8203;lubaskinc0de](https://redirect.github.com/lubaskinc0de)
- [@&#8203;zanieb](https://redirect.github.com/zanieb)
- [@&#8203;MeGaGiGaGon](https://redirect.github.com/MeGaGiGaGon)
- [@&#8203;charliermarsh](https://redirect.github.com/charliermarsh)
- [@&#8203;renovate](https://redirect.github.com/renovate)
- [@&#8203;dylwil3](https://redirect.github.com/dylwil3)
- [@&#8203;MichaReiser](https://redirect.github.com/MichaReiser)
- [@&#8203;11happy](https://redirect.github.com/11happy)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/astral-sh/ruff).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi43NC41IiwidXBkYXRlZEluVmVyIjoiNDIuNzQuNSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiaW50ZXJuYWwiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-19 01:01:25 +00:00
Alex Waygood
7c9803310e [ty] Set None as the definition of Self type variables (#22648) 2026-01-18 19:04:40 +00:00
Alexandr
bab571c12c [ty] Recognize string-literal types as subtypes of Sequence[Literal[chars]] (#22415)
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
2026-01-18 17:43:44 +00:00
Charlie Marsh
57c98a1f07 [ty] Emit diagnostic for NamedTuple and TypedDict decorated with dataclass (#22672)
## Summary

Closes https://github.com/astral-sh/ty/issues/2515.

Closes https://github.com/astral-sh/ty/issues/2527.
2026-01-18 17:20:09 +00:00
Micha Reiser
0e5bac06c8 [ty] Highlight interpolated-parts in t-strings (#22674)
Co-authored-by: Claude <noreply@anthropic.com>
2026-01-18 12:37:12 +00:00
Micha Reiser
bbe295a846 [ty] Fix missing syntax highlighting for aliased import names (#22675)
Co-authored-by: Claude <noreply@anthropic.com>
2026-01-18 12:14:42 +00:00
Alex Waygood
7b534a9b89 scripts/conformance.py: fix collection of diagnostics (#22671) 2026-01-18 11:52:38 +00:00
Charlie Marsh
ac8c85eb8c [ty] Support passing typename and field_names by keyword argument (#22660)
## Summary

Closes https://github.com/astral-sh/ty/issues/2549.
2026-01-17 19:02:34 -05:00
Kevin Yang
704d30f473 [airflow] Second positional argument to Asset/Dataset should not be a dictionary (AIR303) (#22453)
<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
-->

## Summary

This PR is related to https://github.com/apache/airflow/issues/48389.

In Airflow 3, the function signature for `airflow.Dataset`,
`airflow.datasets.Dataset`, and `airflow.sdk.Asset` has changed. Below
is the function signature for `airflow.sdk.Asset`. The second positional
argument is `uri` which is of type `str`. In the older version, the
second positional argument can be a dictionary which is the `extra:
'dict | None' = None` argument. Therefore, we need to flag this in
Airflow 3.

```python
Asset(name: 'str | None' = None, uri: 'str | None' = None, *, group: 'str | None' = None, extra: 'dict | None' = None, watchers: 'list[AssetWatcher | SerializedAssetWatcher] | None' = None) -> 'None'
```

As this is a check on constructor call, we need to create a new method
`check_constructor_arguments`, instead of on method call. The new rule
check whether the index 1 (the second argument) is a dictionary (either
a literal or a `dict()` call).

## Test Plan

The `AIR303.py` test file have been updated with new test cases. The
snapshot has been updated and all other test cases passed.

@Lee-W , could you please review it when you have a chance, and let me
know if you have further feedback. Thanks!
2026-01-17 15:16:12 -05:00
Alex Waygood
3608c620ac [ty] Right-hand side narrowing for if Foo is type(x) expressions (#22608) 2026-01-17 15:49:51 +00:00
Charlie Marsh
df58d67974 [ty] Validate constructor arguments when a class is used as a decorator (#22377)
## Summary

If a class is used as a decorator, we now use the class constructor.

Closes https://github.com/astral-sh/ty/issues/2232.
2026-01-17 10:48:59 -05:00
Alex Waygood
6b16931169 [ty] Simple syntactic validation for PEP-613 type aliases (#22652) 2026-01-17 15:43:50 +00:00
Alex Waygood
2e4774623c [ty] Ban NewTypes with generic bases (#22653) 2026-01-17 15:23:53 +00:00
Alex Waygood
ca57b2595e conformance.py: Only use the "No changes detected " summary if no diagnostics were added or removed (#22649) 2026-01-17 13:30:45 +00:00
Will Duke
dfd236c028 [ty] Handle optional errors in conformance workflow (#22647) 2026-01-17 12:47:45 +00:00
Matthew Mckee
ebf7d0cd2f [ty] Don't add a subdiagnostic pointing to the TypeVar definition if the TypeVar is Self (#22646) 2026-01-17 12:41:37 +00:00
justin
938c1c5e12 [ty] diagnostic on overridden __setattr__ and __delattr__ in frozen dataclasses (#21430)
## Summary
https://github.com/astral-sh/ty/issues/111

this pr adds an `invalid-dataclass-override` diagnostic when a custom
`__setattr__` or `__delattr__` is defined on a dataclass where
`frozen=True`
([docs](https://docs.python.org/3/library/dataclasses.html#frozen-instances))

### Runtime exception
```
Traceback (most recent call last):
  File "/Users/justinchapman/src/ty-playground/main.py", line 4, in <module>
    @dataclass(frozen=True)
     ~~~~~~~~~^^^^^^^^^^^^^
  File "/Users/justinchapman/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/lib/python3.13/dataclasses.py", line 1295, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
                          frozen, match_args, kw_only, slots,
                          weakref_slot)
  File "/Users/justinchapman/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/lib/python3.13/dataclasses.py", line 1157, in _process_class
    func_builder.add_fns_to_class(cls)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/Users/justinchapman/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/lib/python3.13/dataclasses.py", line 516, in add_fns_to_class
    raise TypeError(error_msg)
TypeError: Cannot overwrite attribute __setattr__ in class A
```

### Diagnostic
```
error[invalid-dataclass-override]: Cannot overwrite attribute __setattr__ in class A
 --> /Users/justinchapman/src/ty-playground/main.py:6:5
  |
4 | @dataclass(frozen=True)
5 | class A:
6 |     def __setattr__(self, name: str, value: object) -> None: ...
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
info: __setattr__
info: rule `invalid-dataclass-override` is enabled by default

Found 1 diagnostic
```

## Test Plan
- new mdtests
- e2e
- the `attrs` mypy primer diff looks to be a [true
positive](https://github.com/python-attrs/attrs/blob/main/tests/test_setattr.py#L373)
- the other results have been unpredictable and have changed every time
i pushed new code, even if the diagnostic logic didn't change...

---------

Co-authored-by: Carl Meyer <carl@astral.sh>
2026-01-17 02:24:39 +00:00
Leandro Braga
20d80edfc2 [flake8-bugbear] Mark fix unsafe when it would remove comments (B033) (#22632)
The B033 erroneously removes comments in safe fix.

By running
```console
$ cargo run -p ruff  -- check --select B033 - << 'EOF'
{
  1,
  # comment
  1
}
EOF
```

We get:

# Before

```console
B033 [*] Sets should not contain duplicate item `1`
 --> -:4:3
  |
2 |   1,
3 |   # comment
4 |   1
  |   ^
5 | }
  |
help: Remove duplicate item

Found 1 error.
[*] 1 fixable with the `--fix` option.
```

# After
```console
B033 Sets should not contain duplicate item `1`
 --> -:4:3
  |
2 |   1,
3 |   # comment
4 |   1
  |   ^
5 | }
  |
help: Remove duplicate item

Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).
```

Closes #22629
2026-01-16 19:07:19 -05:00
Alex Waygood
717d024ea9 [ty] Generalize union-type subtyping fast path (#22495) 2026-01-16 22:09:06 +00:00
Leandro Braga
b80d8ff6ff [ruff] Detect duplicate entries in __all__ (RUF068) (#22114)
Hello,

This MR adds a new rule and its fix, `RUF069`,
`DuplicateEntryInDunderAll`. I'm using `RUF069` because we already have
[RUF068](https://github.com/astral-sh/ruff/pull/20585) and
[RUF069](https://github.com/astral-sh/ruff/pull/21079#issuecomment-3493839453)
in the works.

The rule job is to prevent users from accidentally adding duplicate
entries to `__all__`, which, for example, can result from copy-paste
mistakes.

It deals with the following syntaxes:

```python
__all__: list[str] = ["a", "a"]
__all__: typing.Any = ("a", "a")
__all__.extend(["a", "a"])
__all__ += ["a", "a"]
```

But it does not keep track of `__all__` contents, meaning the following
code snippet is a false negative:
```python
class A: ...

__all__ = ["A"]
__all__.extend(["A"])
```

## Violation Example

```console
RUF069 `__all__` contains duplicate entries
 --> RUF069.py:2:17
  |
1 | __all__ = ["A", "A", "B"]
  |                 ^^^
help: Remove duplicate entries from `__all__`
1 | __all__ = ["A", "B"]
  - __all__ = ["A", "A", "B"]
```

## Ecosystem Report

The `ruff-ecosystem` results contain seven violations in four projects,
all of them seem like true positives, with one instance appearing to be
an actual bug.

This [code
snippet](90d855985b/stubs/reportlab/reportlab/lib/rltempfile.pyi (L4))
from `reportlab` contains the same entry twice instead of exporting both
functions.

```python
def get_rl_tempdir(*subdirs: str) -> str: ...
def get_rl_tempfile(fn: str | None = None) -> str: ...

__all__ = ("get_rl_tempdir", "get_rl_tempdir")
```

Closes [#21945](https://github.com/astral-sh/ruff/issues/21945)

---------

Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
2026-01-16 14:58:06 -05:00
Amethyst Reese
337e3ebd27 Combine suppression code diagnostics (#22613)
# Summary

- Report a single combined UnusedNOQA diagnostic when any range
suppression
  has one or more unused, disabled, or duplicate lint codes.
- Report a single combined InvalidRuleCode diagnostic for any range
suppression
  with one or more invalid lint codes.

# Test Plan

Updated fixtures and snapshots

Fixes #22429, #21873
2026-01-16 11:08:48 -08:00
Dex Devlon
5c97b6ef40 [ty] Correct return type for synthesized NamedTuple.__new__ methods (#22625) 2026-01-16 18:56:56 +00:00
Alex Waygood
ed355b6173 [ty] Rename some narrowing-related machinery (#22618) 2026-01-16 17:10:33 +00:00
Alex Waygood
a2b383842a [ty] Allow ... as a default value for any parameter if the function is in an if TYPE_CHECKING block (#22624) 2026-01-16 16:32:38 +00:00
Micha Reiser
a636fbe91c Remove ty_python_semantic dependency from ruff_graph (#22623)
Co-authored-by: Claude <noreply@anthropic.com>
2026-01-16 16:17:05 +01:00
konsti
10fd3b2415 Use explicit manylinux/musllinux targets and better pre-upload checks (#22477)
This ensures that changes to the targets are intentional and explicit.

See also https://github.com/astral-sh/ty/pull/2393 and
https://github.com/astral-sh/uv/pull/17358
2026-01-16 14:26:52 +00:00
Micha Reiser
eb99f80a02 [ty] Extract ty_site_packages crate (#22622) 2026-01-16 15:02:47 +01:00
Alex Waygood
3c323559ed More fixes to scripts/conformance.py (#22616) 2026-01-16 12:47:39 +00:00
Alex Waygood
0cc3a775cd Tell Claude to prefer using #[expect()] over #[allow()] where possible (#22617) 2026-01-16 12:36:32 +00:00
Alex Waygood
28bfcf82b8 [ty] Make ModuleType and object attributes available on namespace packages (#22606)
## Summary

Currently we don't think that namespace packages (e.g. `google` after
you've pip-installed `google-cloud-ndb`) have attributes such as
`__file__`, `__name__`, etc. This PR fixes that.

## Test Plan

Mdtests and snapshots.
2026-01-16 08:42:58 +00:00
Micha Reiser
4adbf7798d [ty] Fix --force-exclude when excluding entire directories (#22595) 2026-01-16 09:23:26 +01:00
Caíque Porfirio
0ce5ce4de1 [ruff] Add exception for ctypes.Structure._fields_ (RUF012) (#22559)
Closes #22166 
## Summary
Adds an exception for `ctypes.Structure._fields_` to the rule RUF012 as
it has it's own way of enforcing immutability:

> The fields class variable can only be set once. Later assignments will
raise an
[AttributeError](https://docs.python.org/3/library/exceptions.html#AttributeError).

---------

Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
2026-01-15 20:49:59 +00:00
Ibraheem Ahmed
78d1343583 [ty] Infer implicit type of cls in __new__ methods (#22584)
## Summary

Resolves https://github.com/astral-sh/ty/issues/2489.
2026-01-15 15:42:16 -05:00
Amethyst Reese
c696ef4025 Skip walking all tokens when loading range suppressions (#22446)
- Adds `Tokens::split_at()` to get tokens before/after an offset.
- Updates `Suppressions::load_from_tokens` to take an `Indexer` and use
comment ranges to minimize the need for walking tokens looking for
indent/dedent.

Adapted from
https://github.com/astral-sh/ruff/pull/21441#pullrequestreview-3503773083

Fixes #22087
2026-01-15 12:35:24 -08:00
Charlie Marsh
b4b8299d6c [ty] Make NamedTuple(...) and namedtuple(...) calls stricter (#22601)
## Summary

Closes https://github.com/astral-sh/ty/issues/2513.
0.14.13
2026-01-15 18:24:25 +00:00
Brent Westbrook
fd9f87d02d Bump 0.14.13 (#22604) 2026-01-15 12:53:20 -05:00
Andrew Gallant
048f02fb6b [ty] Remove redundant re-exports that share the same top-most module
The implementation here is (to me) surprisingly complicated. The main
complications are:

1. Trying to limit the redundant detection to as few of the symbols
we extract as possible. In particular, while I haven't done benchmarking
on this, I perceive the redundancy detection to be somewhat expensive
and auto-import can return lots of symbols. So we're careful to only do
this extra checking on (typically) small groups of symbols that could
possibly be merged.

2. Even by restricting our work, this merging process could still be
called quite a bit. (Thousands of times in my "standard data scienc-y
test environment.") So I went out of my way to amortize allocs.

3. Re-exports can form a chain and we want to find all of them.

4. We (probably) don't want to remove redundant re-exports unless
they share the same top-level module. Otherwise, e.g., a library
that re-exports another library's symbols could have all of its
re-exports dropped.

5. We want to only keep the top-most re-exports, and there may be
multiple such re-exports. So we keep all of them.

6. We can't assume anything about the relationship of re-exports
and the original definition. A re-export could be deeper in the
module hierarchy than the original definition or above it.
2026-01-15 12:31:07 -05:00
Andrew Gallant
a72af10cf8 [ty] Add ModuleName::top
The invariants established by the constructors for `ModuleName`
guarantee that this is always available. It's useful for
determining the "top level" module for where a symbol lives.
2026-01-15 12:31:07 -05:00
Andrew Gallant
2f34836318 [ty] Add test capturing redundant re-exports from pandas
This roughly mimics how pandas defines and re-exports
`read_csv` at the top-level module.
2026-01-15 12:31:07 -05:00
Andrew Gallant
db9eee7b06 [ty] Attach origin module on to re-exported symbols
This information should let us filter out (or rather, merge)
re-exported symbols across a package hierarchy for the purposes
of auto-completions.
2026-01-15 12:31:07 -05:00
Andrew Gallant
2cbd68ab70 [ty] Move fully qualified name into auto-import implementation
Previously, we were constructing this at a higher level layer. But this
commit pushes it down a layer of abstraction. This shouldn't result in
constructing the fully qualified name any more frequently than we
previously did. Namely, we're still only doing it for symbols that match
the caller provided search query.

The motivation here is that we want to do some de-duplication based on
module name, and having the fully qualified name of a symbol seems like
the most straight-forward way to go about this. (We'll need one more
piece of information that we add in a subsequent commit.)
2026-01-15 12:31:07 -05:00
Brent Westbrook
2a0946760f Add trailing slashes to npm publish paths (#22603)
Summary
--

The WASM builds in the 0.14.12 release were failing with an error about
trying
to publish over an existing version 5.8.1 ([example]). This seems to be
because
it's trying to publish a package named `pkg` instead of the `pkg`
directory.

Micha found that a trailing slash causes `npm` to interpret the path
correctly.

Test Plan
--

I think we can test this with a dry run of the release workflow,
otherwise
another release attempt for 0.14.12

[example]:
https://github.com/astral-sh/ruff/actions/runs/21037103249/job/60492735499#step:5:281
2026-01-15 12:18:22 -05:00
Rob Hand
eca58ca1d3 [ty] Override __file__ to str when applicable on imported modules (#22333) 2026-01-15 17:08:50 +00:00
Alex Waygood
aa9f1b27fc Further improvements to typing conformance script (#22596) 2026-01-15 15:49:02 +00:00
Brent Westbrook
f9dd973b13 Bump 0.14.12 (#22602) 2026-01-15 10:41:03 -05:00
Bhuminjay Soni
b2d57ddaa5 [ty]: consolidate type[] types in a union when displaying them in diagnostics (#22592) 2026-01-15 15:20:58 +00:00
Charlie Marsh
de954b6fa4 [ty] Support starred unpacking in class bases (#22591)
## Summary

Closes https://github.com/astral-sh/ty/issues/2492.
2026-01-15 10:17:11 -05:00
Charlie Marsh
fd7cc1f9c9 [ty] Validate field names for typing.NamedTuple(...) (#22599)
## Summary

Closes https://github.com/astral-sh/ty/issues/2511.
2026-01-15 09:15:45 -05:00
RasmusNygren
2a29ce3e41 [ty] Better class def completions (#22571)
## Summary

Prefer completions of type `ClassLiteral` inside class-def context.

Fixes https://github.com/astral-sh/ty/issues/1776

## Test Plan
New completion-eval test that has incorrect ranking on main but correct
after this patch.
2026-01-15 08:31:04 -05:00
Will Duke
9c67b2acd9 [ty] Try fixing conformance workflow (#22593)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Micha Reiser <micha@reiser.io>
2026-01-15 12:38:13 +00:00