File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change 11"""Decoder for the MaxMind DB data section."""
22
3+ from __future__ import annotations
4+
35import struct
4- from typing import ClassVar , Union , cast
6+ from typing import TYPE_CHECKING , ClassVar , cast
57
68try :
79 import mmap
1012
1113
1214from maxminddb .errors import InvalidDatabaseError
13- from maxminddb .file import FileBuffer
14- from maxminddb .types import Record
15+
16+ if TYPE_CHECKING :
17+ from maxminddb .file import FileBuffer
18+ from maxminddb .types import Record
1519
1620
1721class Decoder :
1822 """Decoder for the data section of the MaxMind DB."""
1923
2024 def __init__ (
2125 self ,
22- database_buffer : Union [ FileBuffer , " mmap.mmap" , bytes ] ,
26+ database_buffer : FileBuffer | mmap .mmap | bytes ,
2327 pointer_base : int = 0 ,
2428 pointer_test : bool = False , # noqa: FBT001, FBT002
2529 ) -> None :
Original file line number Diff line number Diff line change 11"""Types representing database records."""
22
3- from typing import AnyStr , Union
3+ from __future__ import annotations
44
5- Primitive = Union [AnyStr , bool , float , int ]
6- Record = Union [Primitive , "RecordList" , "RecordDict" ]
5+ from typing import AnyStr , TypeAlias
76
7+ Primitive : TypeAlias = AnyStr | bool | float | int
88
9- class RecordList (list [Record ]):
9+
10+ class RecordList (list ["Record" ]):
1011 """RecordList is a type for lists in a database record."""
1112
1213
13- class RecordDict (dict [str , Record ]):
14+ class RecordDict (dict [str , " Record" ]):
1415 """RecordDict is a type for dicts in a database record."""
16+
17+
18+ Record : TypeAlias = Primitive | RecordList | RecordDict
You can’t perform that action at this time.
0 commit comments