Harmonise methods for distinguishing different Python source types (#13682)

This commit is contained in:
Alex Waygood 2024-10-09 14:18:52 +01:00 committed by GitHub
parent b9827a4122
commit 5b4afd30ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 40 additions and 53 deletions

View file

@ -5,8 +5,7 @@ use rustc_hash::FxHashMap;
use ruff_python_ast::helpers::from_relative_import;
use ruff_python_ast::name::{QualifiedName, UnqualifiedName};
use ruff_python_ast::{self as ast, Expr, ExprContext, Operator, Stmt};
use ruff_python_stdlib::path::is_python_stub_file;
use ruff_python_ast::{self as ast, Expr, ExprContext, Operator, PySourceType, Stmt};
use ruff_text_size::{Ranged, TextRange, TextSize};
use crate::binding::{
@ -2246,7 +2245,7 @@ bitflags! {
impl SemanticModelFlags {
pub fn new(path: &Path) -> Self {
if is_python_stub_file(path) {
if PySourceType::from(path).is_stub() {
Self::STUB_FILE
} else {
Self::default()