-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from DavidCEllis/add_private
Add private parameter to prefab's attribute function
- Loading branch information
Showing
4 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from ducktools.classbuilder.prefab import Prefab, attribute, get_attributes | ||
|
||
|
||
def test_private_attribute(): | ||
class Ex(Prefab): | ||
_internal: "str | None" = attribute(default=None, private=True) | ||
a: int | ||
b: str | ||
|
||
|
||
ex = Ex(1, "Hello") | ||
|
||
assert ex.a == 1 | ||
assert ex.b == "Hello" | ||
|
||
assert ex._internal is None | ||
|
||
_internal_attrib = get_attributes(Ex)["_internal"] | ||
|
||
assert _internal_attrib.init is False | ||
assert _internal_attrib.repr is False | ||
assert _internal_attrib.iter is False | ||
assert _internal_attrib.compare is False | ||
assert _internal_attrib.serialize is False |