mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-22 20:45:11 +00:00
Rename ruff_python
crate to ruff_python_stdlib
(#3354)
In hindsight, `ruff_python` is too general. A good giveaway is that it's actually a prefix of some other crates. The intent of this crate is to reimplement pieces of the Python standard library and CPython itself, so `ruff_python_stdlib` feels appropriate.
This commit is contained in:
parent
348a38d261
commit
d1c48016eb
41 changed files with 88 additions and 73 deletions
|
@ -6,11 +6,11 @@ use crate::core::types::Range;
|
|||
/// Return the leading quote for a string or byte literal (e.g., `"""`).
|
||||
pub fn leading_quote(content: &str) -> Option<&str> {
|
||||
if let Some(first_line) = content.lines().next() {
|
||||
for pattern in ruff_python::str::TRIPLE_QUOTE_PREFIXES
|
||||
for pattern in ruff_python_stdlib::str::TRIPLE_QUOTE_PREFIXES
|
||||
.iter()
|
||||
.chain(ruff_python::bytes::TRIPLE_QUOTE_PREFIXES)
|
||||
.chain(ruff_python::str::SINGLE_QUOTE_PREFIXES)
|
||||
.chain(ruff_python::bytes::SINGLE_QUOTE_PREFIXES)
|
||||
.chain(ruff_python_stdlib::bytes::TRIPLE_QUOTE_PREFIXES)
|
||||
.chain(ruff_python_stdlib::str::SINGLE_QUOTE_PREFIXES)
|
||||
.chain(ruff_python_stdlib::bytes::SINGLE_QUOTE_PREFIXES)
|
||||
{
|
||||
if first_line.starts_with(pattern) {
|
||||
return Some(pattern);
|
||||
|
@ -22,9 +22,9 @@ pub fn leading_quote(content: &str) -> Option<&str> {
|
|||
|
||||
/// Return the trailing quote string for a string or byte literal (e.g., `"""`).
|
||||
pub fn trailing_quote(content: &str) -> Option<&&str> {
|
||||
ruff_python::str::TRIPLE_QUOTE_SUFFIXES
|
||||
ruff_python_stdlib::str::TRIPLE_QUOTE_SUFFIXES
|
||||
.iter()
|
||||
.chain(ruff_python::str::SINGLE_QUOTE_SUFFIXES)
|
||||
.chain(ruff_python_stdlib::str::SINGLE_QUOTE_SUFFIXES)
|
||||
.find(|&pattern| content.ends_with(pattern))
|
||||
}
|
||||
|
||||
|
@ -160,11 +160,11 @@ pub fn is_elif(orelse: &[rustpython_parser::ast::Stmt], locator: &Locator) -> bo
|
|||
mod tests {
|
||||
#[test]
|
||||
fn test_prefixes() {
|
||||
let prefixes = ruff_python::str::TRIPLE_QUOTE_PREFIXES
|
||||
let prefixes = ruff_python_stdlib::str::TRIPLE_QUOTE_PREFIXES
|
||||
.iter()
|
||||
.chain(ruff_python::bytes::TRIPLE_QUOTE_PREFIXES)
|
||||
.chain(ruff_python::str::SINGLE_QUOTE_PREFIXES)
|
||||
.chain(ruff_python::bytes::SINGLE_QUOTE_PREFIXES)
|
||||
.chain(ruff_python_stdlib::bytes::TRIPLE_QUOTE_PREFIXES)
|
||||
.chain(ruff_python_stdlib::str::SINGLE_QUOTE_PREFIXES)
|
||||
.chain(ruff_python_stdlib::bytes::SINGLE_QUOTE_PREFIXES)
|
||||
.collect::<Vec<_>>();
|
||||
for i in 1..prefixes.len() {
|
||||
for j in 0..i - 1 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue