Coverage for cuda / core / _utils / clear_error_support.py: 75.00%
8 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-08 01:07 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-08 01:07 +0000
1# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2#
3# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
6def assert_type(obj, expected_type):
7 """Ensure obj is of expected_type, else raise AssertionError with a clear message."""
8 if not isinstance(obj, expected_type): 2b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ [ ] ^ _ ` JcKcLcMcNcOcPcQcRcScTcUcVcWcXcYcZc0c1c2c3c4c5c6c7c8c9c!c#c$c%c'c(c)c*c+c,c-c.c/c:c;c=c?c@c[c]c^c_c`c{c|c}c~cadbdcdddedfdgdhd{ | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbidjdkdldqbrbsbtbubvbwbxbybzbAbBbCbDbEbFbGbHbIbJbKbLbMbNbObPbQbRbSbTbUbVbWbXbYbZb0b1b2b3b4b5b6b7b8b9b!b#b$b%b'b(b)b*b+b,b-b.b/b:b;b=b?b@b[b]b^b_b`b{b|b}b~bacbcccdcecfcgchcicjckclcmcmdncndocodpcpdqcqdrcscrdtcucvcsdwcxcyczcAcBcCcDcEcFcGctdudHcvdwdxdydzdAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd0d1d2d3d4d5d6d7d8d9d!d#d$d%d'd(d)dIc*d+d,d-d.d/d:d;d=d?d@d
9 raise TypeError(f"Expected type {expected_type.__name__}, but got {type(obj).__name__}") 2Ic
12def assert_type_str_or_bytes_like(obj):
13 """Ensure obj is of type str or bytes, else raise AssertionError with a clear message."""
14 if not isinstance(obj, (str, bytes, bytearray)): 2b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnb[dob]dpb^dqbrbsbtbubvbwbxbybzbAbBbCbDbEbFbGbHbIbJbKbLbMbNbObPbQbRbSbTbUbVbWbXbYbZb0b1b2b3b4b5b6b7b8b9b!b#b$b%b'b(b)b*b+b,b-b.b/b:b;b=b?b@b[b]b^b_b`b{b|b}b~bacbcccdcecfcgchcicjckclcmcncocpcqcrcsctcucvcwcxcyczcAcBcCcDcEcFcGcHc_d
15 raise TypeError(f"Expected type str or bytes or bytearray, but got {type(obj).__name__}")
18def raise_code_path_meant_to_be_unreachable():
19 raise RuntimeError("This code path is meant to be unreachable.")