From a254c73c75a5c752135931074a5fcdb52e9edabd Mon Sep 17 00:00:00 2001 From: "chandr-andr (Kiselev Aleksandr)" Date: Mon, 2 Dec 2024 21:45:41 +0100 Subject: [PATCH 1/4] Test Signed-off-by: chandr-andr (Kiselev Aleksandr) --- .pre-commit-config.yaml | 25 +- Cargo.lock | 396 ++++++++---------- examples/aiohttp/start_example.py | 1 - examples/fastapi/advanced_example.py | 3 - examples/fastapi/start_example.py | 3 +- psqlpy-stress/psqlpy_stress/api/piccolo.py | 4 +- .../psqlpy_stress/api/plain_queries.py | 4 +- psqlpy-stress/psqlpy_stress/migrations/env.py | 1 + .../versions/06d989926550_basic_user_table.py | 20 +- .../versions/d162c084f522_big_af_table.py | 3 +- pyproject.toml | 75 ++-- python/psqlpy/__init__.py | 20 +- python/psqlpy/_internal/__init__.pyi | 148 +++---- python/psqlpy/_internal/extra_types.pyi | 256 ++--------- python/psqlpy/_internal/row_factories.pyi | 6 +- python/psqlpy/exceptions.py | 30 +- python/psqlpy/extra_types.py | 76 ++-- python/psqlpy/row_factories.py | 2 +- python/tests/conftest.py | 27 +- python/tests/test_binary_copy.py | 3 +- python/tests/test_connection.py | 9 +- python/tests/test_connection_pool.py | 1 - python/tests/test_connection_pool_builder.py | 1 - python/tests/test_cursor.py | 6 +- python/tests/test_row_factories.py | 1 - python/tests/test_ssl_mode.py | 9 +- python/tests/test_transaction.py | 8 +- python/tests/test_value_converter.py | 25 +- 28 files changed, 441 insertions(+), 722 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 47f22330..6ba59e49 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,22 +3,6 @@ repos: rev: v2.1.0 hooks: - id: trailing-whitespace - - repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort - name: python isort - pass_filenames: false - always_run: true - args: ["python"] - - repo: https://github.com/psf/black - rev: 23.9.1 - hooks: - - id: black - name: python black - pass_filenames: false - always_run: true - args: ["python"] - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.5.1 hooks: @@ -28,13 +12,18 @@ repos: pass_filenames: false args: ["python"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.291 + rev: v0.8.1 hooks: - id: ruff name: ruff pass_filenames: false always_run: true args: ["python", "--fix"] + - id: ruff-format + name: ruff + pass_filenames: false + always_run: true + args: ["python"] - repo: local hooks: - id: fmt @@ -77,4 +66,4 @@ repos: entry: cargo pass_filenames: false args: - - check \ No newline at end of file + - check diff --git a/Cargo.lock b/Cargo.lock index 99db18ac..83b8cd3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,18 +4,18 @@ version = 3 [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "ahash" @@ -69,40 +69,40 @@ checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.90", ] [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets", ] [[package]] @@ -111,12 +111,6 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.6.0" @@ -146,9 +140,9 @@ dependencies = [ [[package]] name = "borsh" -version = "1.5.1" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6362ed55def622cddc70a4746a68554d7b687713770de539e59a739b249f8ed" +checksum = "2506947f73ad44e344215ccd6403ac2ae18cd8e046e581a441bf8d199f257f03" dependencies = [ "borsh-derive", "cfg_aliases", @@ -156,16 +150,15 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.5.1" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ef8005764f53cd4dca619f5bf64cafd4664dada50ece25e4d81de54c80cc0b" +checksum = "c2593a3b8b938bd68373196c9832f516be11fa487ef4ae745eb282e6a56a7244" dependencies = [ "once_cell", "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.72", - "syn_derive", + "syn 2.0.90", ] [[package]] @@ -204,15 +197,18 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "cc" -version = "1.1.7" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" +checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -264,15 +260,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" dependencies = [ "libc", ] @@ -424,7 +420,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.90", ] [[package]] @@ -469,9 +465,9 @@ dependencies = [ [[package]] name = "geo-types" -version = "0.7.13" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff16065e5720f376fbced200a5ae0f47ace85fd70b7e54269790281353b6d61" +checksum = "b6f47c611187777bbca61ea7aba780213f5f3441fd36294ab333e96cfa791b65" dependencies = [ "approx", "num-traits", @@ -493,9 +489,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "hashbrown" @@ -508,9 +504,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "heck" @@ -535,9 +531,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -558,12 +554,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.5.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown 0.15.2", ] [[package]] @@ -583,30 +579,31 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" dependencies = [ + "once_cell", "wasm-bindgen", ] [[package]] name = "libc" -version = "0.2.155" +version = "0.2.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" [[package]] name = "libm" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] name = "lock_api" @@ -657,20 +654,19 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] name = "mio" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi", "libc", "wasi", "windows-sys", @@ -698,26 +694,26 @@ dependencies = [ [[package]] name = "object" -version = "0.36.2" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "openssl" -version = "0.10.64" +version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ - "bitflags 2.6.0", + "bitflags", "cfg-if", "foreign-types", "libc", @@ -734,23 +730,23 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.90", ] [[package]] name = "openssl-src" -version = "300.2.2+3.2.1" +version = "300.4.1+3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bbfad0063610ac26ee79f7484739e2b07555a75c42453b89263830b5c8103bc" +checksum = "faa4eac4138c62414b5622d1b31c5c304f34b406b013c079c2bbc652fdd6678c" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.102" +version = "0.9.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ "cc", "libc", @@ -777,7 +773,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.3", + "redox_syscall", "smallvec", "windows-targets", ] @@ -856,9 +852,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -868,15 +864,15 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "portable-atomic" -version = "1.7.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" +checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" [[package]] name = "postgres-derive" @@ -886,7 +882,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.90", ] [[package]] @@ -963,34 +959,11 @@ dependencies = [ "toml_edit", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -1019,7 +992,7 @@ dependencies = [ "postgres_array", "pyo3", "pyo3-async-runtimes", - "rust_decimal 1.36.0", + "rust_decimal 1.36.0 (git+https://github.com/chandr-andr/rust-decimal.git?branch=psqlpy)", "serde", "serde_json", "thiserror", @@ -1050,9 +1023,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d922163ba1f79c04bc49073ba7b32fd5a8d3b76a87c955921234b8e77333c51" +checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884" dependencies = [ "cfg-if", "chrono", @@ -1064,7 +1037,7 @@ dependencies = [ "pyo3-build-config", "pyo3-ffi", "pyo3-macros", - "rust_decimal 1.35.0", + "rust_decimal 1.36.0 (registry+https://github.com/rust-lang/crates.io-index)", "unindent", ] @@ -1082,9 +1055,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc38c5feeb496c8321091edf3d63e9a6829eab4b863b4a6a65f26f3e9cc6b179" +checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38" dependencies = [ "once_cell", "target-lexicon", @@ -1092,9 +1065,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94845622d88ae274d2729fcefc850e63d7a3ddff5e3ce11bd88486db9f1d357d" +checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636" dependencies = [ "libc", "pyo3-build-config", @@ -1102,34 +1075,34 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e655aad15e09b94ffdb3ce3d217acf652e26bbc37697ef012f5e5e348c716e5e" +checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453" dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.72", + "syn 2.0.90", ] [[package]] name = "pyo3-macros-backend" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1e3f09eecd94618f60a455a23def79f79eba4dc561a97324bf9ac8c6df30ce" +checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe" dependencies = [ "heck", "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.72", + "syn 2.0.90", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -1172,27 +1145,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.5.3" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ - "bitflags 2.6.0", + "bitflags", ] [[package]] name = "regex" -version = "1.10.6" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -1202,9 +1166,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -1213,9 +1177,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rend" @@ -1257,9 +1221,9 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.35.0" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1790d1c4c0ca81211399e0e0af16333276f375209e71a37b67698a373db5b47a" +checksum = "b082d80e3e3cc52b2ed634388d436fe1f4de6af5786cc2de9ba9737527bdf555" dependencies = [ "arrayvec", "num-traits", @@ -1307,29 +1271,29 @@ checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] name = "serde" -version = "1.0.205" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.205" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.90", ] [[package]] name = "serde_json" -version = "1.0.122" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -1348,6 +1312,12 @@ dependencies = [ "digest", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -1359,9 +1329,9 @@ dependencies = [ [[package]] name = "simdutf8" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" [[package]] name = "siphasher" @@ -1386,9 +1356,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys", @@ -1424,27 +1394,15 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.72" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "syn_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 2.0.72", -] - [[package]] name = "tap" version = "1.0.1" @@ -1459,22 +1417,22 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.90", ] [[package]] @@ -1494,9 +1452,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.2" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" dependencies = [ "backtrace", "bytes", @@ -1518,16 +1476,15 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.90", ] [[package]] name = "tokio-openssl" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ffab79df67727f6acf57f1ff743091873c24c579b1e2ce4d8f53e47ded4d63d" +checksum = "59df6849caa43bb7567f9a36f863c447d95a11d5903c9cc334ba32576a27eadd" dependencies = [ - "futures-util", "openssl", "openssl-sys", "tokio", @@ -1560,9 +1517,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -1579,9 +1536,9 @@ checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "toml_datetime", @@ -1590,9 +1547,9 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", "tracing-attributes", @@ -1601,20 +1558,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.90", ] [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", ] @@ -1627,30 +1584,30 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] name = "unicode-properties" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4259d9d4425d9f0661581b804cb85fe66a4c631cadd8f490d1c13a35d5d9291" +checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" [[package]] name = "unindent" @@ -1660,9 +1617,9 @@ checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" [[package]] name = "uuid" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" dependencies = [ "getrandom", ] @@ -1693,34 +1650,35 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.90", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1728,28 +1686,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "a98bc3c33f0fe7e59ad7cd041b89034fa82a7c2d4365ca538dda6cdaf513863c" dependencies = [ "js-sys", "wasm-bindgen", @@ -1757,11 +1715,11 @@ dependencies = [ [[package]] name = "whoami" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44ab49fad634e88f55bf8f9bb3abd2f27d7204172a112c7c9987e01c1c94ea9" +checksum = "372d5b87f58ec45c384ba03563b03544dc5fadc3983e434b286913f5b4a9bb6d" dependencies = [ - "redox_syscall 0.4.1", + "redox_syscall", "wasite", "web-sys", ] @@ -1850,9 +1808,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -1884,5 +1842,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.90", ] diff --git a/examples/aiohttp/start_example.py b/examples/aiohttp/start_example.py index 6db35090..1ac2e1f0 100644 --- a/examples/aiohttp/start_example.py +++ b/examples/aiohttp/start_example.py @@ -3,7 +3,6 @@ from typing import Any, cast from aiohttp import web - from psqlpy import PSQLPool diff --git a/examples/fastapi/advanced_example.py b/examples/fastapi/advanced_example.py index 34102eae..934e4ed2 100644 --- a/examples/fastapi/advanced_example.py +++ b/examples/fastapi/advanced_example.py @@ -6,7 +6,6 @@ import uvicorn from fastapi import FastAPI from fastapi.responses import JSONResponse - from psqlpy import PSQLPool db_pool = PSQLPool( @@ -28,9 +27,7 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]: async def some_long_func() -> None: # Some very long execution. - print("Executing...") await asyncio.sleep(10) - print("Done.") @app.get("/") diff --git a/examples/fastapi/start_example.py b/examples/fastapi/start_example.py index 34b60bfc..e0277926 100644 --- a/examples/fastapi/start_example.py +++ b/examples/fastapi/start_example.py @@ -5,9 +5,8 @@ import uvicorn from fastapi import Depends, FastAPI, Request from fastapi.responses import JSONResponse -from typing_extensions import Annotated - from psqlpy import Connection, PSQLPool +from typing_extensions import Annotated @asynccontextmanager diff --git a/psqlpy-stress/psqlpy_stress/api/piccolo.py b/psqlpy-stress/psqlpy_stress/api/piccolo.py index 32348049..1f8ce4c3 100644 --- a/psqlpy-stress/psqlpy_stress/api/piccolo.py +++ b/psqlpy-stress/psqlpy_stress/api/piccolo.py @@ -43,7 +43,7 @@ async def asyncpg_simple_connection_select_piccolo( return web.Response(status=200, text="Ok") -# --------------------------------------------- Hard queries handlers starting here --------------------------------------------- +# ------------ Hard queries handlers starting here ------------ async def psqlpy_hard_transaction_select_piccolo( @@ -79,7 +79,7 @@ async def asyncpg_hard_connection_select_piccolo( return web.Response(status=200, text="Ok") -# --------------------------------------------- Combined queries (select + insert) handlers starting here --------------------------------------------- +# ------------ Combined queries (select + insert) handlers starting here ------------ async def psqlpy_combined_transaction_query_piccolo( diff --git a/psqlpy-stress/psqlpy_stress/api/plain_queries.py b/psqlpy-stress/psqlpy_stress/api/plain_queries.py index 174c906c..1ba12724 100644 --- a/psqlpy-stress/psqlpy_stress/api/plain_queries.py +++ b/psqlpy-stress/psqlpy_stress/api/plain_queries.py @@ -97,7 +97,7 @@ async def psycopg_simple_pool_select(request: web.Request) -> web.Response: return web.Response(status=200, text="Ok") -# --------------------------------------------- Hard queries handlers starting here --------------------------------------------- +# ------------ Hard queries handlers starting here ------------ async def psqlpy_hard_transaction_select(request: web.Request) -> web.Response: @@ -187,7 +187,7 @@ async def psycopg_hard_pool_select(request: web.Request) -> web.Response: return web.Response(status=200, text="Ok") -# --------------------------------------------- Combined queries (select + insert) handlers starting here --------------------------------------------- +# ------------ Combined queries (select + insert) handlers starting here ------------ async def psqlpy_combined_transaction_query(request: web.Request) -> web.Response: diff --git a/psqlpy-stress/psqlpy_stress/migrations/env.py b/psqlpy-stress/psqlpy_stress/migrations/env.py index 513d36e5..9b2bef02 100644 --- a/psqlpy-stress/psqlpy_stress/migrations/env.py +++ b/psqlpy-stress/psqlpy_stress/migrations/env.py @@ -1,3 +1,4 @@ +# noqa: INP001 from logging.config import fileConfig from alembic import context diff --git a/psqlpy-stress/psqlpy_stress/migrations/versions/06d989926550_basic_user_table.py b/psqlpy-stress/psqlpy_stress/migrations/versions/06d989926550_basic_user_table.py index b512af43..bbfe4061 100644 --- a/psqlpy-stress/psqlpy_stress/migrations/versions/06d989926550_basic_user_table.py +++ b/psqlpy-stress/psqlpy_stress/migrations/versions/06d989926550_basic_user_table.py @@ -5,14 +5,16 @@ Create Date: 2024-04-06 12:33:16.052321 """ -from typing import Sequence, Union -from alembic import op +from collections.abc import Sequence +from typing import Union + import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision: str = '06d989926550' +revision: str = "06d989926550" down_revision: Union[str, None] = None branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None @@ -21,16 +23,16 @@ def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.create_table( - 'users', - sa.Column('user_id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('username', sa.String(), nullable=False), - sa.PrimaryKeyConstraint('user_id'), - sa.UniqueConstraint('username'), + "users", + sa.Column("user_id", sa.Integer(), autoincrement=True, nullable=False), + sa.Column("username", sa.String(), nullable=False), + sa.PrimaryKeyConstraint("user_id"), + sa.UniqueConstraint("username"), ) # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('users') + op.drop_table("users") # ### end Alembic commands ### diff --git a/psqlpy-stress/psqlpy_stress/migrations/versions/d162c084f522_big_af_table.py b/psqlpy-stress/psqlpy_stress/migrations/versions/d162c084f522_big_af_table.py index b2c4117e..771e0c26 100644 --- a/psqlpy-stress/psqlpy_stress/migrations/versions/d162c084f522_big_af_table.py +++ b/psqlpy-stress/psqlpy_stress/migrations/versions/d162c084f522_big_af_table.py @@ -6,7 +6,8 @@ """ -from typing import Sequence, Union +from collections.abc import Sequence +from typing import Union import sqlalchemy as sa from alembic import op diff --git a/pyproject.toml b/pyproject.toml index a4aaaf9b..bc906612 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,13 +48,6 @@ homepage = "https://github.com/psqlpy-python/psqlpy" repository = "https://github.com/psqlpy-python/psqlpy" documentation = "https://psqlpy-python.github.io/" -[tool.isort] -profile = "black" -multi_line_output = 3 - -[tool.black] -line-length = 120 - [tool.mypy] strict = true mypy_path = "python" @@ -69,51 +62,31 @@ warn_return_any = false warn_unused_ignores = false [tool.ruff] -# List of enabled rulsets. -# See https://docs.astral.sh/ruff/rules/ for more information. -select = [ - "E", # Error - "F", # Pyflakes - "W", # Pycodestyle - "C90", # McCabe complexity - "N", # pep8-naming - "D", # Pydocstyle - "ANN", # Pytype annotations - "S", # Bandit - "B", # Bugbear - "COM", # Commas - "C4", # Comprehensions - "ISC", # Implicit string concat - "PIE", # Unnecessary code - "T20", # Catch prints - "PYI", # validate pyi files - "Q", # Checks for quotes - "RSE", # Checks raise statements - "RET", # Checks return statements - "SLF", # Self checks - "SIM", # Simplificator - "PTH", # Pathlib checks - "ERA", # Checks for commented out code - "PL", # PyLint checks - "RUF", # Specific to Ruff checks -] +fix = true +unsafe-fixes = true +line-length = 120 +exclude = [".venv/", "psqlpy-stress"] + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +select = ["ALL"] ignore = [ - "D105", # Missing docstring in magic method - "D107", # Missing docstring in __init__ - "D211", # No blank lines allowed before class docstring - "D212", # Multi-line docstring summary should start at the first line - "D401", # First line should be in imperative mood - "D104", # Missing docstring in public package - "D100", # Missing docstring in public module - "ANN102", # Missing type annotation for self in method - "ANN101", # Missing type annotation for argument - "ANN401", # typing.Any are disallowed in `**kwargs - "PLR0913", # Too many arguments for function call - "D106", # Missing docstring in public nested class + "EM", + "FBT", + "TRY003", + "D1", + "D203", + "D213", + "G004", + "FA", + "ANN401", + "PLR0913", + "E721", + "A002", + "S311", ] -exclude = [".venv/"] -mccabe = { max-complexity = 10 } -line-length = 120 [tool.ruff.per-file-ignores] "python/psqlpy/*" = ["PYI021"] @@ -123,6 +96,8 @@ line-length = 120 "D103", # Missing docstring in public function "S311", # Standard pseudo-random generators are not suitable for security/cryptographic purposes ] +"./psqlpy-stress/psqlpy_stress/migrations/env.py" = ["INP001"] +"examples/*" = ["INP001"] [tool.ruff.pydocstyle] convention = "pep257" diff --git a/python/psqlpy/__init__.py b/python/psqlpy/__init__.py index 3eaa441b..0fb00d10 100644 --- a/python/psqlpy/__init__.py +++ b/python/psqlpy/__init__.py @@ -18,20 +18,20 @@ ) __all__ = [ - "ConnectionPool", - "Transaction", + "ConnRecyclingMethod", "Connection", + "ConnectionPool", + "ConnectionPoolBuilder", "Cursor", - "QueryResult", - "SingleQueryResult", - "ConnRecyclingMethod", "IsolationLevel", - "ReadVariant", - "connect", + "KeepaliveConfig", "LoadBalanceHosts", - "TargetSessionAttrs", + "QueryResult", + "ReadVariant", + "SingleQueryResult", "SslMode", - "KeepaliveConfig", - "ConnectionPoolBuilder", "SynchronousCommit", + "TargetSessionAttrs", + "Transaction", + "connect", ] diff --git a/python/psqlpy/_internal/__init__.pyi b/python/psqlpy/_internal/__init__.pyi index ce36ef2d..ff960651 100644 --- a/python/psqlpy/_internal/__init__.pyi +++ b/python/psqlpy/_internal/__init__.pyi @@ -2,7 +2,7 @@ import types from enum import Enum from io import BytesIO from ipaddress import IPv4Address, IPv6Address -from typing import Any, Callable, List, Optional, Sequence, TypeVar, Union +from typing import Any, Callable, Sequence, TypeVar from typing_extensions import Buffer, Self @@ -43,12 +43,10 @@ class QueryResult: from psqlpy import PSQLPool, QueryResult - class ExampleOfAsClass: def __init__(self, username: str) -> None: self.username = username - async def main() -> None: db_pool = PSQLPool() query_result: QueryResult = await db_pool.execute( @@ -111,12 +109,10 @@ class SingleQueryResult: from psqlpy import PSQLPool, QueryResult - class ExampleOfAsClass: def __init__(self, username: str) -> None: self.username = username - async def main() -> None: db_pool = PSQLPool() connection = await db_pool.connection() @@ -472,7 +468,6 @@ class Transaction: from psqlpy import PSQLPool, QueryResult - async def main() -> None: db_pool = PSQLPool() connection = await db_pool.connection() @@ -492,7 +487,7 @@ class Transaction: querystring: str, ) -> None: """ - Executes a sequence of SQL statements using the simple query protocol. + Execute a sequence of SQL statements using the simple query protocol. Statements should be separated by semicolons. If an error occurs, execution of the sequence will stop at that point. @@ -585,7 +580,6 @@ class Transaction: from psqlpy import PSQLPool, QueryResult - async def main() -> None: db_pool = PSQLPool() connection = await db_pool.connection() @@ -629,7 +623,6 @@ class Transaction: from psqlpy import PSQLPool, QueryResult - async def main() -> None: db_pool = PSQLPool() connection = await db_pool.connection() @@ -682,7 +675,6 @@ class Transaction: from psqlpy import PSQLPool, QueryResult - async def main() -> None: db_pool = PSQLPool() connection = await db_pool.connection() @@ -704,7 +696,6 @@ class Transaction: ), ] ) - ``` """ async def create_savepoint(self: Self, savepoint_name: str) -> None: @@ -725,7 +716,6 @@ class Transaction: from psqlpy import PSQLPool, QueryResult - async def main() -> None: db_pool = PSQLPool() connection = await db_pool.connection() @@ -748,7 +738,6 @@ class Transaction: from psqlpy import PSQLPool, QueryResult - async def main() -> None: db_pool = PSQLPool() connection = await db_pool.connection() @@ -772,7 +761,6 @@ class Transaction: from psqlpy import PSQLPool, QueryResult - async def main() -> None: db_pool = PSQLPool() connection = await db_pool.connection() @@ -798,7 +786,6 @@ class Transaction: from psqlpy import PSQLPool, QueryResult - async def main() -> None: db_pool = PSQLPool() connection = await db_pool.connection() @@ -837,7 +824,6 @@ class Transaction: from psqlpy import PSQLPool, QueryResult - async def main() -> None: db_pool = PSQLPool() connection = await db_pool.connection() @@ -852,17 +838,17 @@ class Transaction: async for fetched_result in cursor: dict_result: List[Dict[Any, Any]] = fetched_result.result() - ... # do something with this result. + ... # do something with this result. await cursor.close() ``` """ async def binary_copy_to_table( self: Self, - source: Union[bytes, bytearray, Buffer, BytesIO], + source: bytes | bytearray | Buffer | BytesIO, table_name: str, - columns: Optional[Sequence[str]] = None, - schema_name: Optional[str] = None, + columns: Sequence[str] | None = None, + schema_name: str | None = None, ) -> int: """Perform binary copy to PostgreSQL. @@ -921,7 +907,6 @@ class Connection: from psqlpy import PSQLPool, QueryResult - async def main() -> None: db_pool = PSQLPool() connection = await db_pool.connection() @@ -937,7 +922,7 @@ class Connection: querystring: str, ) -> None: """ - Executes a sequence of SQL statements using the simple query protocol. + Execute a sequence of SQL statements using the simple query protocol. Statements should be separated by semicolons. If an error occurs, execution of the sequence will stop at that point. @@ -1025,7 +1010,6 @@ class Connection: from psqlpy import PSQLPool, QueryResult - async def main() -> None: db_pool = PSQLPool() @@ -1066,7 +1050,6 @@ class Connection: from psqlpy import PSQLPool, QueryResult - async def main() -> None: db_pool = PSQLPool() connection = await db_pool.connection() @@ -1121,7 +1104,6 @@ class Connection: from psqlpy import PSQLPool, QueryResult - async def main() -> None: db_pool = PSQLPool() connection = await db_pool.connection() @@ -1133,7 +1115,7 @@ class Connection: ) as cursor: async for fetched_result in cursor: dict_result: List[Dict[Any, Any]] = fetched_result.result() - ... # do something with this result. + ... # do something with this result. ``` """ def back_to_pool(self: Self) -> None: @@ -1144,10 +1126,10 @@ class Connection: """ async def binary_copy_to_table( self: Self, - source: Union[bytes, bytearray, Buffer, BytesIO], + source: bytes | bytearray | Buffer | BytesIO, table_name: str, - columns: Optional[Sequence[str]] = None, - schema_name: Optional[str] = None, + columns: Sequence[str] | None = None, + schema_name: str | None = None, ) -> int: """Perform binary copy to PostgreSQL. @@ -1181,32 +1163,32 @@ class ConnectionPool: def __init__( self: Self, - dsn: Optional[str] = None, - username: Optional[str] = None, - password: Optional[str] = None, - host: Optional[str] = None, - hosts: Optional[List[str]] = None, - port: Optional[int] = None, - ports: Optional[List[int]] = None, - db_name: Optional[str] = None, - target_session_attrs: Optional[TargetSessionAttrs] = None, - options: Optional[str] = None, - application_name: Optional[str] = None, - connect_timeout_sec: Optional[int] = None, - connect_timeout_nanosec: Optional[int] = None, - tcp_user_timeout_sec: Optional[int] = None, - tcp_user_timeout_nanosec: Optional[int] = None, - keepalives: Optional[bool] = None, - keepalives_idle_sec: Optional[int] = None, - keepalives_idle_nanosec: Optional[int] = None, - keepalives_interval_sec: Optional[int] = None, - keepalives_interval_nanosec: Optional[int] = None, - keepalives_retries: Optional[int] = None, - load_balance_hosts: Optional[LoadBalanceHosts] = None, + dsn: str | None = None, + username: str | None = None, + password: str | None = None, + host: str | None = None, + hosts: list[str] | None = None, + port: int | None = None, + ports: list[int] | None = None, + db_name: str | None = None, + target_session_attrs: TargetSessionAttrs | None = None, + options: str | None = None, + application_name: str | None = None, + connect_timeout_sec: int | None = None, + connect_timeout_nanosec: int | None = None, + tcp_user_timeout_sec: int | None = None, + tcp_user_timeout_nanosec: int | None = None, + keepalives: bool | None = None, + keepalives_idle_sec: int | None = None, + keepalives_idle_nanosec: int | None = None, + keepalives_interval_sec: int | None = None, + keepalives_interval_nanosec: int | None = None, + keepalives_retries: int | None = None, + load_balance_hosts: LoadBalanceHosts | None = None, max_db_pool_size: int = 2, - conn_recycling_method: Optional[ConnRecyclingMethod] = None, - ssl_mode: Optional[SslMode] = None, - ca_file: Optional[str] = None, + conn_recycling_method: ConnRecyclingMethod | None = None, + ssl_mode: SslMode | None = None, + ca_file: str | None = None, ) -> None: """Create new PostgreSQL connection pool. @@ -1325,7 +1307,6 @@ class ConnectionPool: from psqlpy import PSQLPool, QueryResult - async def main() -> None: db_pool = PSQLPool() query_result: QueryResult = await psqlpy.execute( @@ -1373,7 +1354,6 @@ class ConnectionPool: from psqlpy import PSQLPool, QueryResult - async def main() -> None: db_pool = PSQLPool() async with db_pool.acquire() as connection: @@ -1384,32 +1364,32 @@ class ConnectionPool: """Close the connection pool.""" def connect( - dsn: Optional[str] = None, - username: Optional[str] = None, - password: Optional[str] = None, - host: Optional[str] = None, - hosts: Optional[List[str]] = None, - port: Optional[int] = None, - ports: Optional[List[int]] = None, - db_name: Optional[str] = None, - target_session_attrs: Optional[TargetSessionAttrs] = None, - options: Optional[str] = None, - application_name: Optional[str] = None, - connect_timeout_sec: Optional[int] = None, - connect_timeout_nanosec: Optional[int] = None, - tcp_user_timeout_sec: Optional[int] = None, - tcp_user_timeout_nanosec: Optional[int] = None, - keepalives: Optional[bool] = None, - keepalives_idle_sec: Optional[int] = None, - keepalives_idle_nanosec: Optional[int] = None, - keepalives_interval_sec: Optional[int] = None, - keepalives_interval_nanosec: Optional[int] = None, - keepalives_retries: Optional[int] = None, - load_balance_hosts: Optional[LoadBalanceHosts] = None, + dsn: str | None = None, + username: str | None = None, + password: str | None = None, + host: str | None = None, + hosts: list[str] | None = None, + port: int | None = None, + ports: list[int] | None = None, + db_name: str | None = None, + target_session_attrs: TargetSessionAttrs | None = None, + options: str | None = None, + application_name: str | None = None, + connect_timeout_sec: int | None = None, + connect_timeout_nanosec: int | None = None, + tcp_user_timeout_sec: int | None = None, + tcp_user_timeout_nanosec: int | None = None, + keepalives: bool | None = None, + keepalives_idle_sec: int | None = None, + keepalives_idle_nanosec: int | None = None, + keepalives_interval_sec: int | None = None, + keepalives_interval_nanosec: int | None = None, + keepalives_retries: int | None = None, + load_balance_hosts: LoadBalanceHosts | None = None, max_db_pool_size: int = 2, - conn_recycling_method: Optional[ConnRecyclingMethod] = None, - ssl_mode: Optional[SslMode] = None, - ca_file: Optional[str] = None, + conn_recycling_method: ConnRecyclingMethod | None = None, + ssl_mode: SslMode | None = None, + ca_file: str | None = None, ) -> ConnectionPool: """Create new PostgreSQL connection pool. @@ -1607,7 +1587,7 @@ class ConnectionPoolBuilder: ### Returns: `ConnectionPoolBuilder` """ - def hostaddr(self: Self, hostaddr: Union[IPv4Address, IPv6Address]) -> Self: + def hostaddr(self: Self, hostaddr: IPv4Address | IPv6Address) -> Self: """ Add a hostaddr to the configuration. @@ -1739,7 +1719,7 @@ class ConnectionPoolBuilder: keepalives_interval: int, ) -> Self: """ - Sets the time interval between TCP keepalive probes. + Set the time interval between TCP keepalive probes. On Windows, this sets the value of the tcp_keepalive struct keepalive interval field. @@ -1758,7 +1738,7 @@ class ConnectionPoolBuilder: keepalives_retries: int, ) -> Self: """ - Sets the maximum number of TCP keepalive probes that will be sent before dropping a connection. + Set the maximum number of TCP keepalive probes that will be sent before dropping a connection. This is ignored for Unix domain sockets, or if the `keepalives` option is disabled. diff --git a/python/psqlpy/_internal/extra_types.pyi b/python/psqlpy/_internal/extra_types.pyi index 2f904fda..4e0d1821 100644 --- a/python/psqlpy/_internal/extra_types.pyi +++ b/python/psqlpy/_internal/extra_types.pyi @@ -95,11 +95,7 @@ class PyJSONB: def __init__( self: Self, - value: typing.Union[ - dict[str, typing.Any], - list[dict[str, typing.Any]], - list[typing.Any], - ], + value: dict[str, typing.Any] | list[dict[str, typing.Any]] | list[typing.Any], ) -> None: """Create new instance of PyJSON.B. @@ -114,11 +110,7 @@ class PyJSON: def __init__( self: Self, - value: typing.Union[ - dict[str, typing.Any], - list[dict[str, typing.Any]], - list[typing.Any], - ], + value: dict[str, typing.Any] | list[dict[str, typing.Any]] | list[typing.Any], ) -> None: """Create new instance of PyJSON. @@ -151,16 +143,10 @@ class PyMacAddr8: class PyCustomType: def __init__(self, value: bytes) -> None: ... -Coordinates: typing.TypeAlias = typing.Union[ - list[int | float], - set[int | float], - tuple[int | float, int | float], -] -PairsOfCoordinates: typing.TypeAlias = typing.Union[ - list[Coordinates | int | float], - set[Coordinates | int | float], - tuple[Coordinates | int | float, ...], -] +Coordinates: typing.TypeAlias = list[int | float] | set[int | float] | tuple[int | float, int | float] +PairsOfCoordinates: typing.TypeAlias = ( + list[Coordinates | int | float] | set[Coordinates | int | float] | tuple[Coordinates | int | float, ...] +) class PyPoint: """Represent point field in PostgreSQL and Point in Rust.""" @@ -241,11 +227,7 @@ class PyCircle: def __init__( self: Self, - value: typing.Union[ - list[int | float], - set[int | float], - tuple[int | float, int | float, int | float], - ], + value: list[int | float] | set[int | float] | tuple[int | float, int | float, int | float], ) -> None: """Create new instance of PyCircle. @@ -261,13 +243,7 @@ class BoolArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - bool, - typing.Sequence[bool], - typing.Any, - ], - ], + inner: typing.Sequence[bool | typing.Sequence[bool] | typing.Any,], ) -> None: """Create new instance of BoolArray. @@ -280,13 +256,7 @@ class UUIDArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - UUID, - typing.Sequence[UUID], - typing.Any, - ], - ], + inner: typing.Sequence[UUID | typing.Sequence[UUID] | typing.Any,], ) -> None: """Create new instance of UuidArray. @@ -299,13 +269,7 @@ class VarCharArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - str, - typing.Sequence[str], - typing.Any, - ], - ], + inner: typing.Sequence[str | typing.Sequence[str] | typing.Any,], ) -> None: """Create new instance of VarCharArray. @@ -318,13 +282,7 @@ class TextArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - str, - typing.Sequence[str], - typing.Any, - ], - ], + inner: typing.Sequence[str | typing.Sequence[str] | typing.Any,], ) -> None: """Create new instance of TextArray. @@ -337,13 +295,7 @@ class Int16Array: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - int, - typing.Sequence[int], - typing.Any, - ], - ], + inner: typing.Sequence[int | typing.Sequence[int] | typing.Any,], ) -> None: """Create new instance of Int16Array. @@ -356,13 +308,7 @@ class Int32Array: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - int, - typing.Sequence[int], - typing.Any, - ], - ], + inner: typing.Sequence[int | typing.Sequence[int] | typing.Any,], ) -> None: """Create new instance of Int32Array. @@ -375,13 +321,7 @@ class Int64Array: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - int, - typing.Sequence[int], - typing.Any, - ], - ], + inner: typing.Sequence[int | typing.Sequence[int] | typing.Any,], ) -> None: """Create new instance of Int64Array. @@ -394,13 +334,7 @@ class Float32Array: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - float, - typing.Sequence[float], - typing.Any, - ], - ], + inner: typing.Sequence[float | typing.Sequence[float] | typing.Any,], ) -> None: """Create new instance of Float32Array. @@ -413,13 +347,7 @@ class Float64Array: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - float, - typing.Sequence[float], - typing.Any, - ], - ], + inner: typing.Sequence[float | typing.Sequence[float] | typing.Any,], ) -> None: """Create new instance of Float64Array. @@ -432,13 +360,7 @@ class MoneyArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - int, - typing.Sequence[int], - typing.Any, - ], - ], + inner: typing.Sequence[int | typing.Sequence[int] | typing.Any,], ) -> None: """Create new instance of MoneyArray. @@ -452,13 +374,7 @@ class IpAddressArray: def __init__( self: Self, inner: typing.Sequence[ - typing.Union[ - IPv4Address, - IPv6Address, - typing.Sequence[IPv4Address], - typing.Sequence[IPv6Address], - typing.Any, - ], + IPv4Address | IPv6Address | typing.Sequence[IPv4Address] | typing.Sequence[IPv6Address] | typing.Any, ], ) -> None: """Create new instance of IpAddressArray. @@ -473,13 +389,11 @@ class JSONBArray: def __init__( self: Self, inner: typing.Sequence[ - typing.Union[ - typing.Dict[str, typing.Any], - PyJSONB, - typing.Sequence[typing.Dict[str, typing.Any]], - typing.Sequence[PyJSONB], - typing.Sequence[typing.Any], - ] + dict[str, typing.Any] + | PyJSONB + | typing.Sequence[dict[str, typing.Any]] + | typing.Sequence[PyJSONB] + | typing.Sequence[typing.Any] ], ) -> None: """Create new instance of JSONBArray. @@ -494,13 +408,11 @@ class JSONArray: def __init__( self: Self, inner: typing.Sequence[ - typing.Union[ - typing.Dict[str, typing.Any], - PyJSON, - typing.Sequence[typing.Dict[str, typing.Any]], - typing.Sequence[PyJSON], - typing.Sequence[typing.Any], - ] + dict[str, typing.Any] + | PyJSON + | typing.Sequence[dict[str, typing.Any]] + | typing.Sequence[PyJSON] + | typing.Sequence[typing.Any] ], ) -> None: """Create new instance of JSONArray. @@ -514,13 +426,7 @@ class DateArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - date, - typing.Sequence[date], - typing.Any, - ], - ], + inner: typing.Sequence[date | typing.Sequence[date] | typing.Any,], ) -> None: """Create new instance of DateArray. @@ -533,13 +439,7 @@ class TimeArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - time, - typing.Sequence[time], - typing.Any, - ], - ], + inner: typing.Sequence[time | typing.Sequence[time] | typing.Any,], ) -> None: """Create new instance of DateArray. @@ -552,13 +452,7 @@ class DateTimeArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - datetime, - typing.Sequence[datetime], - typing.Any, - ], - ], + inner: typing.Sequence[datetime | typing.Sequence[datetime] | typing.Any,], ) -> None: """Create new instance of DateArray. @@ -571,13 +465,7 @@ class DateTimeTZArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - datetime, - typing.Sequence[datetime], - typing.Any, - ], - ], + inner: typing.Sequence[datetime | typing.Sequence[datetime] | typing.Any,], ) -> None: """Create new instance of DateArray. @@ -590,13 +478,7 @@ class MacAddr6Array: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - PyMacAddr6, - typing.Sequence[PyMacAddr6], - typing.Any, - ], - ], + inner: typing.Sequence[PyMacAddr6 | typing.Sequence[PyMacAddr6] | typing.Any,], ) -> None: """Create new instance of MacAddr6Array. @@ -609,13 +491,7 @@ class MacAddr8Array: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - PyMacAddr8, - typing.Sequence[PyMacAddr8], - typing.Any, - ], - ], + inner: typing.Sequence[PyMacAddr8 | typing.Sequence[PyMacAddr8] | typing.Any,], ) -> None: """Create new instance of MacAddr8Array. @@ -628,13 +504,7 @@ class NumericArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - Decimal, - typing.Sequence[Decimal], - typing.Any, - ], - ], + inner: typing.Sequence[Decimal | typing.Sequence[Decimal] | typing.Any,], ) -> None: """Create new instance of NumericArray. @@ -647,13 +517,7 @@ class PointArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - PyPoint, - typing.Sequence[PyPoint], - typing.Any, - ], - ], + inner: typing.Sequence[PyPoint | typing.Sequence[PyPoint] | typing.Any,], ) -> None: """Create new instance of PointArray. @@ -666,13 +530,7 @@ class BoxArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - PyBox, - typing.Sequence[PyBox], - typing.Any, - ], - ], + inner: typing.Sequence[PyBox | typing.Sequence[PyBox] | typing.Any,], ) -> None: """Create new instance of BoxArray. @@ -685,13 +543,7 @@ class PathArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - PyPath, - typing.Sequence[PyPath], - typing.Any, - ], - ], + inner: typing.Sequence[PyPath | typing.Sequence[PyPath] | typing.Any,], ) -> None: """Create new instance of PathArray. @@ -704,13 +556,7 @@ class LineArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - PyLine, - typing.Sequence[PyLine], - typing.Any, - ], - ], + inner: typing.Sequence[PyLine | typing.Sequence[PyLine] | typing.Any,], ) -> None: """Create new instance of LineArray. @@ -723,13 +569,7 @@ class LsegArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - PyLineSegment, - typing.Sequence[PyLineSegment], - typing.Any, - ], - ], + inner: typing.Sequence[PyLineSegment | typing.Sequence[PyLineSegment] | typing.Any,], ) -> None: """Create new instance of LsegArray. @@ -742,13 +582,7 @@ class CircleArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - PyCircle, - typing.Sequence[PyCircle], - typing.Any, - ], - ], + inner: typing.Sequence[PyCircle | typing.Sequence[PyCircle] | typing.Any,], ) -> None: """Create new instance of CircleArray. @@ -761,13 +595,7 @@ class IntervalArray: def __init__( self: Self, - inner: typing.Sequence[ - typing.Union[ - timedelta, - typing.Sequence[timedelta], - typing.Any, - ], - ], + inner: typing.Sequence[timedelta | typing.Sequence[timedelta] | typing.Any,], ) -> None: """Create new instance of IntervalArray. diff --git a/python/psqlpy/_internal/row_factories.pyi b/python/psqlpy/_internal/row_factories.pyi index 50f018c0..cade950a 100644 --- a/python/psqlpy/_internal/row_factories.pyi +++ b/python/psqlpy/_internal/row_factories.pyi @@ -1,4 +1,4 @@ -from typing import Any, Generic, Tuple, Type, TypeVar +from typing import Any, Generic, TypeVar from typing_extensions import Self @@ -6,7 +6,7 @@ _CustomClass = TypeVar( "_CustomClass", ) -def tuple_row(row: dict[str, Any]) -> Tuple[Tuple[str, Any]]: +def tuple_row(row: dict[str, Any]) -> tuple[tuple[str, Any]]: """Convert dict row into tuple row. ### Parameters: @@ -50,7 +50,7 @@ class class_row(Generic[_CustomClass]): # noqa: N801 ``` """ - def __init__(self: Self, class_: Type[_CustomClass]) -> None: + def __init__(self: Self, class_: type[_CustomClass]) -> None: """Construct new `class_row`. ### Parameters: diff --git a/python/psqlpy/exceptions.py b/python/psqlpy/exceptions.py index d21545c5..c8240b9e 100644 --- a/python/psqlpy/exceptions.py +++ b/python/psqlpy/exceptions.py @@ -26,28 +26,28 @@ ) __all__ = [ + "BaseConnectionError", "BaseConnectionPoolError", + "BaseCursorError", + "BaseTransactionError", + "ConnectionClosedError", + "ConnectionExecuteError", "ConnectionPoolBuildError", "ConnectionPoolConfigurationError", "ConnectionPoolExecuteError", - "BaseConnectionError", - "ConnectionExecuteError", - "ConnectionClosedError", - "BaseTransactionError", - "TransactionBeginError", - "TransactionCommitError", - "TransactionRollbackError", - "TransactionSavepointError", - "TransactionExecuteError", - "TransactionClosedError", - "BaseCursorError", - "CursorStartError", "CursorCloseError", - "CursorFetchError", "CursorClosedError", + "CursorFetchError", + "CursorStartError", + "MacAddrConversionError", + "PyToRustValueMappingError", "RustPSQLDriverPyBaseError", "RustToPyValueMappingError", - "PyToRustValueMappingError", + "TransactionBeginError", + "TransactionClosedError", + "TransactionCommitError", + "TransactionExecuteError", + "TransactionRollbackError", + "TransactionSavepointError", "UUIDValueConvertError", - "MacAddrConversionError", ] diff --git a/python/psqlpy/extra_types.py b/python/psqlpy/extra_types.py index 03cc4cfe..52299b20 100644 --- a/python/psqlpy/extra_types.py +++ b/python/psqlpy/extra_types.py @@ -49,55 +49,55 @@ ) __all__ = [ - "SmallInt", - "Integer", "BigInt", - "PyJSONB", - "PyJSON", - "PyMacAddr6", - "PyMacAddr8", - "PyVarChar", - "PyText", - "PyCustomType", - "Float32", - "Float64", - "Money", - "PyPoint", - "PyBox", - "PyPath", - "PyLine", - "PyLineSegment", - "PyCircle", "BoolArray", - "UUIDArray", - "JSONBArray", - "JSONArray", "BoolArray", - "UUIDArray", - "VarCharArray", - "TextArray", + "BoxArray", + "CircleArray", + "DateArray", + "DateTimeArray", + "DateTimeTZArray", + "Float32", + "Float32Array", + "Float64", + "Float64Array", "Int16Array", "Int32Array", "Int64Array", - "Float32Array", - "Float64Array", - "MoneyArray", + "Integer", + "IntervalArray", "IpAddressArray", - "JSONBArray", "JSONArray", - "DateArray", - "TimeArray", - "DateTimeArray", - "DateTimeTZArray", + "JSONArray", + "JSONBArray", + "JSONBArray", + "LineArray", + "LsegArray", "MacAddr6Array", "MacAddr8Array", + "Money", + "MoneyArray", "NumericArray", - "PointArray", - "BoxArray", "PathArray", - "LineArray", - "LsegArray", - "CircleArray", - "IntervalArray", "PgVector", + "PointArray", + "PyBox", + "PyCircle", + "PyCustomType", + "PyJSON", + "PyJSONB", + "PyLine", + "PyLineSegment", + "PyMacAddr6", + "PyMacAddr8", + "PyPath", + "PyPoint", + "PyText", + "PyVarChar", + "SmallInt", + "TextArray", + "TimeArray", + "UUIDArray", + "UUIDArray", + "VarCharArray", ] diff --git a/python/psqlpy/row_factories.py b/python/psqlpy/row_factories.py index 1e12744e..25a03303 100644 --- a/python/psqlpy/row_factories.py +++ b/python/psqlpy/row_factories.py @@ -1,6 +1,6 @@ from ._internal.row_factories import class_row, tuple_row __all__ = [ - "tuple_row", "class_row", + "tuple_row", ] diff --git a/python/tests/conftest.py b/python/tests/conftest.py index a798958e..515ff87d 100644 --- a/python/tests/conftest.py +++ b/python/tests/conftest.py @@ -3,10 +3,9 @@ from typing import AsyncGenerator import pytest -from pydantic import BaseModel - from psqlpy import ConnectionPool, Cursor from psqlpy._internal import SslMode +from pydantic import BaseModel class DefaultPydanticModel(BaseModel): @@ -24,7 +23,7 @@ def __init__(self, id: int, name: str) -> None: self.name = name -@pytest.fixture() +@pytest.fixture def anyio_backend() -> str: """ Anyio backend. @@ -39,47 +38,47 @@ def random_string(length: int = 10) -> str: return "".join(random.choice("AbCdEfG") for _ in range(length)) -@pytest.fixture() +@pytest.fixture def postgres_host() -> str: return os.environ.get("POSTGRES_HOST", "localhost") -@pytest.fixture() +@pytest.fixture def postgres_user() -> str: return os.environ.get("POSTGRES_USER", "postgres") -@pytest.fixture() +@pytest.fixture def postgres_password() -> str: return os.environ.get("POSTGRES_PASSWORD", "postgres") -@pytest.fixture() +@pytest.fixture def postgres_port() -> int: return int(os.environ.get("POSTGRES_PORT", 5432)) -@pytest.fixture() +@pytest.fixture def postgres_dbname() -> str: return os.environ.get("POSTGRES_DBNAME", "psqlpy_test") -@pytest.fixture() +@pytest.fixture def table_name() -> str: return random_string() -@pytest.fixture() +@pytest.fixture def number_database_records() -> int: return random.randint(10, 35) -@pytest.fixture() +@pytest.fixture def ssl_cert_file() -> str: return os.environ.get("POSTGRES_CERT_FILE", "./root.crt") -@pytest.fixture() +@pytest.fixture async def psql_pool( postgres_host: str, postgres_user: str, @@ -96,7 +95,7 @@ async def psql_pool( ) -@pytest.fixture() +@pytest.fixture async def psql_pool_with_cert_file( postgres_host: str, postgres_user: str, @@ -138,7 +137,7 @@ async def create_default_data_for_tests( ) -@pytest.fixture() +@pytest.fixture async def test_cursor( psql_pool: ConnectionPool, table_name: str, diff --git a/python/tests/test_binary_copy.py b/python/tests/test_binary_copy.py index e1c3d473..93cc1335 100644 --- a/python/tests/test_binary_copy.py +++ b/python/tests/test_binary_copy.py @@ -4,9 +4,8 @@ import pytest from pgpq import ArrowToPostgresBinaryEncoder -from pyarrow import parquet - from psqlpy import ConnectionPool +from pyarrow import parquet pytestmark = pytest.mark.anyio diff --git a/python/tests/test_connection.py b/python/tests/test_connection.py index f9f72d9a..3c15991a 100644 --- a/python/tests/test_connection.py +++ b/python/tests/test_connection.py @@ -3,8 +3,6 @@ import typing import pytest -from tests.helpers import count_rows_in_test_table - from psqlpy import ConnectionPool, Cursor, QueryResult, Transaction from psqlpy.exceptions import ( ConnectionClosedError, @@ -12,6 +10,8 @@ TransactionExecuteError, ) +from tests.helpers import count_rows_in_test_table + pytestmark = pytest.mark.anyio @@ -137,7 +137,6 @@ async def test_connection_fetch_val_more_than_one_row( async def test_connection_cursor( psql_pool: ConnectionPool, table_name: str, - number_database_records: int, ) -> None: """Test cursor from Connection.""" connection = await psql_pool.connection() @@ -149,10 +148,6 @@ async def test_connection_cursor( await cursor.close() await transaction.commit() - # async with connection.transaction(), connection.cursor( - # ) as cursor: - # async for cur_res in cursor: - async def test_connection_async_context_manager( psql_pool: ConnectionPool, diff --git a/python/tests/test_connection_pool.py b/python/tests/test_connection_pool.py index 6bf9a936..cdf2fa48 100644 --- a/python/tests/test_connection_pool.py +++ b/python/tests/test_connection_pool.py @@ -1,5 +1,4 @@ import pytest - from psqlpy import ( Connection, ConnectionPool, diff --git a/python/tests/test_connection_pool_builder.py b/python/tests/test_connection_pool_builder.py index b14ed3ad..f937bec3 100644 --- a/python/tests/test_connection_pool_builder.py +++ b/python/tests/test_connection_pool_builder.py @@ -1,5 +1,4 @@ import pytest - from psqlpy import ( ConnectionPoolBuilder, ConnRecyclingMethod, diff --git a/python/tests/test_cursor.py b/python/tests/test_cursor.py index 08644c59..07fca375 100644 --- a/python/tests/test_cursor.py +++ b/python/tests/test_cursor.py @@ -1,10 +1,12 @@ from __future__ import annotations import math +from typing import TYPE_CHECKING import pytest -from psqlpy import ConnectionPool, Cursor, QueryResult, Transaction +if TYPE_CHECKING: + from psqlpy import ConnectionPool, Cursor, QueryResult, Transaction pytestmark = pytest.mark.anyio @@ -167,7 +169,7 @@ async def test_cursor_as_async_manager( fetch_number=fetch_number, ) as cursor: async for result in cursor: - all_results.append(result) + all_results.append(result) # noqa: PERF401 assert len(all_results) == expected_num_results diff --git a/python/tests/test_row_factories.py b/python/tests/test_row_factories.py index cd0220e1..75d03e5a 100644 --- a/python/tests/test_row_factories.py +++ b/python/tests/test_row_factories.py @@ -2,7 +2,6 @@ from typing import Any, Callable, Dict, Type import pytest - from psqlpy import ConnectionPool from psqlpy.row_factories import class_row, tuple_row diff --git a/python/tests/test_ssl_mode.py b/python/tests/test_ssl_mode.py index 99f6b9b6..53978d9e 100644 --- a/python/tests/test_ssl_mode.py +++ b/python/tests/test_ssl_mode.py @@ -1,5 +1,4 @@ import pytest - from psqlpy import ConnectionPool, SslMode from psqlpy._internal import ConnectionPoolBuilder @@ -8,14 +7,14 @@ @pytest.mark.parametrize( "ssl_mode", - ( + [ SslMode.Disable, SslMode.Allow, SslMode.Prefer, SslMode.Require, SslMode.VerifyCa, SslMode.VerifyFull, - ), + ], ) async def test_ssl_mode_require( ssl_mode: SslMode, @@ -41,14 +40,14 @@ async def test_ssl_mode_require( @pytest.mark.parametrize( "ssl_mode", - ( + [ SslMode.Disable, SslMode.Allow, SslMode.Prefer, SslMode.Require, SslMode.VerifyCa, SslMode.VerifyFull, - ), + ], ) async def test_ssl_mode_require_pool_builder( ssl_mode: SslMode, diff --git a/python/tests/test_transaction.py b/python/tests/test_transaction.py index 6e34a3d6..7704393b 100644 --- a/python/tests/test_transaction.py +++ b/python/tests/test_transaction.py @@ -3,8 +3,6 @@ import typing import pytest -from tests.helpers import count_rows_in_test_table - from psqlpy import ( ConnectionPool, Cursor, @@ -19,6 +17,8 @@ TransactionSavepointError, ) +from tests.helpers import count_rows_in_test_table + pytestmark = pytest.mark.anyio @@ -355,13 +355,13 @@ async def test_execute_batch_method(psql_pool: ConnectionPool) -> None: @pytest.mark.parametrize( "synchronous_commit", - ( + [ SynchronousCommit.On, SynchronousCommit.Off, SynchronousCommit.Local, SynchronousCommit.RemoteWrite, SynchronousCommit.RemoteApply, - ), + ], ) async def test_synchronous_commit( synchronous_commit: SynchronousCommit, diff --git a/python/tests/test_value_converter.py b/python/tests/test_value_converter.py index 585d30b6..f8f8ade5 100644 --- a/python/tests/test_value_converter.py +++ b/python/tests/test_value_converter.py @@ -6,10 +6,6 @@ from typing import Any, Dict, List, Tuple, Union import pytest -from pydantic import BaseModel -from tests.conftest import DefaultPydanticModel, DefaultPythonModelClass -from typing_extensions import Annotated - from psqlpy import ConnectionPool from psqlpy.exceptions import PyToRustValueMappingError from psqlpy.extra_types import ( @@ -56,9 +52,13 @@ UUIDArray, VarCharArray, ) +from pydantic import BaseModel +from typing_extensions import Annotated + +from tests.conftest import DefaultPydanticModel, DefaultPythonModelClass pytestmark = pytest.mark.anyio -now_datetime = datetime.datetime.now() +now_datetime = datetime.datetime.now() # noqa: DTZ005 now_datetime_with_tz = datetime.datetime( 2024, 4, @@ -101,8 +101,8 @@ async def test_as_class( @pytest.mark.parametrize( - ["postgres_type", "py_value", "expected_deserialized"], - ( + ("postgres_type", "py_value", "expected_deserialized"), + [ ("BYTEA", b"Bytes", b"Bytes"), ("VARCHAR", "Some String", "Some String"), ("TEXT", "Some String", "Some String"), @@ -609,7 +609,7 @@ async def test_as_class( [datetime.timedelta(days=100, microseconds=100), datetime.timedelta(days=100, microseconds=100)], [datetime.timedelta(days=100, microseconds=100), datetime.timedelta(days=100, microseconds=100)], ), - ), + ], ) async def test_deserialization_simple_into_python( psql_pool: ConnectionPool, @@ -963,7 +963,7 @@ async def test_custom_decoder( "INSERT INTO for_test VALUES ('(1, 1)')", ) - def point_encoder(point_bytes: bytes) -> str: + def point_encoder(point_bytes: bytes) -> str: # noqa: ARG001 return "Just An Example" qs_result = await psql_pool.execute( @@ -1057,8 +1057,8 @@ async def test_empty_array( @pytest.mark.parametrize( - ["postgres_type", "py_value", "expected_deserialized"], - ( + ("postgres_type", "py_value", "expected_deserialized"), + [ ( "VARCHAR ARRAY", VarCharArray(["Some String", "Some String"]), @@ -1084,7 +1084,6 @@ async def test_empty_array( ("BOOL ARRAY", BoolArray([[True], [False]]), [[True], [False]]), ("INT2 ARRAY", Int16Array([]), []), ("INT2 ARRAY", Int16Array([SmallInt(12), SmallInt(100)]), [12, 100]), - ("INT2 ARRAY", Int16Array([SmallInt(12), SmallInt(100)]), [12, 100]), ("INT2 ARRAY", Int16Array([[SmallInt(12)], [SmallInt(100)]]), [[12], [100]]), ("INT4 ARRAY", Int32Array([Integer(121231231), Integer(121231231)]), [121231231, 121231231]), ("INT4 ARRAY", Int32Array([[Integer(121231231)], [Integer(121231231)]]), [[121231231], [121231231]]), @@ -1519,7 +1518,7 @@ async def test_empty_array( ), [[datetime.timedelta(days=100, microseconds=100)], [datetime.timedelta(days=100, microseconds=100)]], ), - ), + ], ) async def test_array_types( psql_pool: ConnectionPool, From 5189bb23d01b24a31566b396180a7d80ed8bd7fb Mon Sep 17 00:00:00 2001 From: "chandr-andr (Kiselev Aleksandr)" Date: Mon, 2 Dec 2024 21:46:31 +0100 Subject: [PATCH 2/4] Test Signed-off-by: chandr-andr (Kiselev Aleksandr) --- .github/workflows/test.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b364d543..ef53a8fe 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -8,9 +8,8 @@ jobs: strategy: matrix: cmd: - - black - - isort - - ruff + - ruff check + - ruff format - mypy runs-on: ubuntu-latest steps: From b8bd1a98a15bbc6a8b0db8e411f163324ee33d28 Mon Sep 17 00:00:00 2001 From: "chandr-andr (Kiselev Aleksandr)" Date: Mon, 2 Dec 2024 21:52:12 +0100 Subject: [PATCH 3/4] Changed lints Signed-off-by: chandr-andr (Kiselev Aleksandr) --- .github/workflows/test.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ef53a8fe..411d3948 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -8,8 +8,6 @@ jobs: strategy: matrix: cmd: - - ruff check - - ruff format - mypy runs-on: ubuntu-latest steps: From cef89439f3887ce4e66cd7a0c0fd239708c88de4 Mon Sep 17 00:00:00 2001 From: "chandr-andr (Kiselev Aleksandr)" Date: Mon, 2 Dec 2024 21:53:41 +0100 Subject: [PATCH 4/4] Changed lints Signed-off-by: chandr-andr (Kiselev Aleksandr) --- .pre-commit-config.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6ba59e49..7bd77650 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,6 @@ +ci: + skip: [fmt, clippy, check] + repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v2.1.0