Refactor range from Attributed to Nodes (#4422)

This commit is contained in:
Micha Reiser 2023-05-16 08:36:32 +02:00 committed by GitHub
parent 140e0acf54
commit fa26860296
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
330 changed files with 4816 additions and 3946 deletions

View file

@ -1,6 +1,6 @@
use std::path::Path;
use rustpython_parser::ast::{self, Expr, Stmt, StmtKind};
use rustpython_parser::ast::{self, Expr, Stmt};
use ruff_python_ast::call_path::{collect_call_path, CallPath};
use ruff_python_ast::helpers::map_callable;
@ -164,9 +164,9 @@ impl ModuleSource<'_> {
}
pub(crate) fn function_visibility(stmt: &Stmt) -> Visibility {
match &stmt.node {
StmtKind::FunctionDef(ast::StmtFunctionDef { name, .. })
| StmtKind::AsyncFunctionDef(ast::StmtAsyncFunctionDef { name, .. }) => {
match stmt {
Stmt::FunctionDef(ast::StmtFunctionDef { name, .. })
| Stmt::AsyncFunctionDef(ast::StmtAsyncFunctionDef { name, .. }) => {
if name.starts_with('_') {
Visibility::Private
} else {
@ -178,13 +178,13 @@ pub(crate) fn function_visibility(stmt: &Stmt) -> Visibility {
}
pub(crate) fn method_visibility(stmt: &Stmt) -> Visibility {
match &stmt.node {
StmtKind::FunctionDef(ast::StmtFunctionDef {
match stmt {
Stmt::FunctionDef(ast::StmtFunctionDef {
name,
decorator_list,
..
})
| StmtKind::AsyncFunctionDef(ast::StmtAsyncFunctionDef {
| Stmt::AsyncFunctionDef(ast::StmtAsyncFunctionDef {
name,
decorator_list,
..
@ -216,8 +216,8 @@ pub(crate) fn method_visibility(stmt: &Stmt) -> Visibility {
}
pub(crate) fn class_visibility(stmt: &Stmt) -> Visibility {
match &stmt.node {
StmtKind::ClassDef(ast::StmtClassDef { name, .. }) => {
match stmt {
Stmt::ClassDef(ast::StmtClassDef { name, .. }) => {
if name.starts_with('_') {
Visibility::Private
} else {