mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:16 +00:00
Use dot references in docs for methods (#7391)
## Summary This matches the convention used in the Python documentation.
This commit is contained in:
parent
21539f1663
commit
6856d0b44b
10 changed files with 18 additions and 18 deletions
|
@ -17,8 +17,8 @@ use crate::checkers::ast::Checker;
|
||||||
/// contains multiple characters, the reader may be misled into thinking that
|
/// contains multiple characters, the reader may be misled into thinking that
|
||||||
/// a prefix or suffix is being removed, rather than a set of characters.
|
/// a prefix or suffix is being removed, rather than a set of characters.
|
||||||
///
|
///
|
||||||
/// In Python 3.9 and later, you can use `str#removeprefix` and
|
/// In Python 3.9 and later, you can use `str.removeprefix` and
|
||||||
/// `str#removesuffix` to remove an exact prefix or suffix from a string,
|
/// `str.removesuffix` to remove an exact prefix or suffix from a string,
|
||||||
/// respectively, which should be preferred when possible.
|
/// respectively, which should be preferred when possible.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
|
|
|
@ -137,13 +137,13 @@ fn is_standard_library_override(
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
match name {
|
match name {
|
||||||
// Ex) `Event#set`
|
// Ex) `Event.set`
|
||||||
"set" => bases.iter().any(|base| {
|
"set" => bases.iter().any(|base| {
|
||||||
semantic
|
semantic
|
||||||
.resolve_call_path(base)
|
.resolve_call_path(base)
|
||||||
.is_some_and(|call_path| matches!(call_path.as_slice(), ["threading", "Event"]))
|
.is_some_and(|call_path| matches!(call_path.as_slice(), ["threading", "Event"]))
|
||||||
}),
|
}),
|
||||||
// Ex) `Filter#filter`
|
// Ex) `Filter.filter`
|
||||||
"filter" => bases.iter().any(|base| {
|
"filter" => bases.iter().any(|base| {
|
||||||
semantic
|
semantic
|
||||||
.resolve_call_path(base)
|
.resolve_call_path(base)
|
||||||
|
|
|
@ -12,10 +12,10 @@ use crate::registry::AsRule;
|
||||||
use crate::rules::flynt::helpers;
|
use crate::rules::flynt::helpers;
|
||||||
|
|
||||||
/// ## What it does
|
/// ## What it does
|
||||||
/// Checks for `str#join` calls that can be replaced with f-strings.
|
/// Checks for `str.join` calls that can be replaced with f-strings.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// f-strings are more readable and generally preferred over `str#join` calls.
|
/// f-strings are more readable and generally preferred over `str.join` calls.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```python
|
/// ```python
|
||||||
|
|
|
@ -11,15 +11,15 @@ use crate::checkers::ast::Checker;
|
||||||
use crate::settings::types::PythonVersion;
|
use crate::settings::types::PythonVersion;
|
||||||
|
|
||||||
/// ## What it does
|
/// ## What it does
|
||||||
/// Checks duplicate characters in `str#strip` calls.
|
/// Checks duplicate characters in `str.strip` calls.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// All characters in `str#strip` calls are removed from both the leading and
|
/// All characters in `str.strip` calls are removed from both the leading and
|
||||||
/// trailing ends of the string. Including duplicate characters in the call
|
/// trailing ends of the string. Including duplicate characters in the call
|
||||||
/// is redundant and often indicative of a mistake.
|
/// is redundant and often indicative of a mistake.
|
||||||
///
|
///
|
||||||
/// In Python 3.9 and later, you can use `str#removeprefix` and
|
/// In Python 3.9 and later, you can use `str.removeprefix` and
|
||||||
/// `str#removesuffix` to remove an exact prefix or suffix from a string,
|
/// `str.removesuffix` to remove an exact prefix or suffix from a string,
|
||||||
/// respectively, which should be preferred when possible.
|
/// respectively, which should be preferred when possible.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
|
|
|
@ -22,10 +22,10 @@ use crate::rules::pyflakes::format::FormatSummary;
|
||||||
use crate::rules::pyupgrade::helpers::curly_escape;
|
use crate::rules::pyupgrade::helpers::curly_escape;
|
||||||
|
|
||||||
/// ## What it does
|
/// ## What it does
|
||||||
/// Checks for `str#format` calls that can be replaced with f-strings.
|
/// Checks for `str.format` calls that can be replaced with f-strings.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// f-strings are more readable and generally preferred over `str#format`
|
/// f-strings are more readable and generally preferred over `str.format`
|
||||||
/// calls.
|
/// calls.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
|
|
|
@ -12,7 +12,7 @@ use crate::checkers::ast::Checker;
|
||||||
use crate::registry::AsRule;
|
use crate::registry::AsRule;
|
||||||
|
|
||||||
/// ## What it does
|
/// ## What it does
|
||||||
/// Checks for uses of `set#remove` that can be replaced with `set#discard`.
|
/// Checks for uses of `set.remove` that can be replaced with `set.discard`.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// If an element should be removed from a set if it is present, it is more
|
/// If an element should be removed from a set if it is present, it is more
|
||||||
|
|
|
@ -13,7 +13,7 @@ use crate::rules::refurb::helpers::generate_method_call;
|
||||||
/// Checks for unbounded slice expressions to copy a list.
|
/// Checks for unbounded slice expressions to copy a list.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// The `list#copy` method is more readable and consistent with copying other
|
/// The `list.copy` method is more readable and consistent with copying other
|
||||||
/// types.
|
/// types.
|
||||||
///
|
///
|
||||||
/// ## Known problems
|
/// ## Known problems
|
||||||
|
|
|
@ -545,7 +545,7 @@ impl<'a> SemanticModel<'a> {
|
||||||
///
|
///
|
||||||
/// For example, given `["Class", "method"`], resolve the `BindingKind::ClassDefinition`
|
/// For example, given `["Class", "method"`], resolve the `BindingKind::ClassDefinition`
|
||||||
/// associated with `Class`, then the `BindingKind::FunctionDefinition` associated with
|
/// associated with `Class`, then the `BindingKind::FunctionDefinition` associated with
|
||||||
/// `Class#method`.
|
/// `Class.method`.
|
||||||
pub fn lookup_attribute(&'a self, value: &'a Expr) -> Option<BindingId> {
|
pub fn lookup_attribute(&'a self, value: &'a Expr) -> Option<BindingId> {
|
||||||
let call_path = collect_call_path(value)?;
|
let call_path = collect_call_path(value)?;
|
||||||
|
|
||||||
|
|
|
@ -391,7 +391,7 @@ impl<'a> Locator<'a> {
|
||||||
/// Finds the closest [`TextSize`] not exceeding the offset for which `is_char_boundary` is
|
/// Finds the closest [`TextSize`] not exceeding the offset for which `is_char_boundary` is
|
||||||
/// `true`.
|
/// `true`.
|
||||||
///
|
///
|
||||||
/// Can be replaced with `str#floor_char_boundary` once it's stable.
|
/// Can be replaced with `str::floor_char_boundary` once it's stable.
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
///
|
///
|
||||||
|
|
|
@ -15,8 +15,8 @@ impl UniversalNewlines for str {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like [`str#lines`], but accommodates LF, CRLF, and CR line endings,
|
/// Like [`str::lines`], but accommodates LF, CRLF, and CR line endings,
|
||||||
/// the latter of which are not supported by [`str#lines`].
|
/// the latter of which are not supported by [`str::lines`].
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue