Skip to content
Merged
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
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jobs:
# - windows-latest
# - macos-latest
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
Expand Down
7 changes: 0 additions & 7 deletions .pytest.ini

This file was deleted.

2 changes: 0 additions & 2 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ extend-exclude = [
"src/msgspec/_version.py",
"tests/typing/basic_typing_examples.py",
"tests/unit/test_JSONTestSuite.py",
# TODO: remove when this when we drop support for Python 3.9 (example uses match statements)
"examples/asyncio-kv/kv.py",
]

[lint]
Expand Down
3 changes: 2 additions & 1 deletion examples/asyncio-kv/kv.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations

import asyncio
import msgspec
from typing import Any

import msgspec


# Some utilities for writing and reading length-prefix framed messages. Using
# length-prefixed framing makes it easier for the reader to determine the
Expand Down
7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ license = "BSD-3-Clause"
license-files = [
"LICENSE",
]
requires-python = ">=3.9"
requires-python = ">=3.10"
maintainers = [
{ name = "Jim Crist-Harif", email = "jcristharif@gmail.com" },
{ name = "Ofek Lev", email = "oss@ofek.dev" },
Expand All @@ -33,7 +33,6 @@ keywords = [
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand Down Expand Up @@ -85,8 +84,7 @@ hooks = [
"ruff==0.14.1",
]
test-base = [
# TODO: require >=9 once we drop support for Python 3.9
"pytest>=8",
"pytest>=9",
]
test-prof = [
{ include-group = "test-base" },
Expand All @@ -103,7 +101,6 @@ test-unit = [
{ include-group = "test-base" },
"attrs",
"coverage",
"eval-type-backport; python_version < '3.10'",
"msgpack",
"pyyaml",
"tomli; python_version < '3.11'",
Expand Down
18 changes: 0 additions & 18 deletions src/msgspec/_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "atof.h"

/* Python version checks */
#define PY310_PLUS (PY_VERSION_HEX >= 0x030a0000)
#define PY311_PLUS (PY_VERSION_HEX >= 0x030b0000)
#define PY312_PLUS (PY_VERSION_HEX >= 0x030c0000)
#define PY313_PLUS (PY_VERSION_HEX >= 0x030d0000)
Expand Down Expand Up @@ -511,9 +510,7 @@ typedef struct {
PyObject *get_typeddict_info;
PyObject *get_dataclass_info;
PyObject *rebuild;
#if PY310_PLUS
PyObject *types_uniontype;
#endif
#if PY312_PLUS
PyObject *typing_typealiastype;
#endif
Expand Down Expand Up @@ -4899,15 +4896,13 @@ typenode_origin_args_metadata(
}
}

#if PY310_PLUS
if (Py_TYPE(t) == (PyTypeObject *)(state->mod->types_uniontype)) {
/* Handle types.UnionType unions (`int | float | ...`) */
args = PyObject_GetAttr(t, state->mod->str___args__);
if (args == NULL) goto error;
origin = state->mod->typing_union;
Py_INCREF(origin);
}
#endif

*out_origin = origin;
*out_args = args;
Expand Down Expand Up @@ -10500,15 +10495,8 @@ ms_encode_err_type_unsupported(PyTypeObject *type) {
*************************************************************************/

#define MS_HAS_TZINFO(o) (((_PyDateTime_BaseTZInfo *)(o))->hastzinfo)
#if PY310_PLUS
#define MS_DATE_GET_TZINFO(o) PyDateTime_DATE_GET_TZINFO(o)
#define MS_TIME_GET_TZINFO(o) PyDateTime_TIME_GET_TZINFO(o)
#else
#define MS_DATE_GET_TZINFO(o) (MS_HAS_TZINFO(o) ? \
((PyDateTime_DateTime *)(o))->tzinfo : Py_None)
#define MS_TIME_GET_TZINFO(o) (MS_HAS_TZINFO(o) ? \
((PyDateTime_Time *)(o))->tzinfo : Py_None)
#endif

#ifndef Py_GIL_DISABLED
#ifndef TIMEZONE_CACHE_SIZE
Expand Down Expand Up @@ -22298,9 +22286,7 @@ msgspec_clear(PyObject *m)
Py_CLEAR(st->get_typeddict_info);
Py_CLEAR(st->get_dataclass_info);
Py_CLEAR(st->rebuild);
#if PY310_PLUS
Py_CLEAR(st->types_uniontype);
#endif
#if PY312_PLUS
Py_CLEAR(st->typing_typealiastype);
#endif
Expand Down Expand Up @@ -22372,9 +22358,7 @@ msgspec_traverse(PyObject *m, visitproc visit, void *arg)
Py_VISIT(st->get_typeddict_info);
Py_VISIT(st->get_dataclass_info);
Py_VISIT(st->rebuild);
#if PY310_PLUS
Py_VISIT(st->types_uniontype);
#endif
#if PY312_PLUS
Py_VISIT(st->typing_typealiastype);
#endif
Expand Down Expand Up @@ -22594,12 +22578,10 @@ PyInit__core(void)
SET_REF(rebuild, "rebuild");
Py_DECREF(temp_module);

#if PY310_PLUS
temp_module = PyImport_ImportModule("types");
if (temp_module == NULL) return NULL;
SET_REF(types_uniontype, "UnionType");
Py_DECREF(temp_module);
#endif

/* Get the EnumMeta type */
temp_module = PyImport_ImportModule("enum");
Expand Down
21 changes: 0 additions & 21 deletions src/msgspec/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,7 @@ def _forward_ref(value):

def _eval_type(t, globalns, localns):
return typing._eval_type(t, globalns, localns, ())
elif sys.version_info < (3, 10):

def _eval_type(t, globalns, localns):
try:
return typing._eval_type(t, globalns, localns)
except TypeError as e:
try:
from eval_type_backport import eval_type_backport
except ImportError:
raise TypeError(
f"Unable to evaluate type annotation {t.__forward_arg__!r}. If you are making use "
"of the new typing syntax (unions using `|` since Python 3.10 or builtins subscripting "
"since Python 3.9), you should either replace the use of new syntax with the existing "
"`typing` constructs or install the `eval_type_backport` package."
) from e

return eval_type_backport(
t,
globalns,
localns,
try_default=False,
)
else:
_eval_type = typing._eval_type

Expand Down