Skip to content

Commit b651236

Browse files
committed
Use the newer attrs interface in the test suite loader.
1 parent e24f0ee commit b651236

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

jsonschema/tests/_suite.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
"""
22
Python representations of the JSON Schema Test Suite tests.
33
"""
4+
from __future__ import annotations
45

6+
from collections.abc import Mapping
57
from functools import partial
68
from pathlib import Path
9+
from typing import Any
710
import json
811
import os
912
import re
1013
import subprocess
1114
import sys
1215
import unittest
1316

14-
import attr
17+
from attrs import field, frozen
1518

1619
from jsonschema.validators import _VALIDATORS
1720
import jsonschema
@@ -35,10 +38,10 @@ def _find_suite():
3538
return root
3639

3740

38-
@attr.s(hash=True)
41+
@frozen
3942
class Suite:
4043

41-
_root = attr.ib(default=attr.Factory(_find_suite))
44+
_root = field(factory=_find_suite)
4245

4346
def _remotes(self):
4447
jsonschema_suite = self._root.joinpath("bin", "jsonschema_suite")
@@ -62,13 +65,13 @@ def version(self, name):
6265
)
6366

6467

65-
@attr.s(hash=True)
68+
@frozen
6669
class Version:
6770

68-
_path = attr.ib()
69-
_remotes = attr.ib()
71+
_path: Path
72+
_remotes: Mapping[str, Mapping[str, Any] | bool]
7073

71-
name = attr.ib()
74+
name: str
7275

7376
def benchmark(self, runner, **kwargs): # pragma: no cover
7477
for suite in self.tests():
@@ -139,23 +142,23 @@ def _tests_in(self, subject, path):
139142
)
140143

141144

142-
@attr.s(hash=True, repr=False)
145+
@frozen(repr=False)
143146
class _Test:
144147

145-
version = attr.ib()
148+
version: Version
146149

147-
subject = attr.ib()
148-
case_description = attr.ib()
149-
description = attr.ib()
150+
subject: str
151+
case_description: str
152+
description: str
150153

151-
data = attr.ib()
152-
schema = attr.ib(repr=False)
154+
data: Any
155+
schema: dict[str, Any] | bool
153156

154-
valid = attr.ib()
157+
valid: bool
155158

156-
_remotes = attr.ib()
159+
_remotes: dict[str, dict[str, Any] | bool]
157160

158-
comment = attr.ib(default=None)
161+
comment: str | None = None
159162

160163
def __repr__(self): # pragma: no cover
161164
return "<Test {}>".format(self.fully_qualified_name)

0 commit comments

Comments
 (0)