Skip to content

Commit

Permalink
Use TypedDict for JSON output typing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Flameeyes committed Aug 16, 2024
1 parent d4dad25 commit d9e6a92
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ipv6_in_real_life/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@

import json
import time
from typing import Union
from typing import TypedDict

from . import data_structures

HostJson = dict[str, Union[bool, str, None]]
EntityJson = dict[str, Union[str, list[HostJson], HostJson]]

class HostJson(TypedDict):
name: str
has_ipv4_address: bool | None
has_ipv6_address: bool | None


class EntityJson(TypedDict):
name: str
main_host: HostJson
additional_hosts: list[HostJson]


CategoryJson = list[EntityJson]
CountryDataJson = dict[str, CategoryJson]
SourceJson = dict[str, CountryDataJson]
Expand Down

0 comments on commit d9e6a92

Please sign in to comment.