mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:14:52 +00:00
[ty] Sync vendored typeshed stubs (#20083)
Co-authored-by: typeshedbot <> Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
This commit is contained in:
parent
db423ee978
commit
ba47010150
84 changed files with 1733 additions and 846 deletions
|
@ -91,15 +91,15 @@ error[missing-argument]: No argument provided for required parameter `arg` of bo
|
|||
7 | from typing_extensions import deprecated
|
||||
|
|
||||
info: Parameter declared here
|
||||
--> stdlib/typing_extensions.pyi:973:28
|
||||
|
|
||||
971 | stacklevel: int
|
||||
972 | def __init__(self, message: LiteralString, /, *, category: type[Warning] | None = ..., stacklevel: int = 1) -> None: ...
|
||||
973 | def __call__(self, arg: _T, /) -> _T: ...
|
||||
| ^^^^^^^
|
||||
974 |
|
||||
975 | @final
|
||||
|
|
||||
--> stdlib/typing_extensions.pyi:1000:28
|
||||
|
|
||||
998 | stacklevel: int
|
||||
999 | def __init__(self, message: LiteralString, /, *, category: type[Warning] | None = ..., stacklevel: int = 1) -> None: ...
|
||||
1000 | def __call__(self, arg: _T, /) -> _T: ...
|
||||
| ^^^^^^^
|
||||
1001 |
|
||||
1002 | @final
|
||||
|
|
||||
info: rule `missing-argument` is enabled by default
|
||||
|
||||
```
|
||||
|
|
|
@ -26,14 +26,13 @@ error[invalid-await]: `Literal[1]` is not awaitable
|
|||
2 | await 1 # error: [invalid-await]
|
||||
| ^
|
||||
|
|
||||
::: stdlib/builtins.pyi:337:7
|
||||
::: stdlib/builtins.pyi:344:7
|
||||
|
|
||||
335 | _LiteralInteger = _PositiveInteger | _NegativeInteger | Literal[0] # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed
|
||||
336 |
|
||||
337 | class int:
|
||||
343 | @disjoint_base
|
||||
344 | class int:
|
||||
| --- type defined here
|
||||
338 | """int([x]) -> integer
|
||||
339 | int(x, base=10) -> integer
|
||||
345 | """int([x]) -> integer
|
||||
346 | int(x, base=10) -> integer
|
||||
|
|
||||
info: `__await__` is missing
|
||||
info: rule `invalid-await` is enabled by default
|
||||
|
|
|
@ -1409,7 +1409,12 @@ mod implicit_globals {
|
|||
/// Conceptually this function could be a `Set` rather than a list,
|
||||
/// but the number of symbols declared in this scope is likely to be very small,
|
||||
/// so the cost of hashing the names is likely to be more expensive than it's worth.
|
||||
#[salsa::tracked(returns(deref), heap_size=ruff_memory_usage::heap_size)]
|
||||
#[salsa::tracked(
|
||||
returns(deref),
|
||||
cycle_initial=module_type_symbols_initial,
|
||||
cycle_fn=module_type_symbols_cycle_recover,
|
||||
heap_size=ruff_memory_usage::heap_size
|
||||
)]
|
||||
fn module_type_symbols<'db>(db: &'db dyn Db) -> smallvec::SmallVec<[ast::name::Name; 8]> {
|
||||
let Some(module_type) = KnownClass::ModuleType
|
||||
.to_class_literal(db)
|
||||
|
@ -1437,6 +1442,18 @@ mod implicit_globals {
|
|||
.collect()
|
||||
}
|
||||
|
||||
fn module_type_symbols_initial(_db: &dyn Db) -> smallvec::SmallVec<[ast::name::Name; 8]> {
|
||||
smallvec::SmallVec::default()
|
||||
}
|
||||
|
||||
fn module_type_symbols_cycle_recover(
|
||||
_db: &dyn Db,
|
||||
_value: &smallvec::SmallVec<[ast::name::Name; 8]>,
|
||||
_count: u32,
|
||||
) -> salsa::CycleRecoveryAction<smallvec::SmallVec<[ast::name::Name; 8]>> {
|
||||
salsa::CycleRecoveryAction::Iterate
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -11726,6 +11726,14 @@ mod tests {
|
|||
fn unbound_symbol_no_reachability_constraint_check() {
|
||||
let mut db = setup_db();
|
||||
|
||||
// First, type-check a random other file so that we cache a result for the `module_type_symbols`
|
||||
// query (which often encounters cycles due to `types.pyi` importing `typing_extensions` and
|
||||
// `typing_extensions.pyi` importing `types`). Clear the events afterwards so that unrelated
|
||||
// cycles from that query don't interfere with our test.
|
||||
db.write_dedented("src/wherever.py", "print(x)").unwrap();
|
||||
assert_file_diagnostics(&db, "src/wherever.py", &["Name `x` used when not defined"]);
|
||||
db.clear_salsa_events();
|
||||
|
||||
// If the bug we are testing for is not fixed, what happens is that when inferring the
|
||||
// `flag: bool = True` definitions, we look up `bool` as a deferred name (thus from end of
|
||||
// scope), and because of the early return its "unbound" binding has a reachability
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue