-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly support runtime annotations
- Loading branch information
1 parent
f8ee1df
commit b19e86e
Showing
14 changed files
with
531 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
crates/ruff_linter/src/rules/flake8_type_checking/imports.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use ruff_python_semantic::{AnyImport, Binding, ResolvedReferenceId}; | ||
use ruff_text_size::{Ranged, TextRange}; | ||
|
||
/// An import with its surrounding context. | ||
pub(crate) struct ImportBinding<'a> { | ||
/// The qualified name of the import (e.g., `typing.List` for `from typing import List`). | ||
pub(crate) import: AnyImport<'a>, | ||
/// The binding for the imported symbol. | ||
pub(crate) binding: &'a Binding<'a>, | ||
/// The first reference to the imported symbol. | ||
pub(crate) reference_id: ResolvedReferenceId, | ||
/// The trimmed range of the import (e.g., `List` in `from typing import List`). | ||
pub(crate) range: TextRange, | ||
/// The range of the import's parent statement. | ||
pub(crate) parent_range: Option<TextRange>, | ||
} | ||
|
||
impl Ranged for ImportBinding<'_> { | ||
fn range(&self) -> TextRange { | ||
self.range | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.