Skip to content

Commit 13703bc

Browse files
committed
Add pydantic as dependency. Make Language and Config classes inherit BaseModel.
1 parent b9c39ce commit 13703bc

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "judge0"
3-
version = "0.0.1"
3+
version = "0.0.2dev"
44
description = "The official Python library for Judge0."
55
readme = "README.md"
66
requires-python = ">=3.9"
@@ -25,7 +25,7 @@ classifiers = [
2525
"Topic :: Software Development :: Libraries :: Python Modules",
2626
"Typing :: Typed",
2727
]
28-
dependencies = ["requests>=2.28.0,<3.0.0"]
28+
dependencies = ["requests>=2.28.0,<3.0.0", "pydantic>=2.0.0,<3.0.0"]
2929

3030
[build-system]
3131
requires = ["setuptools>=70.0"]

src/judge0/base_types.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from enum import IntEnum
33
from typing import Optional, Protocol, runtime_checkable, Sequence, Union
44

5+
from pydantic import BaseModel
6+
57
Iterable = Sequence
68

79
TestCaseType = Union["TestCase", list, tuple, dict]
@@ -15,6 +17,7 @@ class TestCase:
1517

1618
@staticmethod
1719
def from_record(test_case: Optional[TestCaseType] = None) -> "TestCase":
20+
"""Create a TestCase from built-in types."""
1821
if isinstance(test_case, (tuple, list)):
1922
test_case = {
2023
field: value
@@ -39,8 +42,7 @@ def encode(self) -> bytes:
3942
...
4043

4144

42-
@dataclass(frozen=True)
43-
class Language:
45+
class Language(BaseModel):
4446
id: int
4547
name: str
4648

@@ -85,8 +87,9 @@ def __str__(self):
8587
return self.name.lower().replace("_", " ").title()
8688

8789

88-
@dataclass(frozen=True)
89-
class Config:
90+
class Config(BaseModel):
91+
"""Client config data."""
92+
9093
allow_enable_network: bool
9194
allow_enable_per_process_and_thread_memory_limit: bool
9295
allow_enable_per_process_and_thread_time_limit: bool

0 commit comments

Comments
 (0)