mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-02 04:48:06 +00:00
Allow boolean positionals in __post_init__ (#10027)
Closes https://github.com/astral-sh/ruff/issues/10011.
This commit is contained in:
parent
235cfb7976
commit
e1928be36e
2 changed files with 14 additions and 1 deletions
|
|
@ -119,3 +119,16 @@ def func(x: bool):
|
|||
|
||||
|
||||
settings(True)
|
||||
|
||||
|
||||
from dataclasses import dataclass, InitVar
|
||||
|
||||
|
||||
@dataclass
|
||||
class Fit:
|
||||
force: InitVar[bool] = False
|
||||
|
||||
def __post_init__(self, force: bool) -> None:
|
||||
print(force)
|
||||
|
||||
Fit(force=True)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ pub(super) fn is_allowed_func_call(name: &str) -> bool {
|
|||
|
||||
/// Returns `true` if a function definition is allowed to use a boolean trap.
|
||||
pub(super) fn is_allowed_func_def(name: &str) -> bool {
|
||||
matches!(name, "__setitem__")
|
||||
matches!(name, "__setitem__" | "__post_init__")
|
||||
}
|
||||
|
||||
/// Returns `true` if an argument is allowed to use a boolean trap. To return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue