mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-18 17:40:37 +00:00
Misc. small tweaks from perusing modules (#9383)
This commit is contained in:
parent
7b6baff734
commit
0e202718fd
4 changed files with 10 additions and 5 deletions
|
@ -68,6 +68,7 @@ impl Rule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Linter {
|
impl Linter {
|
||||||
pub const fn upstream_categories(&self) -> Option<&'static [UpstreamCategoryAndPrefix]> {
|
pub const fn upstream_categories(&self) -> Option<&'static [UpstreamCategoryAndPrefix]> {
|
||||||
match self {
|
match self {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
use bitflags::bitflags;
|
||||||
|
|
||||||
use crate::helpers::map_subscript;
|
use crate::helpers::map_subscript;
|
||||||
use crate::{self as ast, Expr, Stmt};
|
use crate::{self as ast, Expr, Stmt};
|
||||||
use bitflags::bitflags;
|
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
|
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
use crate::{ElifElseClause, Expr, Stmt, StmtIf};
|
use std::iter;
|
||||||
|
|
||||||
use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer};
|
use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer};
|
||||||
use ruff_text_size::{Ranged, TextRange};
|
use ruff_text_size::{Ranged, TextRange};
|
||||||
use std::iter;
|
|
||||||
|
use crate::{ElifElseClause, Expr, Stmt, StmtIf};
|
||||||
|
|
||||||
/// Return the `Range` of the first `Elif` or `Else` token in an `If` statement.
|
/// Return the `Range` of the first `Elif` or `Else` token in an `If` statement.
|
||||||
pub fn elif_else_range(clause: &ElifElseClause, contents: &str) -> Option<TextRange> {
|
pub fn elif_else_range(clause: &ElifElseClause, contents: &str) -> Option<TextRange> {
|
||||||
|
@ -17,11 +19,12 @@ pub enum BranchKind {
|
||||||
Elif,
|
Elif,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct IfElifBranch<'a> {
|
pub struct IfElifBranch<'a> {
|
||||||
pub kind: BranchKind,
|
pub kind: BranchKind,
|
||||||
pub test: &'a Expr,
|
pub test: &'a Expr,
|
||||||
pub body: &'a [Stmt],
|
pub body: &'a [Stmt],
|
||||||
pub range: TextRange,
|
range: TextRange,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ranged for IfElifBranch<'_> {
|
impl Ranged for IfElifBranch<'_> {
|
||||||
|
|
|
@ -265,8 +265,8 @@ impl<'a> Deref for Definitions<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoIterator for Definitions<'a> {
|
impl<'a> IntoIterator for Definitions<'a> {
|
||||||
type IntoIter = std::vec::IntoIter<Self::Item>;
|
|
||||||
type Item = Definition<'a>;
|
type Item = Definition<'a>;
|
||||||
|
type IntoIter = std::vec::IntoIter<Self::Item>;
|
||||||
|
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
self.0.into_iter()
|
self.0.into_iter()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue