Skip to content

Commit

Permalink
Allow boolean positionals in __post_init__ (astral-sh#10027)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh authored and nkxxll committed Mar 4, 2024
1 parent 5ccd78c commit 3402645
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Expand Up @@ -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)
Expand Up @@ -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
Expand Down

0 comments on commit 3402645

Please sign in to comment.