mirror of https://github.com/pyodide/pyodide.git
add msgspec 0.18.4 (#4265)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
ea6b971ceb
commit
9c498a8d4f
|
@ -51,6 +51,8 @@ myst:
|
|||
|
||||
- Added `zengl` version 1.16.0 {pr}`4208`
|
||||
|
||||
- Added `msgspec` version 0.18.4 {pr}`4265`
|
||||
|
||||
### Load time & size optimizations
|
||||
|
||||
- {{ Performance }} Do not use `importlib.metadata` when identifying installed packages,
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package:
|
||||
name: msgspec
|
||||
version: 0.18.4
|
||||
top-level:
|
||||
- msgspec
|
||||
source:
|
||||
sha256: cb62030bd6b1a00b01a2fcb09735016011696304e6b1d3321e58022548268d3e
|
||||
url: https://files.pythonhosted.org/packages/f2/5f/d202be1baac094064d3c4d2bd926b5ff83002fe411410b225d0c88f8c5ba/msgspec-0.18.4.tar.gz
|
||||
about:
|
||||
home: https://jcristharif.com/msgspec
|
||||
PyPI: https://pypi.org/project/msgspec
|
||||
summary: A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML.
|
||||
license: BSD-3-Clause
|
|
@ -0,0 +1,28 @@
|
|||
from pytest_pyodide import run_in_pyodide
|
||||
|
||||
|
||||
@run_in_pyodide(packages=["msgspec"])
|
||||
def test_msgspec(selenium_standalone):
|
||||
import msgspec
|
||||
import pytest
|
||||
|
||||
class User(msgspec.Struct):
|
||||
"""A new type describing a User"""
|
||||
|
||||
name: str
|
||||
groups: set[str] = set()
|
||||
email: str | None = None
|
||||
|
||||
alice = User("alice", groups={"admin", "engineering"})
|
||||
msg = msgspec.json.encode(alice)
|
||||
|
||||
# set order is undefined
|
||||
assert msg in [
|
||||
b'{"name":"alice","groups":["admin","engineering"],"email":null}',
|
||||
b'{"name":"alice","groups":["engineering","admin"],"email":null}',
|
||||
]
|
||||
|
||||
msgspec.json.decode(msg, type=User)
|
||||
|
||||
with pytest.raises(msgspec.ValidationError, match=r"str.*int.*\$\.groups\[0\]"):
|
||||
msgspec.json.decode(b'{"name":"bob","groups":[123]}', type=User)
|
Loading…
Reference in New Issue