Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-morel committed Jun 9, 2024
1 parent 5bb7380 commit 1764ce2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/pyoload/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def __call__(self: PyoloadAnnotation, val: Any):
) from e

def __str__(self):
return f"pyoload.Cast({self.type!s})"
return f"pyoload.Cast({self.type!r})"


class CastedAttr(Cast):
Expand Down
14 changes: 7 additions & 7 deletions src/tests/logs.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type_match vs isinstance on int:True 1.4384856ms
type_match vs isinstance on int:False 2.3996007ms
type_match on dict[str, int]*50:True 264.8990402ms
type_match on dict[str, int]*50:False 17.6305638ms
Cast str->int: 10.889522999999999ms
Cast complex->int | str: 0.5091771ms
Cast dict[int,list[str]*10]*10->dict[str,tuple[float]]: 11.79795839ms
type_match vs isinstance on int:True 1.9651758000000001ms
type_match vs isinstance on int:False 2.6587863ms
type_match on dict[str, int]*50:True 264.9008229ms
type_match on dict[str, int]*50:False 17.8607409ms
Cast str->int: 10.8863359ms
Cast complex->int | str: 0.5212234499999999ms
Cast dict[int,list[str]*10]*10->dict[str,tuple[float]]: 11.70674105ms
2 changes: 2 additions & 0 deletions src/tests/test_cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@ def foo2(a: 'Cast(None)'):
else:
raise Exception()

assert str(Cast(int)) == f"pyoload.Cast({int!r})"

if __name__ == "__main__":
test_cast()

0 comments on commit 1764ce2

Please sign in to comment.