Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions crates/codegen/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1752,15 +1752,13 @@ impl<'warnings> Compiler<'warnings> {

// Check if __class__ is available as a cell/free variable
// The scope must be Free (from enclosing class) or have DEF_FREE_CLASS flag
if let Some(symbol) = table.lookup("__class__") {
{
let symbol = table.lookup("__class__")?;
if symbol.scope != SymbolScope::Free
&& !symbol.flags.contains(SymbolFlags::DEF_FREE_CLASS)
{
return None;
}
} else {
// __class__ not in symbol table, optimization not possible
return None;
}

Some(SuperCallType::ZeroArg)
Expand Down Expand Up @@ -8260,12 +8258,7 @@ impl<'warnings> Compiler<'warnings> {
self.compile_name(id, NameUsage::Load)?;
AugAssignKind::Name { id }
}
ast::Expr::Subscript(ast::ExprSubscript {
value,
slice,
ctx: _,
..
}) => {
ast::Expr::Subscript(ast::ExprSubscript { value, slice, .. }) => {
let use_slice_opt = self.should_apply_two_element_slice_optimization(slice);
self.compile_expression(value)?;
self.set_source_range(target_range);
Expand Down Expand Up @@ -9225,14 +9218,7 @@ impl<'warnings> Compiler<'warnings> {
let ast::Expr::Name(ast::ExprName { id, .. }) = func else {
return None;
};
let [
ast::Expr::Generator(ast::ExprGenerator {
elt: _,
generators: _,
..
}),
] = &args.args[..]
else {
let [ast::Expr::Generator(ast::ExprGenerator { .. })] = &args.args[..] else {
return None;
};
if !args.keywords.is_empty() || {
Expand Down
100 changes: 17 additions & 83 deletions crates/codegen/src/symboltable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,6 @@ impl SymbolTableBuilder {
decorator_list,
type_params,
range,
node_index: _,
..
}) => {
let prev_class = self.class_name.clone();
Expand Down Expand Up @@ -1819,7 +1818,6 @@ impl SymbolTableBuilder {
value,
simple,
range,
node_index: _,
..
}) => {
self.tables.last_mut().unwrap().annotations_used = true;
Expand Down Expand Up @@ -2141,35 +2139,20 @@ impl SymbolTableBuilder {
}

match expression {
Expr::BinOp(ExprBinOp {
left,
right,
range: _,
..
}) => {
Expr::BinOp(ExprBinOp { left, right, .. }) => {
self.scan_expression(left, context)?;
self.scan_expression(right, context)?;
}
Expr::BoolOp(ExprBoolOp {
values, range: _, ..
}) => {
Expr::BoolOp(ExprBoolOp { values, .. }) => {
self.scan_expressions(values, context)?;
}
Expr::Compare(ExprCompare {
left,
comparators,
range: _,
..
left, comparators, ..
}) => {
self.scan_expression(left, context)?;
self.scan_expressions(comparators, context)?;
}
Expr::Subscript(ExprSubscript {
value,
slice,
range: _,
..
}) => {
Expr::Subscript(ExprSubscript { value, slice, .. }) => {
self.scan_expression(value, ExpressionContext::Load)?;
self.scan_expression(slice, ExpressionContext::Load)?;
}
Expand All @@ -2179,12 +2162,7 @@ impl SymbolTableBuilder {
self.check_name(attr.as_str(), context, *range)?;
self.scan_expression(value, ExpressionContext::Load)?;
}
Expr::Dict(ExprDict {
items,
node_index: _,
range: _,
..
}) => {
Expr::Dict(ExprDict { items, .. }) => {
for item in items {
if let Some(key) = &item.key {
self.scan_expression(key, context)?;
Expand All @@ -2194,12 +2172,7 @@ impl SymbolTableBuilder {
self.scan_expression(&item.value, context)?;
}
}
Expr::Await(ExprAwait {
value,
node_index: _,
range: _,
..
}) => {
Expr::Await(ExprAwait { value, .. }) => {
let current_scope = self.tables.last().unwrap().typ;
if !self.allows_top_level_await()
&& !Self::is_function_like_scope(current_scope)
Expand Down Expand Up @@ -2227,12 +2200,7 @@ impl SymbolTableBuilder {
self.scan_expression(value, context)?;
self.tables.last_mut().unwrap().is_coroutine = true;
}
Expr::Yield(ExprYield {
value,
node_index: _,
range: _,
..
}) => {
Expr::Yield(ExprYield { value, .. }) => {
if let Some(expression) = value {
self.scan_expression(expression, context)?;
}
Expand All @@ -2252,12 +2220,7 @@ impl SymbolTableBuilder {
});
}
}
Expr::YieldFrom(ExprYieldFrom {
value,
node_index: _,
range: _,
..
}) => {
Expr::YieldFrom(ExprYieldFrom { value, .. }) => {
self.scan_expression(value, context)?;
self.tables.last_mut().unwrap().is_generator = true;
if let Some(context_name) = self.comprehension_yield_context
Expand All @@ -2275,28 +2238,19 @@ impl SymbolTableBuilder {
});
}
}
Expr::UnaryOp(ExprUnaryOp {
operand, range: _, ..
}) => {
Expr::UnaryOp(ExprUnaryOp { operand, .. }) => {
self.scan_expression(operand, context)?;
}
Expr::Starred(ExprStarred {
value, range: _, ..
}) => {
Expr::Starred(ExprStarred { value, .. }) => {
self.scan_expression(value, context)?;
}
Expr::Tuple(ExprTuple { elts, range: _, .. })
| Expr::Set(ExprSet { elts, range: _, .. })
| Expr::List(ExprList { elts, range: _, .. }) => {
Expr::Tuple(ExprTuple { elts, .. })
| Expr::Set(ExprSet { elts, .. })
| Expr::List(ExprList { elts, .. }) => {
self.scan_expressions(elts, context)?;
}
Expr::Slice(ExprSlice {
lower,
upper,
step,
node_index: _,
range: _,
..
lower, upper, step, ..
}) => {
if let Some(lower) = lower {
self.scan_expression(lower, context)?;
Expand Down Expand Up @@ -2326,7 +2280,6 @@ impl SymbolTableBuilder {
elt,
generators,
range,
node_index: _,
..
}) => {
let was_in_iter_def_exp = self.in_iter_def_exp;
Expand All @@ -2341,7 +2294,6 @@ impl SymbolTableBuilder {
elt,
generators,
range,
node_index: _,
..
}) => {
let was_in_iter_def_exp = self.in_iter_def_exp;
Expand All @@ -2357,7 +2309,6 @@ impl SymbolTableBuilder {
value,
generators,
range,
node_index: _,
..
}) => {
let was_in_iter_def_exp = self.in_iter_def_exp;
Expand All @@ -2377,11 +2328,7 @@ impl SymbolTableBuilder {
self.in_iter_def_exp = was_in_iter_def_exp;
}
Expr::Call(ExprCall {
func,
arguments,
node_index: _,
range: _,
..
func, arguments, ..
}) => {
match context {
ExpressionContext::IterDefinitionExp => {
Expand Down Expand Up @@ -2438,11 +2385,7 @@ impl SymbolTableBuilder {
}
}
Expr::Lambda(ExprLambda {
body,
parameters,
node_index: _,
range: _,
..
body, parameters, ..
}) => {
let was_in_iter_def_exp = self.in_iter_def_exp;
if let Some(parameters) = parameters {
Expand Down Expand Up @@ -2535,12 +2478,7 @@ impl SymbolTableBuilder {
});
}
Expr::If(ExprIf {
test,
body,
orelse,
node_index: _,
range: _,
..
test, body, orelse, ..
}) => {
self.scan_expression(test, ExpressionContext::Load)?;
self.scan_expression(body, ExpressionContext::Load)?;
Expand All @@ -2551,7 +2489,6 @@ impl SymbolTableBuilder {
target,
value,
range,
node_index: _,
..
}) => {
// named expressions are not allowed in the definition of
Expand Down Expand Up @@ -2777,7 +2714,6 @@ impl SymbolTableBuilder {
bound,
range: type_var_range,
default,
node_index: _,
..
}) => {
self.register_name(name.as_str(), SymbolUsage::TypeParam, *type_var_range)?;
Expand Down Expand Up @@ -2821,7 +2757,6 @@ impl SymbolTableBuilder {
name,
range: param_spec_range,
default,
node_index: _,
..
}) => {
self.register_name(name, SymbolUsage::TypeParam, *param_spec_range)?;
Expand Down Expand Up @@ -2850,7 +2785,6 @@ impl SymbolTableBuilder {
name,
range: type_var_tuple_range,
default,
node_index: _,
..
}) => {
self.register_name(name, SymbolUsage::TypeParam, *type_var_tuple_range)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/derive-impl/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl ItemNursery {
if !inserted {
return Err(syn::Error::new(
item.attr_name.span(),
format!("Duplicated #[py*] attribute found for {:?}", &item.py_names),
format!("Duplicated #[py*] attribute found for {:?}", item.py_names),
));
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/host_env/src/fileutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ pub unsafe fn fclose(fp: *mut CFile) -> core::ffi::c_int {
// _Py_fopen_obj in cpython (Python/fileutils.c:1757-1835)
// Open a file using std::fs::File and convert to FILE*
// Automatically handles path encoding and EINTR retries
#[expect(
clippy::std_instead_of_core,
reason = "false positive: core::io::ErrorKind is unstable (core_io)"
)]
pub fn fopen(path: &std::path::Path, mode: &str) -> std::io::Result<*mut CFile> {
use alloc::ffi::CString;
use std::fs::File;
Expand Down
8 changes: 8 additions & 0 deletions crates/host_env/src/posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ pub fn fchown(fd: BorrowedFd<'_>, uid: Option<u32>, gid: Option<u32>) -> std::io
}

#[cfg(not(windows))]
#[expect(
clippy::std_instead_of_core,
reason = "false positive: core::io::ErrorKind is unstable (core_io)"
)]
pub fn stat_path(
path: &OsStr,
dir_fd: Option<i32>,
Expand Down Expand Up @@ -1431,6 +1435,10 @@ fn build_posix_spawn_attrs(
target_os = "illumos",
target_os = "hurd",
)))]
#[expect(
clippy::std_instead_of_core,
reason = "false positive: core::io::ErrorKind is unstable (core_io); expect is co-gated with the usage so it is not left unfulfilled on platforms where this block is compiled out"
)]
{
return Err(std::io::Error::new(
std::io::ErrorKind::Unsupported,
Expand Down
2 changes: 1 addition & 1 deletion crates/stdlib/src/binascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ mod decl {
// there are a few uuencodes out there that use
// '`' as zero instead of space.
if !(b' '..=(b' ' + 64)).contains(&c) {
if [b'\r', b'\n'].contains(&c) {
if b"\r\n".contains(&c) {
return Ok(0);
}
return Err(super::new_binascii_error("Illegal char", vm));
Expand Down
3 changes: 3 additions & 0 deletions crates/stdlib/src/pyexpat.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! Pyexpat builtin module
// false positive: core::io::Cursor is unstable (core_io), unusable on stable
#![expect(clippy::std_instead_of_core)]

// spell-checker: ignore libexpat

pub(crate) use _pyexpat::module_def;
Expand Down
3 changes: 3 additions & 0 deletions crates/stdlib/src/ssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
//!
//! Warning: This library contains AI-generated code and comments. Do not trust any code or comment without verification. Please have a qualified expert review the code and remove this notice after review.
// false positive: core::io::{Cursor, ErrorKind} are unstable (core_io), unusable on stable
#![expect(clippy::std_instead_of_core)]

// OID (Object Identifier) management module
mod oid;

Expand Down
4 changes: 2 additions & 2 deletions crates/vm/src/builtins/builtin_func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl PyNativeFunction {
// m_self is an instance: use Py_TYPE(m_self).__qualname__
bound.class().name().to_string()
};
vm.ctx.new_str(format!("{}.{}", prefix, &zelf.value.name))
vm.ctx.new_str(format!("{}.{}", prefix, zelf.value.name))
} else {
vm.ctx.intern_str(zelf.value.name).to_owned()
};
Expand Down Expand Up @@ -220,7 +220,7 @@ impl fmt::Debug for PyNativeMethod {
f,
"builtin method of {:?} with {:?}",
&*self.class.name(),
&self.func
self.func
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/vm/src/builtins/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl PyMethodDescriptor {

#[pygetset]
fn __qualname__(&self) -> String {
format!("{}.{}", self.common.typ.name(), &self.common.name)
format!("{}.{}", self.common.typ.name(), self.common.name)
}

#[pygetset]
Expand Down Expand Up @@ -164,7 +164,7 @@ impl Representable for PyMethodDescriptor {
fn repr_str(zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<String> {
Ok(format!(
"<method '{}' of '{}' objects>",
&zelf.method.name,
zelf.method.name,
zelf.common.typ.name()
))
}
Expand Down
Loading
Loading