[flake8-builtins] Improve A005 documentation (#15466)

This commit is contained in:
Tom Kuson 2025-01-14 07:42:13 +00:00 committed by GitHub
parent dc491e8ade
commit 369cbb5424
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -27,6 +27,20 @@ use crate::settings::types::PythonVersion;
/// of the control of the author of the stub file. Instead, a stub should aim to
/// faithfully emulate the runtime module it is stubbing.
///
/// As of Python 3.13, errors from modules that use the same name as
/// standard-library modules now display a custom message.
///
/// ## Example
///
/// ```console
/// $ touch random.py
/// $ python3 -c 'from random import choice'
/// Traceback (most recent call last):
/// File "<string>", line 1, in <module>
/// from random import choice
/// ImportError: cannot import name 'choice' from 'random' (consider renaming '/random.py' since it has the same name as the standard library module named 'random' and prevents importing that standard library module)
/// ```
///
/// ## Options
/// - `lint.flake8-builtins.builtins-allowed-modules`
#[derive(ViolationMetadata)]

View file

@ -1127,7 +1127,7 @@ pub struct Flake8BuiltinsOptions {
#[option(
default = r#"[]"#,
value_type = "list[str]",
example = "builtins-allowed-modules = [\"id\"]"
example = "builtins-allowed-modules = [\"secrets\"]"
)]
/// List of builtin module names to allow.
pub builtins_allowed_modules: Option<Vec<String>>,