-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.2.0: Add support for validating Literals.
- Loading branch information
1 parent
b58d79f
commit 4e7c129
Showing
8 changed files
with
436 additions
and
344 deletions.
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
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "type_enforced" | ||
version = "1.1.1" | ||
version = "1.2.0" | ||
description = "A pure python type enforcer for python type annotations" | ||
authors = [ | ||
{name="Connor Makowski", email="[email protected]"} | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[metadata] | ||
name = type_enfoced | ||
version = 1.1.1 | ||
version = 1.2.0 | ||
description_file = README.md | ||
|
||
[options] | ||
|
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,27 @@ | ||
import type_enforced | ||
from typing import Literal | ||
|
||
|
||
@type_enforced.Enforcer | ||
def my_fn(a: Literal["a", "b"]): | ||
pass | ||
|
||
|
||
success_1 = True | ||
try: | ||
my_fn(a="a") | ||
my_fn(a="b") | ||
except: | ||
success_1 = False | ||
|
||
success_2 = False | ||
try: | ||
my_fn(a="c") | ||
except Exception as e: | ||
if "Type mismatch" in str(e): | ||
success_2 = True | ||
|
||
if success_1 and success_2: | ||
print("test_fn_13.py passed") | ||
else: | ||
print("test_fn_13.py failed") |
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