pub struct PypiDependency {
pub name: String,
pub name_range: Range,
pub version_req: Option<String>,
pub version_range: Option<Range>,
pub extras: Vec<String>,
pub extras_range: Option<Range>,
pub markers: Option<String>,
pub markers_range: Option<Range>,
pub section: PypiDependencySection,
pub source: PypiDependencySource,
}Expand description
Parsed dependency from pyproject.toml with position tracking.
Stores all information about a Python dependency declaration, including its name, version requirement, extras, environment markers, and source positions for LSP operations. Positions are critical for features like hover, completion, and inlay hints.
§Examples
use deps_pypi::types::{PypiDependency, PypiDependencySection, PypiDependencySource};
use tower_lsp_server::ls_types::{Position, Range};
let dep = PypiDependency {
name: "requests".into(),
name_range: Range::new(Position::new(5, 4), Position::new(5, 12)),
version_req: Some(">=2.28.0,<3.0".into()),
version_range: Some(Range::new(Position::new(5, 13), Position::new(5, 27))),
extras: vec!["security".into()],
extras_range: None,
markers: Some("python_version>='3.8'".into()),
markers_range: None,
section: PypiDependencySection::Dependencies,
source: PypiDependencySource::PyPI,
};
assert_eq!(dep.name, "requests");
assert!(matches!(dep.section, PypiDependencySection::Dependencies));Fields§
§name: StringPackage name (normalized to lowercase with underscores replaced by hyphens)
name_range: RangeLSP range of the package name
version_req: Option<String>PEP 440 version specifier (e.g., “>=2.28.0,<3.0”)
version_range: Option<Range>LSP range of the version specifier
extras: Vec<String>PEP 508 extras (e.g., [“security”, “socks”])
extras_range: Option<Range>LSP range of the extras specification
markers: Option<String>PEP 508 environment markers (e.g., “python_version>=‘3.8’”)
markers_range: Option<Range>LSP range of the markers specification
section: PypiDependencySectionSection where this dependency is declared
source: PypiDependencySourceSource of the dependency (PyPI, Git, Path, URL)
Trait Implementations§
Source§impl Clone for PypiDependency
impl Clone for PypiDependency
Source§fn clone(&self) -> PypiDependency
fn clone(&self) -> PypiDependency
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PypiDependency
impl Debug for PypiDependency
Source§impl Dependency for PypiDependency
impl Dependency for PypiDependency
Source§fn name_range(&self) -> Range
fn name_range(&self) -> Range
Source§fn version_requirement(&self) -> Option<&str>
fn version_requirement(&self) -> Option<&str>
Source§fn version_range(&self) -> Option<Range>
fn version_range(&self) -> Option<Range>
Source§fn source(&self) -> DependencySource
fn source(&self) -> DependencySource
Source§impl DependencyInfo for PypiDependency
impl DependencyInfo for PypiDependency
Source§fn name_range(&self) -> Range
fn name_range(&self) -> Range
Source§fn version_requirement(&self) -> Option<&str>
fn version_requirement(&self) -> Option<&str>
Source§fn version_range(&self) -> Option<Range>
fn version_range(&self) -> Option<Range>
Source§fn source(&self) -> DependencySource
fn source(&self) -> DependencySource
Source§impl PartialEq for PypiDependency
impl PartialEq for PypiDependency
impl StructuralPartialEq for PypiDependency
Auto Trait Implementations§
impl Freeze for PypiDependency
impl RefUnwindSafe for PypiDependency
impl Send for PypiDependency
impl Sync for PypiDependency
impl Unpin for PypiDependency
impl UnwindSafe for PypiDependency
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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