Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions benchmarks/bench_encodings.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from __future__ import annotations

import sys
import dataclasses
import importlib.metadata
import json
import sys
import timeit
import importlib.metadata
from typing import Any, Literal, Callable

from .generate_data import make_filesystem_data
from typing import Any, Callable, Literal

import msgspec

from .generate_data import make_filesystem_data


class File(msgspec.Struct, kw_only=True, omit_defaults=True, tag="file"):
name: str
Expand Down Expand Up @@ -61,9 +61,9 @@ def run(self, data: bytes) -> dict:

def json_benchmarks():
import orjson
import ujson
import rapidjson
import simdjson
import ujson

simdjson_ver = importlib.metadata.version("pysimdjson")

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bench_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ def main():
args = parser.parse_args()

if args.versions:
import sys
import importlib.metadata
import sys

for _, lib, _ in BENCHMARKS:
if lib is not None:
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/bench_validation/__main__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import argparse
import json
import tempfile
from ..generate_data import make_filesystem_data
import sys
import subprocess
import shutil
import subprocess
import sys
import tempfile

from ..generate_data import make_filesystem_data

LIBRARIES = ["msgspec", "mashumaro", "cattrs", "pydantic"]

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bench_validation/bench_cattrs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import enum
import datetime
import enum
from typing import Literal

import attrs
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bench_validation/bench_mashumaro.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

import enum
import dataclasses
import datetime
import enum
from typing import Literal

from mashumaro.mixins.orjson import DataClassORJSONMixin
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bench_validation/bench_msgspec.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import enum
import datetime
import enum

import msgspec

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/bench_validation/bench_pydantic.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

import enum
import datetime
from typing import Literal, Annotated
import enum
from typing import Annotated, Literal

import pydantic

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/bench_validation/runner.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import gc
import importlib
import json
import timeit
import resource
import sys
import gc
import timeit

library, path, runs, repeats = sys.argv[1:5]
num_runs = int(runs)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ ignore = [
select = [
"E", # PEP8 Errors
"F", # Pyflakes
"I", # Import sorting
"W", # PEP8 Warnings
]

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
import os
import sys

from setuptools import setup
from setuptools.extension import Extension
Expand Down
2 changes: 1 addition & 1 deletion src/msgspec/_json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
import textwrap
from collections.abc import Iterable
from typing import Any, Optional, Callable
from typing import Any, Callable, Optional

from . import inspect as mi, to_builtins

Expand Down
1 change: 0 additions & 1 deletion src/msgspec/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import collections
import sys
import typing

from typing import _AnnotatedAlias # noqa: F401

try:
Expand Down
2 changes: 1 addition & 1 deletion src/msgspec/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
StructConfig,
asdict,
astuple,
replace,
force_setattr,
replace,
)
from ._utils import get_class_annotations as _get_class_annotations

Expand Down
5 changes: 3 additions & 2 deletions src/msgspec/toml.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import datetime as _datetime
from typing import TYPE_CHECKING, overload, TypeVar, Any
from typing import TYPE_CHECKING, Any, TypeVar, overload

from . import (
DecodeError as _DecodeError,
Expand All @@ -10,7 +10,8 @@
)

if TYPE_CHECKING:
from typing import Callable, Optional, Type, Union, Literal
from typing import Callable, Literal, Optional, Type, Union

from typing_extensions import Buffer


Expand Down
5 changes: 3 additions & 2 deletions src/msgspec/yaml.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import datetime as _datetime
from typing import TYPE_CHECKING, overload, TypeVar, Any
from typing import TYPE_CHECKING, Any, TypeVar, overload

from . import (
DecodeError as _DecodeError,
Expand All @@ -10,7 +10,8 @@
)

if TYPE_CHECKING:
from typing import Callable, Optional, Type, Union, Literal
from typing import Callable, Literal, Optional, Type, Union

from typing_extensions import Buffer


Expand Down
4 changes: 2 additions & 2 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
)

import pytest
from utils import temp_module, max_call_depth
from utils import max_call_depth, temp_module

try:
import attrs
except ImportError:
attrs = None

import msgspec
from msgspec import Meta, Struct, ValidationError, UNSET, UnsetType
from msgspec import UNSET, Meta, Struct, UnsetType, ValidationError

UTC = datetime.timezone.utc

Expand Down
2 changes: 1 addition & 1 deletion tests/test_constraints.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
import math
import re
from typing import Dict, List, Union, Annotated
from typing import Annotated, Dict, List, Union

import pytest

Expand Down
4 changes: 2 additions & 2 deletions tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
NamedTuple,
Set,
Tuple,
TypeVar,
TypedDict,
TypeVar,
Union,
)

import pytest
from utils import temp_module, max_call_depth
from utils import max_call_depth, temp_module

import msgspec
from msgspec import Meta, Struct, ValidationError, convert, to_builtins
Expand Down
1 change: 0 additions & 1 deletion tests/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import msgspec.inspect as mi
from msgspec import Meta


PY312 = sys.version_info[:2] >= (3, 12)
py312_plus = pytest.mark.skipif(not PY312, reason="3.12+ only")

Expand Down
4 changes: 2 additions & 2 deletions tests/test_performance.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import textwrap

import msgspec

from utils import temp_module

import msgspec


def test_process_large_recursive_union():
"""
Expand Down
1 change: 0 additions & 1 deletion tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import msgspec
from msgspec import Meta


T = TypeVar("T")


Expand Down
2 changes: 1 addition & 1 deletion tests/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import weakref
from contextlib import contextmanager
from inspect import Parameter, Signature
from typing import Any, List, Optional, Generic, TypeVar
from typing import Any, Generic, List, Optional, TypeVar

import pytest
from utils import temp_module
Expand Down
3 changes: 2 additions & 1 deletion tests/test_struct_meta.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Tests for the exposed StructMeta metaclass."""

import pytest

import msgspec
from msgspec import Struct, StructMeta
from msgspec.structs import asdict, astuple, replace, force_setattr
from msgspec.structs import asdict, astuple, force_setattr, replace


def test_struct_meta_exists():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_to_builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import pytest

from msgspec import UNSET, Struct, UnsetType, to_builtins, defstruct
from msgspec import UNSET, Struct, UnsetType, defstruct, to_builtins

PY310 = sys.version_info[:2] >= (3, 10)
PY311 = sys.version_info[:2] >= (3, 11)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Generic, List, Optional, Set, TypeVar

import pytest
from utils import temp_module, package_not_installed
from utils import package_not_installed, temp_module

from msgspec._utils import get_class_annotations

Expand Down
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
import inspect
import sys
import textwrap
import types
import uuid
Expand Down