(obj, tp)
| 4932 | |
| 4933 | def test_naive_runtime_checks(self): |
| 4934 | def naive_dict_check(obj, tp): |
| 4935 | # Check if a dictionary conforms to Dict type |
| 4936 | if len(tp.__parameters__) > 0: |
| 4937 | raise NotImplementedError |
| 4938 | if tp.__args__: |
| 4939 | KT, VT = tp.__args__ |
| 4940 | return all( |
| 4941 | isinstance(k, KT) and isinstance(v, VT) |
| 4942 | for k, v in obj.items() |
| 4943 | ) |
| 4944 | self.assertTrue(naive_dict_check({'x': 1}, typing.Dict[str, int])) |
| 4945 | self.assertFalse(naive_dict_check({1: 'x'}, typing.Dict[str, int])) |
| 4946 | with self.assertRaises(NotImplementedError): |
nothing calls this directly
no test coverage detected