Skip to content

Commit

Permalink
Use PEP 585 type annotations
Browse files Browse the repository at this point in the history
Signed-off-by: Emanuele Giaquinta <[email protected]>
  • Loading branch information
exg committed Nov 23, 2024
1 parent 74bbfa3 commit fee2d52
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 20 deletions.
3 changes: 1 addition & 2 deletions benchmarks/bench_dataclass.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import dataclasses
from typing import List

import msgpack

Expand All @@ -16,7 +15,7 @@ class Member:
class Object:
id: int
name: str
members: List[Member]
members: list[Member]


objects_as_dataclass = [
Expand Down
4 changes: 1 addition & 3 deletions benchmarks/bench_pydantic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import List

import msgpack
from pydantic import BaseModel

Expand All @@ -14,7 +12,7 @@ class Member(BaseModel):
class Object(BaseModel):
id: int
name: str
members: List[Member]
members: list[Member]


objects_as_pydantic = [
Expand Down
8 changes: 3 additions & 5 deletions tests/test_circular.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from typing import Dict, List

import pytest

import ormsgpack
Expand All @@ -11,7 +9,7 @@ def test_circular_dict() -> None:
"""
packb() circular reference dict
"""
obj: Dict[str, object] = {}
obj: dict[str, object] = {}
obj["obj"] = obj
with pytest.raises(ormsgpack.MsgpackEncodeError):
ormsgpack.packb(obj)
Expand All @@ -21,7 +19,7 @@ def test_circular_list() -> None:
"""
packb() circular reference list
"""
obj: List[object] = []
obj: list[object] = []
obj.append(obj)
with pytest.raises(ormsgpack.MsgpackEncodeError):
ormsgpack.packb(obj)
Expand All @@ -31,7 +29,7 @@ def test_circular_nested() -> None:
"""
packb() circular reference nested dict, list
"""
obj: Dict[str, object] = {}
obj: dict[str, object] = {}
obj["list"] = [{"obj": obj}]
with pytest.raises(ormsgpack.MsgpackEncodeError):
ormsgpack.packb(obj)
4 changes: 1 addition & 3 deletions tests/test_dict.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from typing import Dict

import msgpack
import pytest

Expand All @@ -16,7 +14,7 @@
pytest.param({str(i): i for i in range(65536)}, id="map 32"),
),
)
def test_dict(value: Dict[str, int]) -> None:
def test_dict(value: dict[str, int]) -> None:
packed = ormsgpack.packb(value)
assert packed == msgpack.packb(value)
assert ormsgpack.unpackb(packed) == value
Expand Down
4 changes: 1 addition & 3 deletions tests/test_list.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from typing import List

import msgpack
import pytest

Expand All @@ -16,7 +14,7 @@
pytest.param([i for i in range(65536)], id="array 32"),
),
)
def test_list(value: List[int]) -> None:
def test_list(value: list[int]) -> None:
packed = ormsgpack.packb(value)
assert packed == msgpack.packb(value)
assert ormsgpack.unpackb(packed) == value
7 changes: 3 additions & 4 deletions tests/test_subclass.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

import collections
from typing import Dict, List, Tuple

import msgpack
import pytest
Expand All @@ -17,19 +16,19 @@ class SubInt(int):
pass


class SubDict(Dict[str, object]):
class SubDict(dict[str, object]):
pass


class SubList(List[object]):
class SubList(list[object]):
pass


class SubFloat(float):
pass


class SubTuple(Tuple[object, object]):
class SubTuple(tuple[object, object]):
pass


Expand Down

0 comments on commit fee2d52

Please sign in to comment.