mirror of
https://github.com/astral-sh/ruff
synced 2026-01-22 14:00:51 -05:00
fedd982fd5fca5b69adf313220fe9b7c7efabd03
688 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
fedd982fd5 |
[red-knot] Avoid unresolved-reference in unreachable code (#17169)
## Summary This PR changes the inferred type for symbols in unreachable sections of code to `Never` (instead of reporting them as unbound), in order to silence false positive diagnostics. See the lengthy comment in the code for further details. ## Test Plan - Updated Markdown tests. - Manually verified a couple of ecosystem diagnostic changes. |
||
|
|
a1eb834a5f |
Fix relative import resolution in site-packages packages when the site-packages search path is a subdirectory of the first-party search path (#17178)
## Summary
If a package in `site-packages` had this directory structure:
```py
# bar/__init__.py
from .a import A
# bar/a.py
class A: ...
```
then we would fail to resolve the `from .a import A` import _if_ (as is
usually the case!) the `site-packages` search path was located inside a
`.venv` directory that was a subdirectory of the project's first-party
search path. The reason for this is a bug in `file_to_module` in the
module resolver. In this loop, we would identify that
`/project_root/.venv/lib/python3.13/site-packages/foo/__init__.py` can
be turned into a path relative to the first-party search path
(`/project_root`):
|
||
|
|
ca0cce3f9c |
[red-knot] Fix more [redundant-cast] false positives (#17170)
Fixes #17164. Simply checking whether one type is gradually equivalent to another is too simplistic here: `Any` is gradually equivalent to `Todo`, but we should permit users to cast from `Todo` or `Unknown` to `Any` without complaining about it. This changes our logic so that we only complain about redundant casts if: - the two types are exactly equal (when normalized) OR they are equivalent (we'll still complain about `Any -> Any` casts, and about `Any | str | int` -> `str | int | Any` casts, since their normalized forms are exactly equal, even though the type is not fully static -- and therefore does not participate in equivalence relations) - AND the casted type does not contain `Todo` |
||
|
|
3f00010a7a |
[red-knot] Three-argument type-calls take 'str' as the first argument (#17168)
## Summary Similar to #17163, a minor fix in the signature of `type(…)`. ## Test Plan New MD tests |
||
|
|
62f8d855d2 |
[red-knot] Improve Debug implementation for semantic_index::SymbolTable (#17172)
## Summary
`dbg!`ing a `SymbolTable` is currently very noisy due to the
`symbols_by_name` field, which doesn't tell you very much at all. The
noisiness makes debugging difficult. This PR removes the
`symbols_by_name` field from the `Debug` implementation.
## Test Plan
`dbg!` output before of the `builtins.pyi` global-scope symbol table:
<details>
```
[crates/red_knot_python_semantic/src/symbol.rs:633:5] symbol_table(db, scope) = SymbolTable {
symbols: [
Symbol {
name: Name("_ast"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_sitebuiltins"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_typeshed"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("sys"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("types"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("dict_items"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("dict_keys"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("dict_values"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("AnyStr_co"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ConvertibleToFloat"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ConvertibleToInt"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("FileDescriptorOrPath"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("OpenBinaryMode"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("OpenBinaryModeReading"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("OpenBinaryModeUpdating"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("OpenBinaryModeWriting"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("OpenTextMode"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ReadableBuffer"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsAdd"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsAiter"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsAnext"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsDivMod"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsFlush"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsIter"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsKeysAndGetItem"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsLenAndGetItem"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsNext"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsRAdd"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsRDivMod"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsRichComparison"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsRichComparisonT"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsWrite"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Awaitable"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Callable"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Iterable"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Iterator"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("MutableSet"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Reversible"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("AbstractSet"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Sized"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("BufferedRandom"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("BufferedReader"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("BufferedWriter"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("FileIO"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("TextIOWrapper"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("CellType"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("CodeType"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("TracebackType"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("IO"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Any"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("BinaryIO"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ClassVar"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Generic"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Mapping"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("MutableMapping"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("MutableSequence"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Protocol"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Sequence"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsAbs"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsBytes"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsComplex"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsFloat"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SupportsIndex"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("TypeVar"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("final"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("overload"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("type_check_only"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Concatenate"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Literal"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("LiteralString"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ParamSpec"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Self"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("TypeAlias"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("TypeGuard"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("TypeIs"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("TypeVarTuple"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("deprecated"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("GenericAlias"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_T"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("int"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_I"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_T_co"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_T_contra"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_R_co"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_KT"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_VT"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_S"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_T1"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_T2"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_T3"),
flags: SymbolFlags(
IS_BOUND,
),
},
Symbol {
name: Name("_T4"),
flags: SymbolFlags(
IS_BOUND,
),
},
Symbol {
name: Name("_T5"),
flags: SymbolFlags(
IS_BOUND,
),
},
Symbol {
name: Name("_SupportsNextT_co"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_SupportsAnextT_co"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_AwaitableT"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_AwaitableT_co"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_P"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_StartT_co"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_StopT_co"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_StepT_co"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("object"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("staticmethod"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("classmethod"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("type"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("super"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_PositiveInteger"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_NegativeInteger"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_LiteralInteger"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("float"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("complex"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_FormatMapMapping"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_TranslateTable"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("str"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("bytes"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("bytearray"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_IntegerFormats"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("memoryview"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("bool"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("slice"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("tuple"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("function"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("list"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("dict"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("set"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("frozenset"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("enumerate"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("range"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("property"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_NotImplementedType"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("NotImplemented"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("abs"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("all"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("any"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ascii"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("bin"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("breakpoint"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("callable"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("chr"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_PathLike"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("aiter"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_SupportsSynchronousAnext"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("anext"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("compile"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("copyright"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("credits"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("delattr"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("dir"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("divmod"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("eval"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("exec"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("exit"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("filter"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("format"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("getattr"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("globals"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("hasattr"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("hash"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("help"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("hex"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("id"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("input"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_GetItemIterable"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("iter"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_ClassInfo"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("isinstance"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("issubclass"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("len"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("license"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("locals"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("map"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("max"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("min"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("next"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("oct"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_Opener"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("open"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ord"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_SupportsWriteAndFlush"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("print"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_E_contra"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_M_contra"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_SupportsPow2"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_SupportsPow3NoneOnly"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_SupportsPow3"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_SupportsSomeKindOfPow"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("pow"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("quit"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("reversed"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("repr"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_SupportsRound1"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_SupportsRound2"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("round"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("setattr"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("sorted"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_AddableT1"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_AddableT2"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_SupportsSumWithNoDefaultGiven"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_SupportsSumNoDefaultT"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("sum"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("vars"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("zip"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("__import__"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("__build_class__"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("EllipsisType"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ellipsis"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Ellipsis"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("BaseException"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("GeneratorExit"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("KeyboardInterrupt"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SystemExit"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Exception"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("StopIteration"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("OSError"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("EnvironmentError"),
flags: SymbolFlags(
IS_BOUND,
),
},
Symbol {
name: Name("IOError"),
flags: SymbolFlags(
IS_BOUND,
),
},
Symbol {
name: Name("WindowsError"),
flags: SymbolFlags(
IS_BOUND,
),
},
Symbol {
name: Name("ArithmeticError"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("AssertionError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("AttributeError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("BufferError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("EOFError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ImportError"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("LookupError"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("MemoryError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("NameError"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ReferenceError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("RuntimeError"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("StopAsyncIteration"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SyntaxError"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SystemError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("TypeError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ValueError"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("FloatingPointError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("OverflowError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ZeroDivisionError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ModuleNotFoundError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("IndexError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("KeyError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("UnboundLocalError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("BlockingIOError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ChildProcessError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ConnectionError"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("BrokenPipeError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ConnectionAbortedError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ConnectionRefusedError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ConnectionResetError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("FileExistsError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("FileNotFoundError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("InterruptedError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("IsADirectoryError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("NotADirectoryError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("PermissionError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ProcessLookupError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("TimeoutError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("NotImplementedError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("RecursionError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("IndentationError"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("TabError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("UnicodeError"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("UnicodeDecodeError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("UnicodeEncodeError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("UnicodeTranslateError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("Warning"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("UserWarning"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("DeprecationWarning"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("SyntaxWarning"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("RuntimeWarning"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("FutureWarning"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("PendingDeprecationWarning"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ImportWarning"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("UnicodeWarning"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("BytesWarning"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ResourceWarning"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("EncodingWarning"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("_BaseExceptionT_co"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_BaseExceptionT"),
flags: SymbolFlags(
IS_BOUND,
),
},
Symbol {
name: Name("_ExceptionT_co"),
flags: SymbolFlags(
IS_USED | IS_BOUND,
),
},
Symbol {
name: Name("_ExceptionT"),
flags: SymbolFlags(
IS_BOUND,
),
},
Symbol {
name: Name("BaseExceptionGroup"),
flags: SymbolFlags(
IS_USED | IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("ExceptionGroup"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
Symbol {
name: Name("PythonFinalizationError"),
flags: SymbolFlags(
IS_BOUND | IS_DECLARED,
),
},
],
symbols_by_name: {
ScopedSymbolId(
235,
): (),
ScopedSymbolId(
267,
): (),
ScopedSymbolId(
86,
): (),
ScopedSymbolId(
22,
): (),
ScopedSymbolId(
182,
): (),
ScopedSymbolId(
213,
): (),
ScopedSymbolId(
252,
): (),
ScopedSymbolId(
177,
): (),
ScopedSymbolId(
173,
): (),
ScopedSymbolId(
108,
): (),
ScopedSymbolId(
122,
): (),
ScopedSymbolId(
118,
): (),
ScopedSymbolId(
197,
): (),
ScopedSymbolId(
69,
): (),
ScopedSymbolId(
134,
): (),
ScopedSymbolId(
52,
): (),
ScopedSymbolId(
248,
): (),
ScopedSymbolId(
168,
): (),
ScopedSymbolId(
2,
): (),
ScopedSymbolId(
129,
): (),
ScopedSymbolId(
5,
): (),
ScopedSymbolId(
18,
): (),
ScopedSymbolId(
150,
): (),
ScopedSymbolId(
9,
): (),
ScopedSymbolId(
16,
): (),
ScopedSymbolId(
205,
): (),
ScopedSymbolId(
246,
): (),
ScopedSymbolId(
68,
): (),
ScopedSymbolId(
93,
): (),
ScopedSymbolId(
189,
): (),
ScopedSymbolId(
161,
): (),
ScopedSymbolId(
64,
): (),
ScopedSymbolId(
124,
): (),
ScopedSymbolId(
229,
): (),
ScopedSymbolId(
94,
): (),
ScopedSymbolId(
202,
): (),
ScopedSymbolId(
67,
): (),
ScopedSymbolId(
120,
): (),
ScopedSymbolId(
219,
): (),
ScopedSymbolId(
12,
): (),
ScopedSymbolId(
20,
): (),
ScopedSymbolId(
79,
): (),
ScopedSymbolId(
11,
): (),
ScopedSymbolId(
157,
): (),
ScopedSymbolId(
216,
): (),
ScopedSymbolId(
231,
): (),
ScopedSymbolId(
239,
): (),
ScopedSymbolId(
140,
): (),
ScopedSymbolId(
36,
): (),
ScopedSymbolId(
13,
): (),
ScopedSymbolId(
184,
): (),
ScopedSymbolId(
204,
): (),
ScopedSymbolId(
70,
): (),
ScopedSymbolId(
259,
): (),
ScopedSymbolId(
96,
): (),
ScopedSymbolId(
111,
): (),
ScopedSymbolId(
72,
): (),
ScopedSymbolId(
247,
): (),
ScopedSymbolId(
101,
): (),
ScopedSymbolId(
242,
): (),
ScopedSymbolId(
261,
): (),
ScopedSymbolId(
263,
): (),
ScopedSymbolId(
214,
): (),
ScopedSymbolId(
62,
): (),
ScopedSymbolId(
166,
): (),
ScopedSymbolId(
244,
): (),
ScopedSymbolId(
257,
): (),
ScopedSymbolId(
133,
): (),
ScopedSymbolId(
112,
): (),
ScopedSymbolId(
87,
): (),
ScopedSymbolId(
90,
): (),
ScopedSymbolId(
117,
): (),
ScopedSymbolId(
158,
): (),
ScopedSymbolId(
162,
): (),
ScopedSymbolId(
230,
): (),
ScopedSymbolId(
154,
): (),
ScopedSymbolId(
255,
): (),
ScopedSymbolId(
35,
): (),
ScopedSymbolId(
39,
): (),
ScopedSymbolId(
138,
): (),
ScopedSymbolId(
190,
): (),
ScopedSymbolId(
21,
): (),
ScopedSymbolId(
66,
): (),
ScopedSymbolId(
181,
): (),
ScopedSymbolId(
7,
): (),
ScopedSymbolId(
236,
): (),
ScopedSymbolId(
251,
): (),
ScopedSymbolId(
152,
): (),
ScopedSymbolId(
227,
): (),
ScopedSymbolId(
78,
): (),
ScopedSymbolId(
55,
): (),
ScopedSymbolId(
61,
): (),
ScopedSymbolId(
253,
): (),
ScopedSymbolId(
47,
): (),
ScopedSymbolId(
65,
): (),
ScopedSymbolId(
153,
): (),
ScopedSymbolId(
104,
): (),
ScopedSymbolId(
74,
): (),
ScopedSymbolId(
107,
): (),
ScopedSymbolId(
149,
): (),
ScopedSymbolId(
98,
): (),
ScopedSymbolId(
155,
): (),
ScopedSymbolId(
169,
): (),
ScopedSymbolId(
180,
): (),
ScopedSymbolId(
237,
): (),
ScopedSymbolId(
146,
): (),
ScopedSymbolId(
15,
): (),
ScopedSymbolId(
243,
): (),
ScopedSymbolId(
17,
): (),
ScopedSymbolId(
136,
): (),
ScopedSymbolId(
80,
): (),
ScopedSymbolId(
44,
): (),
ScopedSymbolId(
228,
): (),
ScopedSymbolId(
60,
): (),
ScopedSymbolId(
245,
): (),
ScopedSymbolId(
193,
): (),
ScopedSymbolId(
264,
): (),
ScopedSymbolId(
268,
): (),
ScopedSymbolId(
58,
): (),
ScopedSymbolId(
258,
): (),
ScopedSymbolId(
279,
): (),
ScopedSymbolId(
113,
): (),
ScopedSymbolId(
135,
): (),
ScopedSymbolId(
240,
): (),
ScopedSymbolId(
85,
): (),
ScopedSymbolId(
186,
): (),
ScopedSymbolId(
100,
): (),
ScopedSymbolId(
187,
): (),
ScopedSymbolId(
106,
): (),
ScopedSymbolId(
73,
): (),
ScopedSymbolId(
223,
): (),
ScopedSymbolId(
49,
): (),
ScopedSymbolId(
83,
): (),
ScopedSymbolId(
77,
): (),
ScopedSymbolId(
43,
): (),
ScopedSymbolId(
274,
): (),
ScopedSymbolId(
46,
): (),
ScopedSymbolId(
151,
): (),
ScopedSymbolId(
217,
): (),
ScopedSymbolId(
178,
): (),
ScopedSymbolId(
278,
): (),
ScopedSymbolId(
132,
): (),
ScopedSymbolId(
6,
): (),
ScopedSymbolId(
174,
): (),
ScopedSymbolId(
99,
): (),
ScopedSymbolId(
196,
): (),
ScopedSymbolId(
109,
): (),
ScopedSymbolId(
128,
): (),
ScopedSymbolId(
123,
): (),
ScopedSymbolId(
102,
): (),
ScopedSymbolId(
116,
): (),
ScopedSymbolId(
172,
): (),
ScopedSymbolId(
32,
): (),
ScopedSymbolId(
105,
): (),
ScopedSymbolId(
241,
): (),
ScopedSymbolId(
95,
): (),
ScopedSymbolId(
206,
): (),
ScopedSymbolId(
209,
): (),
ScopedSymbolId(
198,
): (),
ScopedSymbolId(
81,
): (),
ScopedSymbolId(
170,
): (),
ScopedSymbolId(
171,
): (),
ScopedSymbolId(
8,
): (),
ScopedSymbolId(
276,
): (),
ScopedSymbolId(
1,
): (),
ScopedSymbolId(
212,
): (),
ScopedSymbolId(
222,
): (),
ScopedSymbolId(
33,
): (),
ScopedSymbolId(
144,
): (),
ScopedSymbolId(
194,
): (),
ScopedSymbolId(
125,
): (),
ScopedSymbolId(
89,
): (),
ScopedSymbolId(
38,
): (),
ScopedSymbolId(
51,
): (),
ScopedSymbolId(
19,
): (),
ScopedSymbolId(
163,
): (),
ScopedSymbolId(
0,
): (),
ScopedSymbolId(
211,
): (),
ScopedSymbolId(
3,
): (),
ScopedSymbolId(
226,
): (),
ScopedSymbolId(
121,
): (),
ScopedSymbolId(
148,
): (),
ScopedSymbolId(
232,
): (),
ScopedSymbolId(
262,
): (),
ScopedSymbolId(
260,
): (),
ScopedSymbolId(
91,
): (),
ScopedSymbolId(
270,
): (),
ScopedSymbolId(
269,
): (),
ScopedSymbolId(
225,
): (),
ScopedSymbolId(
191,
): (),
ScopedSymbolId(
115,
): (),
ScopedSymbolId(
28,
): (),
ScopedSymbolId(
220,
): (),
ScopedSymbolId(
164,
): (),
ScopedSymbolId(
250,
): (),
ScopedSymbolId(
137,
): (),
ScopedSymbolId(
141,
): (),
ScopedSymbolId(
24,
): (),
ScopedSymbolId(
54,
): (),
ScopedSymbolId(
45,
): (),
ScopedSymbolId(
188,
): (),
ScopedSymbolId(
75,
): (),
ScopedSymbolId(
40,
): (),
ScopedSymbolId(
234,
): (),
ScopedSymbolId(
30,
): (),
ScopedSymbolId(
41,
): (),
ScopedSymbolId(
127,
): (),
ScopedSymbolId(
185,
): (),
ScopedSymbolId(
145,
): (),
ScopedSymbolId(
23,
): (),
ScopedSymbolId(
238,
): (),
ScopedSymbolId(
143,
): (),
ScopedSymbolId(
167,
): (),
ScopedSymbolId(
110,
): (),
ScopedSymbolId(
25,
): (),
ScopedSymbolId(
31,
): (),
ScopedSymbolId(
57,
): (),
ScopedSymbolId(
195,
): (),
ScopedSymbolId(
221,
): (),
ScopedSymbolId(
218,
): (),
ScopedSymbolId(
37,
): (),
ScopedSymbolId(
71,
): (),
ScopedSymbolId(
50,
): (),
ScopedSymbolId(
176,
): (),
ScopedSymbolId(
179,
): (),
ScopedSymbolId(
200,
): (),
ScopedSymbolId(
266,
): (),
ScopedSymbolId(
277,
): (),
ScopedSymbolId(
119,
): (),
ScopedSymbolId(
84,
): (),
ScopedSymbolId(
114,
): (),
ScopedSymbolId(
165,
): (),
ScopedSymbolId(
271,
): (),
ScopedSymbolId(
280,
): (),
ScopedSymbolId(
256,
): (),
ScopedSymbolId(
249,
): (),
ScopedSymbolId(
88,
): (),
ScopedSymbolId(
27,
): (),
ScopedSymbolId(
139,
): (),
ScopedSymbolId(
265,
): (),
ScopedSymbolId(
4,
): (),
ScopedSymbolId(
53,
): (),
ScopedSymbolId(
29,
): (),
ScopedSymbolId(
130,
): (),
ScopedSymbolId(
42,
): (),
ScopedSymbolId(
76,
): (),
ScopedSymbolId(
147,
): (),
ScopedSymbolId(
156,
): (),
ScopedSymbolId(
208,
): (),
ScopedSymbolId(
273,
): (),
ScopedSymbolId(
183,
): (),
ScopedSymbolId(
224,
): (),
ScopedSymbolId(
97,
): (),
ScopedSymbolId(
233,
): (),
ScopedSymbolId(
82,
): (),
ScopedSymbolId(
142,
): (),
ScopedSymbolId(
254,
): (),
ScopedSymbolId(
131,
): (),
ScopedSymbolId(
63,
): (),
ScopedSymbolId(
48,
): (),
ScopedSymbolId(
215,
): (),
ScopedSymbolId(
103,
): (),
ScopedSymbolId(
14,
): (),
ScopedSymbolId(
92,
): (),
ScopedSymbolId(
207,
): (),
ScopedSymbolId(
275,
): (),
ScopedSymbolId(
160,
): (),
ScopedSymbolId(
26,
): (),
ScopedSymbolId(
56,
): (),
ScopedSymbolId(
34,
): (),
ScopedSymbolId(
272,
): (),
ScopedSymbolId(
59,
): (),
ScopedSymbolId(
126,
): (),
ScopedSymbolId(
159,
): (),
ScopedSymbolId(
199,
): (),
ScopedSymbolId(
175,
): (),
ScopedSymbolId(
192,
): (),
ScopedSymbolId(
201,
): (),
ScopedSymbolId(
203,
): (),
ScopedSymbolId(
210,
): (),
ScopedSymbolId(
10,
): (),
},
}
```
</details>
I checked that with this PR, the second field is gone from the debug
output (I'd paste it in, but it goes over the GitHub comment length
maximum).
|
||
|
|
130339f3d8 |
[red-knot] Fix str(…) calls (#17163)
## Summary The existing signature for `str` calls had various problems, one of which I noticed while looking at some ecosystem projects (`scrapy`, added as a project to mypy_primer in this PR). ## Test Plan - New tests for `str(…)` calls. - Observed reduction of false positives in ecosystem checks |
||
|
|
e50fc049ab |
[red-knot] visibility_constraint analysis for match cases (#17077)
## Summary Add visibility constraint analysis for pattern predicate kinds `Singleton`, `Or`, and `Class`. ## Test Plan update conditional/match.md |
||
|
|
177afabe18 |
[red-knot] Callable types are disjoint from literals (#17160)
## Summary A callable type is disjoint from other literal types. For example, `Type::StringLiteral` must be an instance of exactly `str`, not a subclass of `str`, and `str` is not callable. The same applies to other literal types. This should hopefully fix #17144, I couldn't produce any failures after running property tests multiple times. ## Test Plan Add test cases for disjointness check between callable and other literal types. Run property tests multiple times. |
||
|
|
28c68934a4 |
[red-knot] Fix inference for pow between two literal integers (#17161)
## Summary Python `**` works differently to Rust `**`! ## Test Plan Added an mdtest for various edge cases, and checked in the Python REPL that we infer the correct type in all the new cases tested. |
||
|
|
c2bb5d5250 |
[red-knot] Fix equivalence of differently ordered unions that contain Callable types (#17145)
## Summary Fixes https://github.com/astral-sh/ruff/issues/17058. Equivalent callable types were not understood as equivalent when they appeared nested inside unions and intersections. This PR fixes that by ensuring that `Callable` elements nested inside unions, intersections and tuples have their representations normalized before one union type is compared with another for equivalence, or before one intersection type is compared with another for equivalence. The normalizations applied to a `Callable` type are: - the type of the default value is stripped from all parameters (only whether the parameter _has_ a default value is relevant to whether one `Callable` type is equivalent to another) - The names of the parameters are stripped from positional-only parameters, variadic parameters and keyword-variadic parameters - Unions and intersections that are present (top-level or nested) inside parameter annotations or return annotations are normalized. Adding a `CallableType::normalized()` method also allows us to simplify the implementation of `CallableType::is_equivalent_to()`. ### Should these normalizations be done eagerly as part of a `CallableType` constructor? I considered this. It's something that we could still consider doing in the future; this PR doesn't rule it out as a possibility. However, I didn't pursue it for now, for several reasons: 1. Our current `Display` implementation doesn't handle well the possibility that a parameter might not have a name or an annotated type. Callable types with parameters like this would be displayed as follows: ```py (, ,) -> None: ... ``` That's fixable! It could easily become something like `(Unknown, Unknown) -> None: ...`. But it also illustrates that we probably want to retain the parameter names when displaying the signature of a `lambda` function if you're hovering over a reference to the lambda in an IDE. Currently we don't have a `LambdaType` struct for representing `lambda` functions; if we wanted to eagerly normalize signatures when creating `CallableType`s, we'd probably have to add a `LambdaType` struct so that we would retain the full signature of a `lambda` function, rather than representing it as an eagerly simplified `CallableType`. 2. In order to ensure that it's impossible to create `CallableType`s without the parameters being normalized, I'd either have to create an alternative `SimplifiedSignature` struct (which would duplicate a lot of code), or move `CallableType` to a new module so that the only way of constructing a `CallableType` instance would be via a constructor method that performs the normalizations eagerly on the callable's signature. Again, this isn't a dealbreaker, and I think it's still an option, but it would be a lot of churn, and it didn't seem necessary for now. Doing it this way, at least to start with, felt like it would create a diff that's easier to review and felt like it would create fewer merge conflicts for others. ## Test Plan - Added a regression mdtest for https://github.com/astral-sh/ruff/issues/17058 - Ran `QUICKCHECK_TESTS=1000000 cargo test --release -p red_knot_python_semantic -- --ignored types::property_tests::stable` |
||
|
|
af988bf866 |
[red-knot] Detect division-by-zero in unions and intersections (#17157)
## Summary
With this PR, we emit a diagnostic for this case where
previously didn't:
```py
from typing import Literal
def f(m: int, n: Literal[-1, 0, 1]):
# error: [division-by-zero] "Cannot divide object of type `int` by zero"
return m / n
```
## Test Plan
New Markdown test
|
||
|
|
185bcfef1a |
red_knot_python_semantic: remove comment about TypeCheckDiagnostic
I put this in its own commit in case all of the information removed here was controversial. But it *looks* stale to me. At the very least, `TypeCheckDiagnostic` no longer exists, so that would need to be fixed. And it doesn't really make sense to me (at this point) to make `Diagnostic` a Salsa struct, particularly since we are keen on using it in Ruff (at some point). |
||
|
|
c30e80a3f4 |
ruff_db: delete most of the old diagnostic code
We do keep around `OldSecondaryDiagnosticMessage`, since that's part of the Red Knot `InferContext` API. But it's a rather simple type, and we'll be able to delete it entirely once `InferContext` exposes the new `Diagnostic` type directly. Since we aren't consuming `OldSecondaryDiagnosticMessage` any more, we can now accept a slice instead of a vec. (Thanks Clippy.) |
||
|
|
4e169e5f6c |
red_knot: use Diagnostic inside of red knot
This replaces things like `TypeCheckDiagnostic` with the new Diagnostic` type. This is a "surgical" replacement where we retain the existing API of of diagnostic reporting such that _most_ of Red Knot doesn't need to be changed to support this update. But it will enable us to start using the new diagnostic renderer and to delete the old renderer. It also paves the path for exposing the new `Diagnostic` data model to the broader Red Knot codebase. |
||
|
|
a8a18e7171 |
red_knot_python_semantic: remove WithDiagnostic trait
I did this mostly because it wasn't buying us much, and I'm trying to simplify the public API of the types I'd like to refactor in order to make the refactor simpler. If we really want something like this, we can re-add it later. |
||
|
|
a953373892 |
red_knot_python_semantic: remove Deref impl on TypeCheckDiagnostics
I removed this to see how much code was depending internally on the `&[Arc<TypeCheckDiagnostic>]` representation. Thankfully, it was just one place. So I just removed the `Deref` impl in favor of adding an explicit `iter` method. In general, I think using `Deref` for things like this is _somewhat_ of an abuse. The tip-off is if there are `&self` or `&mut self` methods on the type, then it's probably not a good candidate for `Deref`. |
||
|
|
2ae39edccf |
[red-knot] Goto type definition (#16901)
## Summary Implement basic *Goto type definition* support for Red Knot's LSP. This PR also builds the foundation for other LSP operations. E.g., Goto definition, hover, etc., should be able to reuse some, if not most, logic introduced in this PR. The basic steps of resolving the type definitions are: 1. Find the closest token for the cursor offset. This is a bit more subtle than I first anticipated because the cursor could be positioned right between the callee and the `(` in `call(test)`, in which case we want to resolve the type for `call`. 2. Find the node with the minimal range that fully encloses the token found in 1. I somewhat suspect that 1 and 2 could be done at the same time but it complicated things because we also need to compute the spine (ancestor chain) for the node and there's no guarantee that the found nodes have the same ancestors 3. Reduce the node found in 2. to a node that is a valid goto target. This may require traversing upwards to e.g. find the closest expression. 4. Resolve the type for the goto target 5. Resolve the location for the type, return it to the LSP ## Design decisions The current implementation navigates to the inferred type. I think this is what we want because it means that it correctly accounts for narrowing (in which case we want to go to the narrowed type because that's the value's type at the given position). However, it does have the downside that Goto type definition doesn't work whenever we infer `T & Unknown` because intersection types aren't supported. I'm not sure what to do about this specific case, other than maybe ignoring `Unkown` in Goto type definition if the type is an intersection? ## Known limitations * Types defined in the vendored typeshed aren't supported because the client can't open files from the red knot binary (we can either implement our own file protocol and handler OR extract the typeshed files and point there). See https://github.com/astral-sh/ruff/issues/17041 * Red Knot only exposes an API to get types for expressions and definitions. However, there are many other nodes with identifiers that can have a type (e.g. go to type of a globals statement, match patterns, ...). We can add support for those in separate PRs (after we figure out how to query the types from the semantic model). See https://github.com/astral-sh/ruff/issues/17113 * We should have a higher-level API for the LSP that doesn't directly call semantic queries. I intentionally decided not to design that API just yet. ## Test plan https://github.com/user-attachments/assets/fa077297-a42d-4ec8-b71f-90c0802b4edb Goto type definition on a union <img width="1215" alt="Screenshot 2025-04-01 at 13 02 55" src="https://github.com/user-attachments/assets/689cabcc-4a86-4a18-b14a-c56f56868085" /> Note: I recorded this using a custom typeshed path so that navigating to builtins works. |
||
|
|
7e97910704 |
[red-knot] Fix _NotImplementedType check for Python >=3.10 (#17143)
<!-- Thank you for contributing to Ruff! 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? - Does this pull request include references to any relevant issues? --> ## Summary from https://github.com/astral-sh/ruff/pull/17034#discussion_r2024222525 This is a simple PR to fix the invalid behavior of `NotImplemented` on Python >=3.10. ## Test Plan I think it would be better if we could run mdtest across multiple Python versions in GitHub Actions. <!-- How was it tested? --> --------- Co-authored-by: David Peter <sharkdp@users.noreply.github.com> |
||
|
|
ae2cf91a36 |
[red-knot] Decorators and properties (#17017)
## Summary Add support for decorators on function as well as support for properties by adding special handling for `@property` and `@<name of property>.setter`/`.getter` decorators. closes https://github.com/astral-sh/ruff/issues/16987 ## Ecosystem results - ✔️ A lot of false positives are fixed by our new understanding of properties - 🔴 A bunch of new false positives (typically `possibly-unbound-attribute` or `invalid-argument-type`) occur because we currently do not perform type narrowing on attributes. And with the new understanding of properties, this becomes even more relevant. In many cases, the narrowing occurs through an assertion, so this is also something that we need to implement to get rid of these false positives. - 🔴 A few new false positives occur because we do not understand generics, and therefore some calls to custom setters fail. - 🔴 Similarly, some false positives occur because we do not understand protocols yet. - ✔️ Seems like a true positive to me. [The setter]( |
||
|
|
eb3e176309 |
[red-knot] Add callable subtyping for callable instances and bound methods (#17105)
## Summary Trying to improve #17005 Partially fixes #16953 ## Test Plan Update is_subtype_of.md --------- Co-authored-by: Carl Meyer <carl@astral.sh> |
||
|
|
d38f6fcc55 |
[red-knot] Add property tests for callable types (#17006)
## Summary
Part of #15382, this PR adds property tests for callable types.
Specifically, this PR updates the property tests to generate an
arbitrary signature for a general callable type which includes:
* Arbitrary combination of parameter kinds in the correct order
* Arbitrary number of parameters
* Arbitrary optional types for annotation and return type
* Arbitrary parameter names (no duplicate names), optional for
positional-only parameters
## Test Plan
```
QUICKCHECK_TESTS=100000 cargo test -p red_knot_python_semantic -- --ignored types::property_tests::stable
```
Also, the commands in CI:
|
||
|
|
6be0a5057d |
[red-knot] Disjointness for callable types (#17094)
## Summary Part of #15382, this PR adds support for disjointness between two callable types. They are never disjoint because there exists a callable type that's a subtype of all other callable types: ```py (*args: object, **kwargs: object) -> Never ``` The `Never` is a subtype of every fully static type thus a callable type that has the return type of `Never` means that it is a subtype of every return type. ## Test Plan Add test cases related to mixed parameter kinds, gradual form (`...`) and `Never` type. |
||
|
|
d6dcc377f7 |
[red-knot] Flatten Type::Callable into four Type variants (#17126)
## Summary Currently our `Type::Callable` wraps a four-variant `CallableType` enum. But as time has gone on, I think we've found that the four variants in `CallableType` are really more different to each other than they are similar to each other: - `GeneralCallableType` is a structural type describing all callable types with a certain signature, but the other three types are "literal types", more similar to the `FunctionLiteral` variant - `GeneralCallableType` is not a singleton or a single-valued type, but the other three are all single-valued types (`WrapperDescriptorDunderGet` is even a singleton type) - `GeneralCallableType` has (or should have) ambiguous truthiness, but all possible inhabitants of the other three types are always truthy. - As a structural type, `GeneralCallableType` can contain inner unions and intersections that must be sorted in some contexts in our internal model, but this is not true for the other three variants. This PR flattens `Type::Callable` into four distinct `Type::` variants. In the process, it fixes a number of latent bugs that were concealed by the current architecture but are laid bare by the refactor. Unit tests for these bugs are included in the PR. |
||
|
|
d29d4956de |
[red-knot] Fix callable subtyping for standard parameters (#17125)
## Summary This PR fixes a bug in callable subtyping to consider both the positional and keyword form of the standard parameter in the supertype when matching against variadic, keyword-only and keyword-variadic parameter in the subtype. This is done by collecting the unmatched standard parameters and then checking them against the keyword-only / keyword-variadic parameters after the positional loop. ## Test Plan Add test cases. |
||
|
|
c74ba00219 |
[red-knot] Fix more redundant-cast false positives (#17119)
## Summary
There are quite a few places we infer `Todo` types currently, and some
of them are nested somewhat deeply in type expressions. These can cause
spurious issues for the new `redundant-cast` diagnostics. We fixed all
the false positives we saw in the mypy_primer report before merging
https://github.com/astral-sh/ruff/pull/17100, but I think there are
still lots of places where we'd emit false positives due to this check
-- we currently don't run on that many projects at all in our
mypy_primer check:
|
||
|
|
3f63c08728 |
[red-knot] support Any as a class in typeshed (#17107)
## Summary In https://github.com/python/typeshed/pull/13520 the typeshed definition of `typing.Any` was changed from `Any = object()` to `class Any: ...`. Our automated typeshed updater pulled down this change in https://github.com/astral-sh/ruff/pull/17106, with the consequence that we no longer understand `Any`, which is... not good. This PR gives us the ability to understand `Any` defined as a class instead of `object()`. It doesn't remove our ability to understand the old form. Perhaps at some point we'll want to remove it, but for now we may as well support both old and new typeshed? This also directly patches typeshed to use the new form of `Any`; this is purely to work around our tests that no known class is inferred as `Unknown`, which otherwise fail with the old typeshed and the changes in this PR. (All other tests pass.) This patch to typeshed will shortly be subsumed by https://github.com/astral-sh/ruff/pull/17106 anyway. ## Test Plan Without the typeshed change in this PR, all tests pass except for the two `known_class_doesnt_fallback_to_unknown_unexpectedly_*` tests (so we still support the old form of defining `Any`). With the typeshed change in this PR, all tests pass, so we now support the new form in a way that is indistinguishable to our test suite from the old form. And indistinguishable to the ecosystem check: after rebasing https://github.com/astral-sh/ruff/pull/17106 on this PR, there's zero ecosystem impact. |
||
|
|
49c25993eb |
[red-knot] Don't infer Todo for quite so many tuple type expressions (#17116)
## Summary I noticed we were inferring `Todo` as the declared type for annotations such as `x: tuple[list[int], list[int]]`. This PR reworks our annotation parsing so that we instead infer `tuple[Todo, Todo]` for this annotation, which is quite a bit more precise. ## Test Plan Existing mdtest updated. |
||
|
|
53cfaaebc4 |
[red-knot] Add redundant-cast error (#17100)
## Summary Following up from earlier discussion on Discord, this PR adds logic to flag casts as redundant when the inferred type of the expression is the same as the target type. It should follow the semantics from [mypy](https://github.com/python/mypy/pull/1705). Example: ```python def f() -> int: return 10 # error: [redundant-cast] "Value is already of type `int`" cast(int, f()) ``` |
||
|
|
3ad123bc23 |
[red-knot] Narrowing on in tuple[...] and in str (#17059)
## Summary Part of #13694 Seems there a bit more to cover regarding `in` and other types, but i can cover them in different PRs ## Test Plan Add `in.md` file in narrowing conditionals folder --------- Co-authored-by: Carl Meyer <carl@astral.sh> |
||
|
|
a1535fbdbd |
[red-knot] Change venv discovery (#17099)
## Summary Rewrites the virtual env discovery to: * Only use of `System` APIs, this ensures that the discovery will also work when using a memory file system (testing or WASM) * Don't traverse ancestor directories. We're not convinced that this is necessary. Let's wait until someone shows us a use case where it is needed * Start from the project root and not from the current working directory. This ensures that Red Knot picks up the right venv even when using `knot --project ../other-dir` ## Test Plan Existing tests, @ntBre tested that the `file_watching` tests no longer pick up his virtual env in a parent directory |
||
|
|
4a6fa5fc27 |
[red-knot] Add assignability of function literals to callables (#17095)
## Summary Part of #16953 ## Test Plan Update is_assignable_to.md --------- Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com> |
||
|
|
2d7f118f52 |
[red-knot] Binary operator inference: generalize code for non-instances (#17081)
## Summary Generalize the rich-comparison fallback code for binary operator inference. This gets rid of one `todo_type!(…)` and implements the last remaining failing case from https://github.com/astral-sh/ruff/issues/14200. closes https://github.com/astral-sh/ruff/issues/14200 ## Test Plan New Markdown tests. |
||
|
|
3d1e5676fb |
[red-knot] Add ParamSpecArgs and ParamSpecKwargs as KnownClass (#17086)
## Summary In preparation for #17017, where we will need them to suppress new false positives (once we understand the `ParamSpec.args`/`ParamSpec.kwargs` properties). ## Test Plan Tested on branch #17017 |
||
|
|
d9616e61b0 |
[red-knot] Disallow todo_type! without custom message (#17083)
## Summary Disallow empty `todo_type!()`s without a custom message. They can lead to spurious diffs in `mypy_primer` where the only thing that's changed is the file/line information. |
||
|
|
a192d96880 |
Update pre-commit dependencies (#17073)
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [abravalheri/validate-pyproject](https://redirect.github.com/abravalheri/validate-pyproject) | repository | patch | `v0.24` -> `v0.24.1` | | [astral-sh/ruff-pre-commit](https://redirect.github.com/astral-sh/ruff-pre-commit) | repository | patch | `v0.11.0` -> `v0.11.2` | | [crate-ci/typos](https://redirect.github.com/crate-ci/typos) | repository | minor | `v1.30.2` -> `v1.31.0` | | [python-jsonschema/check-jsonschema](https://redirect.github.com/python-jsonschema/check-jsonschema) | repository | minor | `0.31.3` -> `0.32.1` | | [woodruffw/zizmor-pre-commit](https://redirect.github.com/woodruffw/zizmor-pre-commit) | repository | patch | `v1.5.1` -> `v1.5.2` | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. Note: The `pre-commit` manager in Renovate is not supported by the `pre-commit` maintainers or community. Please do not report any problems there, instead [create a Discussion in the Renovate repository](https://redirect.github.com/renovatebot/renovate/discussions/new) if you have any questions. --- ### Release Notes <details> <summary>abravalheri/validate-pyproject (abravalheri/validate-pyproject)</summary> ### [`v0.24.1`](https://redirect.github.com/abravalheri/validate-pyproject/releases/tag/v0.24.1) [Compare Source](https://redirect.github.com/abravalheri/validate-pyproject/compare/v0.24...v0.24.1) #### What's Changed - Fixed multi plugin id was read from the wrong place by [@​henryiii](https://redirect.github.com/henryiii) in [https://github.com/abravalheri/validate-pyproject/pull/240](https://redirect.github.com/abravalheri/validate-pyproject/pull/240) - Implemented alternative plugin sorting, [https://github.com/abravalheri/validate-pyproject/pull/243](https://redirect.github.com/abravalheri/validate-pyproject/pull/243) **Full Changelog**: https://github.com/abravalheri/validate-pyproject/compare/v0.24...v0.24.1 </details> <details> <summary>astral-sh/ruff-pre-commit (astral-sh/ruff-pre-commit)</summary> ### [`v0.11.2`](https://redirect.github.com/astral-sh/ruff-pre-commit/releases/tag/v0.11.2) [Compare Source](https://redirect.github.com/astral-sh/ruff-pre-commit/compare/v0.11.1...v0.11.2) See: https://github.com/astral-sh/ruff/releases/tag/0.11.2 ### [`v0.11.1`](https://redirect.github.com/astral-sh/ruff-pre-commit/releases/tag/v0.11.1) [Compare Source](https://redirect.github.com/astral-sh/ruff-pre-commit/compare/v0.11.0...v0.11.1) See: https://github.com/astral-sh/ruff/releases/tag/0.11.1 </details> <details> <summary>crate-ci/typos (crate-ci/typos)</summary> ### [`v1.31.0`](https://redirect.github.com/crate-ci/typos/releases/tag/v1.31.0) [Compare Source](https://redirect.github.com/crate-ci/typos/compare/v1.30.3...v1.31.0) #### \[1.31.0] - 2025-03-28 ##### Features - Updated the dictionary with the [March 2025](https://redirect.github.com/crate-ci/typos/issues/1266) changes ### [`v1.30.3`](https://redirect.github.com/crate-ci/typos/releases/tag/v1.30.3) [Compare Source](https://redirect.github.com/crate-ci/typos/compare/v1.30.2...v1.30.3) #### \[1.30.3] - 2025-03-24 ##### Features - Support detecting `go.work` and `go.work.sum` files </details> <details> <summary>python-jsonschema/check-jsonschema (python-jsonschema/check-jsonschema)</summary> ### [`v0.32.1`](https://redirect.github.com/python-jsonschema/check-jsonschema/blob/HEAD/CHANGELOG.rst#0321) [Compare Source](https://redirect.github.com/python-jsonschema/check-jsonschema/compare/0.32.0...0.32.1) - Fix the `check-meltano` hook to use `types_or`. Thanks :user:`edgarrmondragon`! (:pr:`543`) ### [`v0.32.0`](https://redirect.github.com/python-jsonschema/check-jsonschema/blob/HEAD/CHANGELOG.rst#0320) [Compare Source](https://redirect.github.com/python-jsonschema/check-jsonschema/compare/0.31.3...0.32.0) - Update vendored schemas: circle-ci, compose-spec, dependabot, github-workflows, gitlab-ci, mergify, renovate, taskfile (2025-03-25) - Add Meltano schema and pre-commit hook. Thanks :user:`edgarrmondragon`! (:issue:`540`) - Add Snapcraft schema and pre-commit hook. Thanks :user:`fabolhak`! (:issue:`535`) </details> <details> <summary>woodruffw/zizmor-pre-commit (woodruffw/zizmor-pre-commit)</summary> ### [`v1.5.2`](https://redirect.github.com/woodruffw/zizmor-pre-commit/releases/tag/v1.5.2) [Compare Source](https://redirect.github.com/woodruffw/zizmor-pre-commit/compare/v1.5.1...v1.5.2) See: https://github.com/woodruffw/zizmor/releases/tag/v1.5.2 </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. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- 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:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMDcuMSIsInVwZGF0ZWRJblZlciI6IjM5LjIwNy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJpbnRlcm5hbCJdfQ==--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Micha Reiser <micha@reiser.io> |
||
|
|
5c1fab0661 |
Fix member lookup for unions & intersections ignoring policy (#17066)
## Summary A quick fix for how union/intersection member search ins performed in Knot. ## Test Plan * Added a dunder method call test for Union, which exhibits the error * Also added an intersection error, but it is not triggering currently due to `call` logic not being fully implemented for intersections. --------- Co-authored-by: David Peter <mail@david-peter.de> |
||
|
|
c6efa93cf7 |
[red-knot] Handle special case returning NotImplemented (#17034)
## Summary Closes #16661 This PR includes two changes: - `NotImplementedType` is now a member of `KnownClass` - We skip `is_assignable_to` checks for `NotImplemented` when checking return types ### Limitation ```py def f(cond: bool) -> int: return 1 if cond else NotImplemented ``` The implementation covers cases where `NotImplemented` appears inside a `Union`. However, for more complex types (ex. `Intersection`) it will not worked. In my opinion, supporting such complexity is unnecessary at this point. ## Test Plan Two `mdtest` files were updated: - `mdtest/function/return_type.md` - `mdtest/type_properties/is_singleton.md` To test `KnownClass`, run: ```bash cargo test -p red_knot_python_semantic -- types::class:: ``` |
||
|
|
93052331b0 |
[red-knot] Allow CallableTypeFromFunction to display the signatures of callable types that are not function literals (#17047)
I found this helpful for understanding some of the stuff that was going on in https://github.com/astral-sh/ruff/pull/17005. |
||
|
|
78b0b5a3ab |
[red-knot] Factor out shared unpacking logic (#16595)
## Summary This PR refactors the common logic for unpacking in assignment, for loops, and with items. ## Test Plan Make sure existing tests pass. --------- Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com> |
||
|
|
0e48940ea4 |
[red-knot] Discover local venv folder in cli (#16917)
<!--
Thank you for contributing to Ruff! 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?
- Does this pull request include references to any relevant issues?
-->
## Summary
Fixes #16744
Code from
|
||
|
|
aca6254e82 |
[red-knot] fix eager nested scopes handling (#16916)
## Summary From #16861, and the continuation of #16915. This PR fixes the incorrect behavior of `TypeInferenceBuilder::infer_name_load` in eager nested scopes. And this PR closes #16341. ## Test Plan New test cases are added in `annotations/deferred.md`. |
||
|
|
64171744dc |
[red-knot] support narrowing on or patterns in matches (#17030)
## Summary Part of #13694 Narrow in or-patterns by taking the type union of the type constraints in each disjunct pattern. ## Test Plan Add new tests to narrow/match.md --------- Co-authored-by: Carl Meyer <carl@astral.sh> |
||
|
|
3acf4e716d |
[red-knot] support narrowing on constants in matches (#16974)
## Summary Part of #13694 The implementation here was suspiciously straightforward so please lmk if I missed something Also some drive-by changes to DRY things up a bit ## Test Plan Add new tests to narrow/match.md --------- Co-authored-by: Carl Meyer <carl@astral.sh> |
||
|
|
992a1af4c2 |
[red-knot] Reduce false positives on super() and enum-class attribute accesses (#17004)
## Summary This PR adds some branches so that we infer `Todo` types for attribute access on instances of `super()` and subtypes of `type[Enum]`. It reduces false positives in the short term until we implement full support for these features. ## Test Plan New mdtests added + mypy_primer report |
||
|
|
b9a7328789 |
[red-knot] Make every type a subtype of object (#16960)
## Summary Mainly for partially fixing #16953 ## Test Plan Update is_subtype tests. And should maybe do these checks for many other types (is subtype of object but object is not subtype) --------- Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com> |
||
|
|
aae4d0f3eb |
[red-knot] A FunctionType can be a subtype of Callable (but never the other way around) (#16970)
## Summary Partially fixes #16953 ## Test Plan Update is_subtype_of.md --------- Co-authored-by: Carl Meyer <carl@astral.sh> |
||
|
|
4975c2f027 |
[red-knot] Fix panic on cyclic * imports (#16958)
## Summary Further work towards https://github.com/astral-sh/ruff/issues/14169. We currently panic on encountering cyclic `*` imports. This is easily fixed using fixpoint iteration. ## Test Plan Added a test that panics on `main`, but passes with this PR |
||
|
|
dd5b02aaa2 |
[red-knot] Fix gradual equivalence for callable types (#16887)
## Summary As mentioned in https://github.com/astral-sh/ruff/pull/16698#discussion_r2004920075, part of #15382, this PR updates the `is_gradual_equivalent_to` implementation between callable types to be similar to `is_equivalent_to` and checks other attributes of parameters like name, optionality, and parameter kind. ## Test Plan Expand the existing test cases to consider other properties but not all similar to how the tests are structured for subtyping and assignability. |
||
|
|
68ea2b8b5b |
[red-knot] simplify "removing" in UnionBuilder::add (#16947)
## Summary Simplify "removing" in UnionBuilder::add It's now O(m) instead of O(n + m) and easier to read. ## Test Plan cargo test (incl. mdtest) |
||
|
|
e87fee4b3b |
[red-knot] Add initial support for * imports (#16923)
## Summary
This PR adds initial support for `*` imports to red-knot. The approach
is to implement a standalone query, called from semantic indexing, that
visits the module referenced by the `*` import and collects all
global-scope public names that will be imported by the `*` import. The
`SemanticIndexBuilder` then adds separate definitions for each of these
names, all keyed to the same `ast::Alias` node that represents the `*`
import.
There are many pieces of `*`-import semantics that are still yet to be
done, even with this PR:
- This PR does not attempt to implement any of the semantics to do with
`__all__`. (If a module defines `__all__`, then only the symbols
included in `__all__` are imported, _not_ all public global-scope
symbols.
- With the logic implemented in this PR as it currently stands, we
sometimes incorrectly consider a symbol bound even though it is defined
in a branch that is statically known to be dead code, e.g. (assuming the
target Python version is set to 3.11):
```py
# a.py
import sys
if sys.version_info < (3, 10):
class Foo: ...
```
```py
# b.py
from a import *
print(Foo) # this is unbound at runtime on 3.11,
# but we currently consider it bound with the logic in this PR
```
Implementing these features is important, but is for now deferred to
followup PRs.
Many thanks to @ntBre, who contributed to this PR in a pairing session
on Friday!
## Test Plan
Assertions in existing mdtests are adjusted, and several new ones are
added.
|