diff --git a/Cargo.lock b/Cargo.lock index 557acf5a..74b97974 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -127,9 +127,9 @@ checksum = "9028f49264629065d057f340a86acb84867925865f73bbf8d47b4d149a7e88b8" [[package]] name = "libc" -version = "0.2.149" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libm" @@ -139,9 +139,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "no-panic" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71a6d126424f5ce0bb4587ff4561421d44aeede520541cc66f1bb912506ae46a" +checksum = "bf98081e1af7145ec0f77baf9ec845903ccb6ae4a8b1e881265d5487f37f90a2" dependencies = [ "proc-macro2", "quote", @@ -255,18 +255,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.190" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.190" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -275,9 +275,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -292,9 +292,9 @@ checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "static_assertions" @@ -304,9 +304,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "syn" -version = "2.0.38" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -333,18 +333,18 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "zerocopy" -version = "0.7.15" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ba595b9f2772fbee2312de30eeb80ec773b4cb2f1e8098db024afadda6c06f" +checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.15" +version = "0.7.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "772666c41fb6dceaf520b564b962d738a8e1a83b41bd48945f50837aed78bb1d" +checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" dependencies = [ "proc-macro2", "quote", diff --git a/integration/wsgi.py b/integration/wsgi.py index 7e20e9b0..b5d4d4c4 100644 --- a/integration/wsgi.py +++ b/integration/wsgi.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) -from datetime import datetime +from datetime import datetime, timezone from uuid import uuid4 from flask import Flask @@ -9,7 +9,7 @@ app = Flask(__name__) -NOW = datetime.utcnow() +NOW = datetime.now(timezone.utc) @app.route("/") diff --git a/pyproject.toml b/pyproject.toml index 276703ed..58007e5f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,20 +39,21 @@ include = [ { format = "sdist", path = "include/**/*" }, ] - -[tool.black] -line-length = 88 -target-version = ["py38"] -include = ".pyi?$" - [tool.ruff] line-length = 88 target-version = "py38" +select = [ + "I", +] + ignore = [ "E501", # line too long "F601", # Dictionary key literal ... repeated ] +[tool.ruff.lint.isort] +known-first-party = ["orjson"] + [tool.mypy] python_version = "3.8" diff --git a/requirements.txt b/requirements.txt index c8d3e01a..9ef0c1fd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,6 @@ -r bench/requirements.txt -r integration/requirements.txt -r test/requirements.txt -autoflake -black -isort maturin mypy ruff diff --git a/script/lint b/script/lint index c08a928f..15eed6ec 100755 --- a/script/lint +++ b/script/lint @@ -6,8 +6,6 @@ to_lint="./bench/*.py ./pysrc/orjson/__init__.pyi ./test/*.py script/pydataclass script/pysort script/pynumpy script/pynonstr script/pycorrectness script/graph integration/init integration/wsgi.py integration/typestubs.py integration/thread" -autoflake --in-place --recursive --remove-all-unused-imports --ignore-init-module-imports . -isort ${to_lint} ruff ${to_lint} --fix -black ${to_lint} +ruff format ${to_lint} mypy --ignore-missing-imports --check-untyped-defs ./bench/*.py ./pysrc/orjson/__init__.pyi ./test/*.py diff --git a/script/pynumpy b/script/pynumpy index df7a1194..102a395d 100755 --- a/script/pynumpy +++ b/script/pynumpy @@ -39,9 +39,7 @@ elif kind == "int32": elif kind == "uint8": array = numpy.random.randint(((2**8) - 1), size=(100000, 100), dtype=numpy.uint8) elif kind == "uint16": - array = numpy.random.randint( - ((2**16) - 1), size=(100000, 100), dtype=numpy.uint16 - ) + array = numpy.random.randint(((2**16) - 1), size=(100000, 100), dtype=numpy.uint16) else: print("usage: pynumpy (bool|int16|int32|float64|int8|uint8|uint16)") sys.exit(1) diff --git a/src/deserialize/yyjson.rs b/src/deserialize/yyjson.rs index c8c5b774..0fc8f6f3 100644 --- a/src/deserialize/yyjson.rs +++ b/src/deserialize/yyjson.rs @@ -164,10 +164,7 @@ fn parse_yy_object(elem: *mut yyjson_val) -> NonNull { return nonnull!(ffi!(PyDict_New())); } let mut key = unsafe_yyjson_get_first(elem); - #[cfg(not(Py_3_13))] let dict = ffi!(_PyDict_NewPresized(len as isize)); - #[cfg(Py_3_13)] - let dict = ffi!(PyDict_New()); for _ in 0..=len - 1 { let val = key.add(1); let key_str = str_from_slice!((*key).uni.str_ as *const u8, unsafe_yyjson_get_len(key)); diff --git a/src/typeref.rs b/src/typeref.rs index 55dad15c..242a8275 100644 --- a/src/typeref.rs +++ b/src/typeref.rs @@ -236,11 +236,9 @@ unsafe fn look_up_json_exc() -> *mut PyObject { #[cold] #[cfg_attr(feature = "optimize", optimize(size))] -unsafe fn look_up_numpy_type(numpy_module: *mut PyObject, np_type: &str) -> *mut PyTypeObject { - let mod_dict = PyObject_GenericGetDict(numpy_module, null_mut()); - let ptr = PyMapping_GetItemString(mod_dict, np_type.as_ptr() as *const c_char); +unsafe fn look_up_numpy_type(numpy_module_dict: *mut PyObject, np_type: &str) -> *mut PyTypeObject { + let ptr = PyMapping_GetItemString(numpy_module_dict, np_type.as_ptr() as *const c_char); Py_XDECREF(ptr); - Py_XDECREF(mod_dict); ptr as *mut PyTypeObject } @@ -253,21 +251,23 @@ pub fn load_numpy_types() -> Box>> { PyErr_Clear(); return Box::new(None); } + let numpy_module_dict = PyObject_GenericGetDict(numpy, null_mut()); let types = Box::new(NumpyTypes { - array: look_up_numpy_type(numpy, "ndarray\0"), - float32: look_up_numpy_type(numpy, "float32\0"), - float64: look_up_numpy_type(numpy, "float64\0"), - int8: look_up_numpy_type(numpy, "int8\0"), - int16: look_up_numpy_type(numpy, "int16\0"), - int32: look_up_numpy_type(numpy, "int32\0"), - int64: look_up_numpy_type(numpy, "int64\0"), - uint16: look_up_numpy_type(numpy, "uint16\0"), - uint32: look_up_numpy_type(numpy, "uint32\0"), - uint64: look_up_numpy_type(numpy, "uint64\0"), - uint8: look_up_numpy_type(numpy, "uint8\0"), - bool_: look_up_numpy_type(numpy, "bool_\0"), - datetime64: look_up_numpy_type(numpy, "datetime64\0"), + array: look_up_numpy_type(numpy_module_dict, "ndarray\0"), + float32: look_up_numpy_type(numpy_module_dict, "float32\0"), + float64: look_up_numpy_type(numpy_module_dict, "float64\0"), + int8: look_up_numpy_type(numpy_module_dict, "int8\0"), + int16: look_up_numpy_type(numpy_module_dict, "int16\0"), + int32: look_up_numpy_type(numpy_module_dict, "int32\0"), + int64: look_up_numpy_type(numpy_module_dict, "int64\0"), + uint16: look_up_numpy_type(numpy_module_dict, "uint16\0"), + uint32: look_up_numpy_type(numpy_module_dict, "uint32\0"), + uint64: look_up_numpy_type(numpy_module_dict, "uint64\0"), + uint8: look_up_numpy_type(numpy_module_dict, "uint8\0"), + bool_: look_up_numpy_type(numpy_module_dict, "bool_\0"), + datetime64: look_up_numpy_type(numpy_module_dict, "datetime64\0"), }); + Py_XDECREF(numpy_module_dict); Py_XDECREF(numpy); Box::new(Some(nonnull!(Box::::into_raw(types)))) }