pub struct PypiDependency {
pub name: PackageName,
pub name_range: Range,
pub version_req: Option<VersionReq>,
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: DependencySource,
}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_full_version >= '3.8'".into()),
markers_range: None,
section: PypiDependencySection::Dependencies,
source: PypiDependencySource::Registry,
};
assert_eq!(dep.name, "requests");
assert!(matches!(dep.section, PypiDependencySection::Dependencies));Fields§
§name: PackageNameThe package name as produced by the parse path that created this dependency — normalization is non-uniform, not a property callers can rely on directly:
- PEP 508 string paths (PEP 621
[project] dependencies, PEP 735 dependency groups,requirements.txt) — already PEP 503-normalized, becausepep508_rs::PackageNamenormalizes at construction. - Poetry table-key paths (
[tool.poetry.dependencies],[tool.poetry.group.*.dependencies]) — the verbatim TOML key, unnormalized.
Callers must therefore never assume a normalized name. Apply
crate::name::normalize (via
EcosystemFormatter::normalize_package_name) at lookup time.
name_range: RangeLSP range of the package name
version_req: Option<VersionReq>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_full_version >= ‘3.8’”; pep508_rs
canonicalizes python_version comparisons to python_full_version on serialization)
markers_range: Option<Range>LSP range of the markers specification
section: PypiDependencySectionSection where this dependency is declared
source: DependencySourceSource 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 (const: unstable) · 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(&self) -> &PackageName
fn name(&self) -> &PackageName
Source§fn name_range(&self) -> Range
fn name_range(&self) -> Range
Source§fn version_requirement(&self) -> Option<&VersionReq>
fn version_requirement(&self) -> Option<&VersionReq>
Source§fn version_range(&self) -> Option<Range>
fn version_range(&self) -> Option<Range>
Source§fn source(&self) -> DependencySource
fn source(&self) -> DependencySource
Source§fn markers(&self) -> Option<&str>
fn markers(&self) -> Option<&str>
python_version >= '3.8'). Ecosystem-specific, None if not supported
or not present on this dependency.Source§fn markers_range(&self) -> Option<Range>
fn markers_range(&self) -> Option<Range>
None if not supported or not present).Source§fn features_range(&self) -> Option<Range>
fn features_range(&self) -> Option<Range>
Source§fn version_literal(&self) -> Option<&str>
fn version_literal(&self) -> Option<&str>
Source§impl PartialEq for PypiDependency
impl PartialEq for PypiDependency
Source§fn eq(&self, other: &PypiDependency) -> bool
fn eq(&self, other: &PypiDependency) -> bool
self and other values to be equal, and is used by ==.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 UnsafeUnpin 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