1
1
"""
2
2
Python representations of the JSON Schema Test Suite tests.
3
3
"""
4
+ from __future__ import annotations
4
5
6
+ from collections .abc import Mapping
5
7
from functools import partial
6
8
from pathlib import Path
9
+ from typing import Any
7
10
import json
8
11
import os
9
12
import re
10
13
import subprocess
11
14
import sys
12
15
import unittest
13
16
14
- import attr
17
+ from attrs import field , frozen
15
18
16
19
from jsonschema .validators import _VALIDATORS
17
20
import jsonschema
@@ -35,10 +38,10 @@ def _find_suite():
35
38
return root
36
39
37
40
38
- @attr . s ( hash = True )
41
+ @frozen
39
42
class Suite :
40
43
41
- _root = attr . ib ( default = attr . Factory ( _find_suite ) )
44
+ _root = field ( factory = _find_suite )
42
45
43
46
def _remotes (self ):
44
47
jsonschema_suite = self ._root .joinpath ("bin" , "jsonschema_suite" )
@@ -62,13 +65,13 @@ def version(self, name):
62
65
)
63
66
64
67
65
- @attr . s ( hash = True )
68
+ @frozen
66
69
class Version :
67
70
68
- _path = attr . ib ()
69
- _remotes = attr . ib ()
71
+ _path : Path
72
+ _remotes : Mapping [ str , Mapping [ str , Any ] | bool ]
70
73
71
- name = attr . ib ()
74
+ name : str
72
75
73
76
def benchmark (self , runner , ** kwargs ): # pragma: no cover
74
77
for suite in self .tests ():
@@ -139,23 +142,23 @@ def _tests_in(self, subject, path):
139
142
)
140
143
141
144
142
- @attr . s ( hash = True , repr = False )
145
+ @frozen ( repr = False )
143
146
class _Test :
144
147
145
- version = attr . ib ()
148
+ version : Version
146
149
147
- subject = attr . ib ()
148
- case_description = attr . ib ()
149
- description = attr . ib ()
150
+ subject : str
151
+ case_description : str
152
+ description : str
150
153
151
- data = attr . ib ()
152
- schema = attr . ib ( repr = False )
154
+ data : Any
155
+ schema : dict [ str , Any ] | bool
153
156
154
- valid = attr . ib ()
157
+ valid : bool
155
158
156
- _remotes = attr . ib ()
159
+ _remotes : dict [ str , dict [ str , Any ] | bool ]
157
160
158
- comment = attr . ib ( default = None )
161
+ comment : str | None = None
159
162
160
163
def __repr__ (self ): # pragma: no cover
161
164
return "<Test {}>" .format (self .fully_qualified_name )
0 commit comments