mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[ty] File inclusion and exclusion (#18498)
This commit is contained in:
parent
3c6c017950
commit
1f27d53fd5
23 changed files with 2728 additions and 159 deletions
|
@ -665,6 +665,9 @@ pub enum DiagnosticId {
|
|||
|
||||
/// No rule with the given name exists.
|
||||
UnknownRule,
|
||||
|
||||
/// A glob pattern doesn't follow the expected syntax.
|
||||
InvalidGlob,
|
||||
}
|
||||
|
||||
impl DiagnosticId {
|
||||
|
@ -699,6 +702,7 @@ impl DiagnosticId {
|
|||
DiagnosticId::Lint(name) => name.as_str(),
|
||||
DiagnosticId::RevealedType => "revealed-type",
|
||||
DiagnosticId::UnknownRule => "unknown-rule",
|
||||
DiagnosticId::InvalidGlob => "invalid-glob",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,30 @@ impl SystemPath {
|
|||
SystemPath::from_std_path(dunce::simplified(self.as_std_path())).unwrap()
|
||||
}
|
||||
|
||||
/// Returns `true` if the `SystemPath` is absolute, i.e., if it is independent of
|
||||
/// the current directory.
|
||||
///
|
||||
/// * On Unix, a path is absolute if it starts with the root, so
|
||||
/// `is_absolute` and [`has_root`] are equivalent.
|
||||
///
|
||||
/// * On Windows, a path is absolute if it has a prefix and starts with the
|
||||
/// root: `c:\windows` is absolute, while `c:temp` and `\temp` are not.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use ruff_db::system::SystemPath;
|
||||
///
|
||||
/// assert!(!SystemPath::new("foo.txt").is_absolute());
|
||||
/// ```
|
||||
///
|
||||
/// [`has_root`]: Utf8Path::has_root
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn is_absolute(&self) -> bool {
|
||||
self.0.is_absolute()
|
||||
}
|
||||
|
||||
/// Extracts the file extension, if possible.
|
||||
///
|
||||
/// The extension is:
|
||||
|
@ -538,6 +562,10 @@ impl SystemPathBuf {
|
|||
self.0.into_std_path_buf()
|
||||
}
|
||||
|
||||
pub fn into_string(self) -> String {
|
||||
self.0.into_string()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_path(&self) -> &SystemPath {
|
||||
SystemPath::new(&self.0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue