pub struct Import {
pub module: String,
pub relative_dots: u8,
pub names: Vec<String>,
pub bindings: Vec<String>,
pub is_star: bool,
pub type_checking_only: bool,
pub redundant: Vec<bool>,
pub in_try: bool,
pub line: u32,
pub end_line: u32,
}Expand description
An import / from ... import ... statement.
Fields§
§module: StringThe module path, e.g. os.path or mypkg.sub. Empty for relative dots
captured in relative_dots.
relative_dots: u8Number of leading dots in a relative import (from . import x -> 1).
names: Vec<String>Imported names (from m import a, b -> [a, b]). Empty for import m.
bindings: Vec<String>Local names this statement binds, honoring aliases: import a.b -> [a];
import a.b as c -> [c]; from m import x as y -> [y]. Empty for *.
is_star: boolTrue for from m import *.
type_checking_only: boolTrue if guarded by if TYPE_CHECKING: / if False: — a deliberate
type-only import that must never be flagged as unused.
redundant: Vec<bool>Per-binding: true when written with a redundant alias (import x as x,
from m import y as y) — the PEP 484 explicit re-export convention, so
the binding is public API even with zero in-module uses.
in_try: boolTrue if the statement sits in a try: body / except: handler, or a
module-level if/else arm — availability probes and platform
switches (try: import x / except: …, if flag: from y import z).
Removing a guarded arm changes behavior, so this is never a certain fix.
line: u32§end_line: u32Last line of the statement (inclusive) — multi-line from x import (…)
spans several lines, and a # noqa on any of them counts.
Trait Implementations§
impl Eq for Import
impl StructuralPartialEq for Import
Auto Trait Implementations§
impl Freeze for Import
impl RefUnwindSafe for Import
impl Send for Import
impl Sync for Import
impl Unpin for Import
impl UnsafeUnpin for Import
impl UnwindSafe for Import
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more