From 817146c28b430bdf6cc54e8e101c6a40795b2ab1 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Fri, 20 Aug 2021 16:07:28 -0700 Subject: [PATCH] python: Upgrade SQLAlchemy from 1.3.24 to 1.4.23. Signed-off-by: Anders Kaseorg --- requirements/common.in | 2 +- requirements/dev.txt | 136 ++++++++++++++++++++--------- requirements/mypy.in | 4 +- requirements/mypy.txt | 104 ++++++++++++++++++++-- requirements/prod.txt | 119 +++++++++++++++++-------- version.py | 2 +- zerver/lib/sqlalchemy_utils.py | 3 +- zerver/lib/topic.py | 8 +- zerver/lib/topic_mutes.py | 3 +- zerver/tests/test_message_fetch.py | 50 +++++------ zerver/views/message_fetch.py | 91 ++++++++++--------- 11 files changed, 358 insertions(+), 164 deletions(-) diff --git a/requirements/common.in b/requirements/common.in index 60c2205918..5c3bcfd077 100644 --- a/requirements/common.in +++ b/requirements/common.in @@ -32,7 +32,7 @@ jedi<0.18.0 Pillow # Needed for building complex DB queries -SQLAlchemy==1.3.* # 1.4 has badly busted type annotations +SQLAlchemy==1.4.* # Needed for S3 file uploads boto3 diff --git a/requirements/dev.txt b/requirements/dev.txt index e4bc455b40..6a29eb4286 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -447,6 +447,58 @@ gitlint==0.15.1 \ --hash=sha256:4b22916dcbdca381244aee6cb8d8743756cfd98f27e7d1f02e78733f07c3c21c \ --hash=sha256:7ebdb8e7d333e577e956225cbc3ad8e0e96d05e638e6d461c9b66b784f9d2ac4 # via -r requirements/dev.in +greenlet==1.1.1 \ + --hash=sha256:04e1849c88aa56584d4a0a6e36af5ec7cc37993fdc1fda72b56aa1394a92ded3 \ + --hash=sha256:05e72db813c28906cdc59bd0da7c325d9b82aa0b0543014059c34c8c4ad20e16 \ + --hash=sha256:07e6d88242e09b399682b39f8dfa1e7e6eca66b305de1ff74ed9eb1a7d8e539c \ + --hash=sha256:090126004c8ab9cd0787e2acf63d79e80ab41a18f57d6448225bbfcba475034f \ + --hash=sha256:1796f2c283faab2b71c67e9b9aefb3f201fdfbee5cb55001f5ffce9125f63a45 \ + --hash=sha256:2f89d74b4f423e756a018832cd7a0a571e0a31b9ca59323b77ce5f15a437629b \ + --hash=sha256:34e6675167a238bede724ee60fe0550709e95adaff6a36bcc97006c365290384 \ + --hash=sha256:3e594015a2349ec6dcceda9aca29da8dc89e85b56825b7d1f138a3f6bb79dd4c \ + --hash=sha256:3f8fc59bc5d64fa41f58b0029794f474223693fd00016b29f4e176b3ee2cfd9f \ + --hash=sha256:3fc6a447735749d651d8919da49aab03c434a300e9f0af1c886d560405840fd1 \ + --hash=sha256:40abb7fec4f6294225d2b5464bb6d9552050ded14a7516588d6f010e7e366dcc \ + --hash=sha256:44556302c0ab376e37939fd0058e1f0db2e769580d340fb03b01678d1ff25f68 \ + --hash=sha256:476ba9435afaead4382fbab8f1882f75e3fb2285c35c9285abb3dd30237f9142 \ + --hash=sha256:4870b018ca685ff573edd56b93f00a122f279640732bb52ce3a62b73ee5c4a92 \ + --hash=sha256:4adaf53ace289ced90797d92d767d37e7cdc29f13bd3830c3f0a561277a4ae83 \ + --hash=sha256:4eae94de9924bbb4d24960185363e614b1b62ff797c23dc3c8a7c75bbb8d187e \ + --hash=sha256:5317701c7ce167205c0569c10abc4bd01c7f4cf93f642c39f2ce975fa9b78a3c \ + --hash=sha256:5c3b735ccf8fc8048664ee415f8af5a3a018cc92010a0d7195395059b4b39b7d \ + --hash=sha256:5cde7ee190196cbdc078511f4df0be367af85636b84d8be32230f4871b960687 \ + --hash=sha256:655ab836324a473d4cd8cf231a2d6f283ed71ed77037679da554e38e606a7117 \ + --hash=sha256:6ce9d0784c3c79f3e5c5c9c9517bbb6c7e8aa12372a5ea95197b8a99402aa0e6 \ + --hash=sha256:6e0696525500bc8aa12eae654095d2260db4dc95d5c35af2b486eae1bf914ccd \ + --hash=sha256:75ff270fd05125dce3303e9216ccddc541a9e072d4fc764a9276d44dee87242b \ + --hash=sha256:8039f5fe8030c43cd1732d9a234fdcbf4916fcc32e21745ca62e75023e4d4649 \ + --hash=sha256:84488516639c3c5e5c0e52f311fff94ebc45b56788c2a3bfe9cf8e75670f4de3 \ + --hash=sha256:84782c80a433d87530ae3f4b9ed58d4a57317d9918dfcc6a59115fa2d8731f2c \ + --hash=sha256:8ddb38fb6ad96c2ef7468ff73ba5c6876b63b664eebb2c919c224261ae5e8378 \ + --hash=sha256:98b491976ed656be9445b79bc57ed21decf08a01aaaf5fdabf07c98c108111f6 \ + --hash=sha256:990e0f5e64bcbc6bdbd03774ecb72496224d13b664aa03afd1f9b171a3269272 \ + --hash=sha256:9b02e6039eafd75e029d8c58b7b1f3e450ca563ef1fe21c7e3e40b9936c8d03e \ + --hash=sha256:a11b6199a0b9dc868990456a2667167d0ba096c5224f6258e452bfbe5a9742c5 \ + --hash=sha256:a414f8e14aa7bacfe1578f17c11d977e637d25383b6210587c29210af995ef04 \ + --hash=sha256:a91ee268f059583176c2c8b012a9fce7e49ca6b333a12bbc2dd01fc1a9783885 \ + --hash=sha256:ac991947ca6533ada4ce7095f0e28fe25d5b2f3266ad5b983ed4201e61596acf \ + --hash=sha256:b050dbb96216db273b56f0e5960959c2b4cb679fe1e58a0c3906fa0a60c00662 \ + --hash=sha256:b97a807437b81f90f85022a9dcfd527deea38368a3979ccb49d93c9198b2c722 \ + --hash=sha256:bad269e442f1b7ffa3fa8820b3c3aa66f02a9f9455b5ba2db5a6f9eea96f56de \ + --hash=sha256:bf3725d79b1ceb19e83fb1aed44095518c0fcff88fba06a76c0891cfd1f36837 \ + --hash=sha256:c0f22774cd8294078bdf7392ac73cf00bfa1e5e0ed644bd064fdabc5f2a2f481 \ + --hash=sha256:c1862f9f1031b1dee3ff00f1027fcd098ffc82120f43041fe67804b464bbd8a7 \ + --hash=sha256:c8d4ed48eed7414ccb2aaaecbc733ed2a84c299714eae3f0f48db085342d5629 \ + --hash=sha256:cf31e894dabb077a35bbe6963285d4515a387ff657bd25b0530c7168e48f167f \ + --hash=sha256:d15cb6f8706678dc47fb4e4f8b339937b04eda48a0af1cca95f180db552e7663 \ + --hash=sha256:dfcb5a4056e161307d103bc013478892cfd919f1262c2bb8703220adcb986362 \ + --hash=sha256:e02780da03f84a671bb4205c5968c120f18df081236d7b5462b380fd4f0b497b \ + --hash=sha256:e2002a59453858c7f3404690ae80f10c924a39f45f6095f18a985a1234c37334 \ + --hash=sha256:e22a82d2b416d9227a500c6860cf13e74060cf10e7daf6695cbf4e6a94e0eee4 \ + --hash=sha256:e41f72f225192d5d4df81dad2974a8943b0f2d664a2a5cfccdf5a01506f5523c \ + --hash=sha256:f253dad38605486a4590f9368ecbace95865fea0f2b66615d121ac91fd1a1563 \ + --hash=sha256:fddfb31aa2ac550b938d952bca8a87f1db0f8dc930ffa14ce05b5c08d27e7fd1 + # via sqlalchemy h2==4.0.0 \ --hash=sha256:ac9e293a1990b339d5d71b19c5fe630e3dd4d768c620d1730d355485323f1b25 \ --hash=sha256:bb7ac7099dd67a857ed52c815a6192b6b1f5ba6b516237fc24a085341340593d @@ -489,11 +541,13 @@ importlib-metadata==4.6.4 ; python_version < "3.8" \ # via # -r requirements/common.in # -r requirements/dev.in + # -r requirements/mypy.in # cssutils # jsonpickle # jsonschema # markdown # pep517 + # sqlalchemy incremental==21.3.0 \ --hash=sha256:02f5de5aff48f6b9f665d99d48bfc7ec03b6e3943210de7cfc88856d755d6f57 \ --hash=sha256:92014aebc6a20b78a8084cdd5645eeaa7f74b8933f70fa3ada2cfbd1e3b54321 @@ -830,7 +884,7 @@ mypy==0.910 \ --hash=sha256:ef565033fa5a958e62796867b1df10c40263ea9ded87164d67572834e57a174d # via # -r requirements/mypy.in - # sqlalchemy-stubs + # sqlalchemy mypy-boto3-s3==1.18.27 \ --hash=sha256:e8cfdba15656afc0d5f2d440fade7791f7ef8f35e141a867f2cb819854c0cf7e \ --hash=sha256:eb10f0e82fdec402817c4166e543e8a91e7a4c670cd78f1690372bdf4a99f31c @@ -1597,46 +1651,44 @@ sphinxcontrib-serializinghtml==1.1.5 \ --hash=sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd \ --hash=sha256:aa5f6de5dfdf809ef505c4895e51ef5c9eac17d0f287933eb49ec495280b6952 # via sphinx -sqlalchemy==1.3.24 \ - --hash=sha256:014ea143572fee1c18322b7908140ad23b3994036ef4c0d630110faf942652f8 \ - --hash=sha256:0172423a27fbcae3751ef016663b72e1a516777de324a76e30efa170dbd3dd2d \ - --hash=sha256:01aa5f803db724447c1d423ed583e42bf5264c597fd55e4add4301f163b0be48 \ - --hash=sha256:0352db1befcbed2f9282e72843f1963860bf0e0472a4fa5cf8ee084318e0e6ab \ - --hash=sha256:09083c2487ca3c0865dc588e07aeaa25416da3d95f7482c07e92f47e080aa17b \ - --hash=sha256:0d5d862b1cfbec5028ce1ecac06a3b42bc7703eb80e4b53fceb2738724311443 \ - --hash=sha256:14f0eb5db872c231b20c18b1e5806352723a3a89fb4254af3b3e14f22eaaec75 \ - --hash=sha256:1e2f89d2e5e3c7a88e25a3b0e43626dba8db2aa700253023b82e630d12b37109 \ - --hash=sha256:26155ea7a243cbf23287f390dba13d7927ffa1586d3208e0e8d615d0c506f996 \ - --hash=sha256:2ed6343b625b16bcb63c5b10523fd15ed8934e1ed0f772c534985e9f5e73d894 \ - --hash=sha256:34fcec18f6e4b24b4a5f6185205a04f1eab1e56f8f1d028a2a03694ebcc2ddd4 \ - --hash=sha256:4d0e3515ef98aa4f0dc289ff2eebb0ece6260bbf37c2ea2022aad63797eacf60 \ - --hash=sha256:5de2464c254380d8a6c20a2746614d5a436260be1507491442cf1088e59430d2 \ - --hash=sha256:6607ae6cd3a07f8a4c3198ffbf256c261661965742e2b5265a77cd5c679c9bba \ - --hash=sha256:8110e6c414d3efc574543109ee618fe2c1f96fa31833a1ff36cc34e968c4f233 \ - --hash=sha256:816de75418ea0953b5eb7b8a74933ee5a46719491cd2b16f718afc4b291a9658 \ - --hash=sha256:861e459b0e97673af6cc5e7f597035c2e3acdfb2608132665406cded25ba64c7 \ - --hash=sha256:87a2725ad7d41cd7376373c15fd8bf674e9c33ca56d0b8036add2d634dba372e \ - --hash=sha256:a006d05d9aa052657ee3e4dc92544faae5fcbaafc6128217310945610d862d39 \ - --hash=sha256:bce28277f308db43a6b4965734366f533b3ff009571ec7ffa583cb77539b84d6 \ - --hash=sha256:c10ff6112d119f82b1618b6dc28126798481b9355d8748b64b9b55051eb4f01b \ - --hash=sha256:d375d8ccd3cebae8d90270f7aa8532fe05908f79e78ae489068f3b4eee5994e8 \ - --hash=sha256:d37843fb8df90376e9e91336724d78a32b988d3d20ab6656da4eb8ee3a45b63c \ - --hash=sha256:e47e257ba5934550d7235665eee6c911dc7178419b614ba9e1fbb1ce6325b14f \ - --hash=sha256:e98d09f487267f1e8d1179bf3b9d7709b30a916491997137dd24d6ae44d18d79 \ - --hash=sha256:ebbb777cbf9312359b897bf81ba00dae0f5cb69fba2a18265dcc18a6f5ef7519 \ - --hash=sha256:ee5f5188edb20a29c1cc4a039b074fdc5575337c9a68f3063449ab47757bb064 \ - --hash=sha256:f03bd97650d2e42710fbe4cf8a59fae657f191df851fc9fc683ecef10746a375 \ - --hash=sha256:f1149d6e5c49d069163e58a3196865e4321bad1803d7886e07d8710de392c548 \ - --hash=sha256:f3c5c52f7cb8b84bfaaf22d82cb9e6e9a8297f7c2ed14d806a0f5e4d22e83fb7 \ - --hash=sha256:f597a243b8550a3a0b15122b14e49d8a7e622ba1c9d29776af741f1845478d79 \ - --hash=sha256:fc1f2a5a5963e2e73bac4926bdaf7790c4d7d77e8fc0590817880e22dd9d0b8b \ - --hash=sha256:fc4cddb0b474b12ed7bdce6be1b9edc65352e8ce66bc10ff8cbbfb3d4047dbf4 \ - --hash=sha256:fcb251305fa24a490b6a9ee2180e5f8252915fb778d3dafc70f9cc3f863827b9 - # via -r requirements/common.in -sqlalchemy-stubs==0.4 \ - --hash=sha256:5eec7aa110adf9b957b631799a72fef396b23ff99fe296df726645d01e312aa5 \ - --hash=sha256:c665d6dd4482ef642f01027fa06c3d5e91befabb219dc71fc2a09e7d7695f7ae - # via -r requirements/mypy.in +sqlalchemy[mypy]==1.4.23 \ + --hash=sha256:059c5f41e8630f51741a234e6ba2a034228c11b3b54a15478e61d8b55fa8bd9d \ + --hash=sha256:07b9099a95dd2b2620498544300eda590741ac54915c6b20809b6de7e3c58090 \ + --hash=sha256:0aa312f9906ecebe133d7f44168c3cae4c76f27a25192fa7682f3fad505543c9 \ + --hash=sha256:0aa746d1173587743960ff17b89b540e313aacfe6c1e9c81aa48393182c36d4f \ + --hash=sha256:1c15191f2430a30082f540ec6f331214746fc974cfdf136d7a1471d1c61d68ff \ + --hash=sha256:25e9b2e5ca088879ce3740d9ccd4d58cb9061d49566a0b5e12166f403d6f4da0 \ + --hash=sha256:2bca9a6e30ee425cc321d988a152a5fe1be519648e7541ac45c36cd4f569421f \ + --hash=sha256:355024cf061ed04271900414eb4a22671520241d2216ddb691bdd8a992172389 \ + --hash=sha256:370f4688ce47f0dc1e677a020a4d46252a31a2818fd67f5c256417faefc938af \ + --hash=sha256:37f2bd1b8e32c5999280f846701712347fc0ee7370e016ede2283c71712e127a \ + --hash=sha256:3a0d3b3d51c83a66f5b72c57e1aad061406e4c390bd42cf1fda94effe82fac81 \ + --hash=sha256:43fc207be06e50158e4dae4cc4f27ce80afbdbfa7c490b3b22feb64f6d9775a0 \ + --hash=sha256:448612570aa1437a5d1b94ada161805778fe80aba5b9a08a403e8ae4e071ded6 \ + --hash=sha256:4803a481d4c14ce6ad53dc35458c57821863e9a079695c27603d38355e61fb7f \ + --hash=sha256:512f52a8872e8d63d898e4e158eda17e2ee40b8d2496b3b409422e71016db0bd \ + --hash=sha256:6a8dbf3d46e889d864a57ee880c4ad3a928db5aa95e3d359cbe0da2f122e50c4 \ + --hash=sha256:76ff246881f528089bf19385131b966197bb494653990396d2ce138e2a447583 \ + --hash=sha256:82c03325111eab88d64e0ff48b6fe15c75d23787429fa1d84c0995872e702787 \ + --hash=sha256:967307ea52985985224a79342527c36ec2d1daa257a39748dd90e001a4be4d90 \ + --hash=sha256:9b128a78581faea7a5ee626ad4471353eee051e4e94616dfeff4742b6e5ba262 \ + --hash=sha256:a8395c4db3e1450eef2b68069abf500cc48af4b442a0d98b5d3c9535fe40cde8 \ + --hash=sha256:ae07895b55c7d58a7dd47438f437ac219c0f09d24c2e7d69fdebc1ea75350f00 \ + --hash=sha256:bd41f8063a9cd11b76d6d7d6af8139ab3c087f5dbbe5a50c02cb8ece7da34d67 \ + --hash=sha256:be185b3daf651c6c0639987a916bf41e97b60e68f860f27c9cb6574385f5cbb4 \ + --hash=sha256:cd0e85dd2067159848c7672acd517f0c38b7b98867a347411ea01b432003f8d9 \ + --hash=sha256:cd68c5f9d13ffc8f4d6802cceee786678c5b1c668c97bc07b9f4a60883f36cd1 \ + --hash=sha256:cec1a4c6ddf5f82191301a25504f0e675eccd86635f0d5e4c69e0661691931c5 \ + --hash=sha256:d9667260125688c71ccf9af321c37e9fb71c2693575af8210f763bfbbee847c7 \ + --hash=sha256:e0ce4a2e48fe0a9ea3a5160411a4c5135da5255ed9ac9c15f15f2bcf58c34194 \ + --hash=sha256:e9d4f4552aa5e0d1417fc64a2ce1cdf56a30bab346ba6b0dd5e838eb56db4d29 + # via + # -r requirements/common.in + # -r requirements/mypy.in +sqlalchemy2-stubs==0.0.2a11 \ + --hash=sha256:c4acfba94a8fde6293c7c48a615c2247efb05096b6b5e95ada712fa95ede4a81 \ + --hash=sha256:c5e9a206fa11003bc73365762c1f4139e78f8668653f30d46186c344d335e156 + # via sqlalchemy sqlparse==0.4.1 \ --hash=sha256:017cde379adbd6a1f15a61873f43e8274179378e95ef3fede90b5aa64d304ed0 \ --hash=sha256:0f91fd2e829c44362cbcfab3e9ae12e22badaa8a29ad5ff599f9ec109f0454e8 @@ -1845,7 +1897,7 @@ typing-extensions==3.10.0.0 \ # mypy-boto3-s3 # pyre-check # pyre-extensions - # sqlalchemy-stubs + # sqlalchemy2-stubs # twisted # typing-inspect # zulint diff --git a/requirements/mypy.in b/requirements/mypy.in index d98f5893ab..47992cd331 100644 --- a/requirements/mypy.in +++ b/requirements/mypy.in @@ -8,7 +8,7 @@ backoff-stubs boto3-stubs[s3] lxml-stubs https://github.com/andersk/pika-stubs/archive/87c5795741449e37bdbd2ceceee853fd56462440.zip#egg=pika-stubs==0.1.3+git # https://github.com/hahow/pika-stubs/issues/1, https://github.com/hahow/pika-stubs/pull/4 -sqlalchemy-stubs +sqlalchemy[mypy] types-boto types-certifi types-chardet @@ -28,3 +28,5 @@ types-PyYAML types-redis types-requests types-six + +importlib-metadata;python_version<"3.8" # for sqlalchemy diff --git a/requirements/mypy.txt b/requirements/mypy.txt index 3a71944156..84a035229c 100644 --- a/requirements/mypy.txt +++ b/requirements/mypy.txt @@ -18,6 +18,64 @@ botocore-stubs==1.21.27 \ --hash=sha256:8fb26a19e5fcbd50b23ea5648fb7557a3701ddf45f0a8ca0307801f28a29f041 \ --hash=sha256:c1b9e5f8ba4c7ea680d9bd8344ded5ad02950e2fa8d64decd2ecb9ff2b1d9cd5 # via boto3-stubs +greenlet==1.1.1 \ + --hash=sha256:04e1849c88aa56584d4a0a6e36af5ec7cc37993fdc1fda72b56aa1394a92ded3 \ + --hash=sha256:05e72db813c28906cdc59bd0da7c325d9b82aa0b0543014059c34c8c4ad20e16 \ + --hash=sha256:07e6d88242e09b399682b39f8dfa1e7e6eca66b305de1ff74ed9eb1a7d8e539c \ + --hash=sha256:090126004c8ab9cd0787e2acf63d79e80ab41a18f57d6448225bbfcba475034f \ + --hash=sha256:1796f2c283faab2b71c67e9b9aefb3f201fdfbee5cb55001f5ffce9125f63a45 \ + --hash=sha256:2f89d74b4f423e756a018832cd7a0a571e0a31b9ca59323b77ce5f15a437629b \ + --hash=sha256:34e6675167a238bede724ee60fe0550709e95adaff6a36bcc97006c365290384 \ + --hash=sha256:3e594015a2349ec6dcceda9aca29da8dc89e85b56825b7d1f138a3f6bb79dd4c \ + --hash=sha256:3f8fc59bc5d64fa41f58b0029794f474223693fd00016b29f4e176b3ee2cfd9f \ + --hash=sha256:3fc6a447735749d651d8919da49aab03c434a300e9f0af1c886d560405840fd1 \ + --hash=sha256:40abb7fec4f6294225d2b5464bb6d9552050ded14a7516588d6f010e7e366dcc \ + --hash=sha256:44556302c0ab376e37939fd0058e1f0db2e769580d340fb03b01678d1ff25f68 \ + --hash=sha256:476ba9435afaead4382fbab8f1882f75e3fb2285c35c9285abb3dd30237f9142 \ + --hash=sha256:4870b018ca685ff573edd56b93f00a122f279640732bb52ce3a62b73ee5c4a92 \ + --hash=sha256:4adaf53ace289ced90797d92d767d37e7cdc29f13bd3830c3f0a561277a4ae83 \ + --hash=sha256:4eae94de9924bbb4d24960185363e614b1b62ff797c23dc3c8a7c75bbb8d187e \ + --hash=sha256:5317701c7ce167205c0569c10abc4bd01c7f4cf93f642c39f2ce975fa9b78a3c \ + --hash=sha256:5c3b735ccf8fc8048664ee415f8af5a3a018cc92010a0d7195395059b4b39b7d \ + --hash=sha256:5cde7ee190196cbdc078511f4df0be367af85636b84d8be32230f4871b960687 \ + --hash=sha256:655ab836324a473d4cd8cf231a2d6f283ed71ed77037679da554e38e606a7117 \ + --hash=sha256:6ce9d0784c3c79f3e5c5c9c9517bbb6c7e8aa12372a5ea95197b8a99402aa0e6 \ + --hash=sha256:6e0696525500bc8aa12eae654095d2260db4dc95d5c35af2b486eae1bf914ccd \ + --hash=sha256:75ff270fd05125dce3303e9216ccddc541a9e072d4fc764a9276d44dee87242b \ + --hash=sha256:8039f5fe8030c43cd1732d9a234fdcbf4916fcc32e21745ca62e75023e4d4649 \ + --hash=sha256:84488516639c3c5e5c0e52f311fff94ebc45b56788c2a3bfe9cf8e75670f4de3 \ + --hash=sha256:84782c80a433d87530ae3f4b9ed58d4a57317d9918dfcc6a59115fa2d8731f2c \ + --hash=sha256:8ddb38fb6ad96c2ef7468ff73ba5c6876b63b664eebb2c919c224261ae5e8378 \ + --hash=sha256:98b491976ed656be9445b79bc57ed21decf08a01aaaf5fdabf07c98c108111f6 \ + --hash=sha256:990e0f5e64bcbc6bdbd03774ecb72496224d13b664aa03afd1f9b171a3269272 \ + --hash=sha256:9b02e6039eafd75e029d8c58b7b1f3e450ca563ef1fe21c7e3e40b9936c8d03e \ + --hash=sha256:a11b6199a0b9dc868990456a2667167d0ba096c5224f6258e452bfbe5a9742c5 \ + --hash=sha256:a414f8e14aa7bacfe1578f17c11d977e637d25383b6210587c29210af995ef04 \ + --hash=sha256:a91ee268f059583176c2c8b012a9fce7e49ca6b333a12bbc2dd01fc1a9783885 \ + --hash=sha256:ac991947ca6533ada4ce7095f0e28fe25d5b2f3266ad5b983ed4201e61596acf \ + --hash=sha256:b050dbb96216db273b56f0e5960959c2b4cb679fe1e58a0c3906fa0a60c00662 \ + --hash=sha256:b97a807437b81f90f85022a9dcfd527deea38368a3979ccb49d93c9198b2c722 \ + --hash=sha256:bad269e442f1b7ffa3fa8820b3c3aa66f02a9f9455b5ba2db5a6f9eea96f56de \ + --hash=sha256:bf3725d79b1ceb19e83fb1aed44095518c0fcff88fba06a76c0891cfd1f36837 \ + --hash=sha256:c0f22774cd8294078bdf7392ac73cf00bfa1e5e0ed644bd064fdabc5f2a2f481 \ + --hash=sha256:c1862f9f1031b1dee3ff00f1027fcd098ffc82120f43041fe67804b464bbd8a7 \ + --hash=sha256:c8d4ed48eed7414ccb2aaaecbc733ed2a84c299714eae3f0f48db085342d5629 \ + --hash=sha256:cf31e894dabb077a35bbe6963285d4515a387ff657bd25b0530c7168e48f167f \ + --hash=sha256:d15cb6f8706678dc47fb4e4f8b339937b04eda48a0af1cca95f180db552e7663 \ + --hash=sha256:dfcb5a4056e161307d103bc013478892cfd919f1262c2bb8703220adcb986362 \ + --hash=sha256:e02780da03f84a671bb4205c5968c120f18df081236d7b5462b380fd4f0b497b \ + --hash=sha256:e2002a59453858c7f3404690ae80f10c924a39f45f6095f18a985a1234c37334 \ + --hash=sha256:e22a82d2b416d9227a500c6860cf13e74060cf10e7daf6695cbf4e6a94e0eee4 \ + --hash=sha256:e41f72f225192d5d4df81dad2974a8943b0f2d664a2a5cfccdf5a01506f5523c \ + --hash=sha256:f253dad38605486a4590f9368ecbace95865fea0f2b66615d121ac91fd1a1563 \ + --hash=sha256:fddfb31aa2ac550b938d952bca8a87f1db0f8dc930ffa14ce05b5c08d27e7fd1 + # via sqlalchemy +importlib-metadata==4.6.4 ; python_version < "3.8" \ + --hash=sha256:7b30a78db2922d78a6f47fb30683156a14f3c6aa5cc23f77cc8967e9ab2d002f \ + --hash=sha256:ed5157fef23a4bc4594615a0dd8eba94b2bb36bf2a343fa3d8bb2fa0a62a99d5 + # via + # -r requirements/mypy.in + # sqlalchemy lxml-stubs==0.2.0 \ --hash=sha256:78f1bfb31b1f2af9a5c9e9a602ab1b589a64a5a3cc444931a39cdfd02d6864b0 \ --hash=sha256:f0b3621ec2a23bea4145f484490c8b27383ecb407b3f8b079199ad4a0af4180b @@ -48,7 +106,7 @@ mypy==0.910 \ --hash=sha256:ef565033fa5a958e62796867b1df10c40263ea9ded87164d67572834e57a174d # via # -r requirements/mypy.in - # sqlalchemy-stubs + # sqlalchemy mypy-boto3-s3==1.18.27 \ --hash=sha256:e8cfdba15656afc0d5f2d440fade7791f7ef8f35e141a867f2cb819854c0cf7e \ --hash=sha256:eb10f0e82fdec402817c4166e543e8a91e7a4c670cd78f1690372bdf4a99f31c @@ -60,10 +118,42 @@ mypy-extensions==0.4.3 \ https://github.com/andersk/pika-stubs/archive/87c5795741449e37bdbd2ceceee853fd56462440.zip#egg=pika-stubs==0.1.3+git \ --hash=sha256:b56b4210ba66c65e3c54236dc3ccfd79d02c1385b9d72146d3ea8af05ec7c5ff # via -r requirements/mypy.in -sqlalchemy-stubs==0.4 \ - --hash=sha256:5eec7aa110adf9b957b631799a72fef396b23ff99fe296df726645d01e312aa5 \ - --hash=sha256:c665d6dd4482ef642f01027fa06c3d5e91befabb219dc71fc2a09e7d7695f7ae +sqlalchemy[mypy]==1.4.23 \ + --hash=sha256:059c5f41e8630f51741a234e6ba2a034228c11b3b54a15478e61d8b55fa8bd9d \ + --hash=sha256:07b9099a95dd2b2620498544300eda590741ac54915c6b20809b6de7e3c58090 \ + --hash=sha256:0aa312f9906ecebe133d7f44168c3cae4c76f27a25192fa7682f3fad505543c9 \ + --hash=sha256:0aa746d1173587743960ff17b89b540e313aacfe6c1e9c81aa48393182c36d4f \ + --hash=sha256:1c15191f2430a30082f540ec6f331214746fc974cfdf136d7a1471d1c61d68ff \ + --hash=sha256:25e9b2e5ca088879ce3740d9ccd4d58cb9061d49566a0b5e12166f403d6f4da0 \ + --hash=sha256:2bca9a6e30ee425cc321d988a152a5fe1be519648e7541ac45c36cd4f569421f \ + --hash=sha256:355024cf061ed04271900414eb4a22671520241d2216ddb691bdd8a992172389 \ + --hash=sha256:370f4688ce47f0dc1e677a020a4d46252a31a2818fd67f5c256417faefc938af \ + --hash=sha256:37f2bd1b8e32c5999280f846701712347fc0ee7370e016ede2283c71712e127a \ + --hash=sha256:3a0d3b3d51c83a66f5b72c57e1aad061406e4c390bd42cf1fda94effe82fac81 \ + --hash=sha256:43fc207be06e50158e4dae4cc4f27ce80afbdbfa7c490b3b22feb64f6d9775a0 \ + --hash=sha256:448612570aa1437a5d1b94ada161805778fe80aba5b9a08a403e8ae4e071ded6 \ + --hash=sha256:4803a481d4c14ce6ad53dc35458c57821863e9a079695c27603d38355e61fb7f \ + --hash=sha256:512f52a8872e8d63d898e4e158eda17e2ee40b8d2496b3b409422e71016db0bd \ + --hash=sha256:6a8dbf3d46e889d864a57ee880c4ad3a928db5aa95e3d359cbe0da2f122e50c4 \ + --hash=sha256:76ff246881f528089bf19385131b966197bb494653990396d2ce138e2a447583 \ + --hash=sha256:82c03325111eab88d64e0ff48b6fe15c75d23787429fa1d84c0995872e702787 \ + --hash=sha256:967307ea52985985224a79342527c36ec2d1daa257a39748dd90e001a4be4d90 \ + --hash=sha256:9b128a78581faea7a5ee626ad4471353eee051e4e94616dfeff4742b6e5ba262 \ + --hash=sha256:a8395c4db3e1450eef2b68069abf500cc48af4b442a0d98b5d3c9535fe40cde8 \ + --hash=sha256:ae07895b55c7d58a7dd47438f437ac219c0f09d24c2e7d69fdebc1ea75350f00 \ + --hash=sha256:bd41f8063a9cd11b76d6d7d6af8139ab3c087f5dbbe5a50c02cb8ece7da34d67 \ + --hash=sha256:be185b3daf651c6c0639987a916bf41e97b60e68f860f27c9cb6574385f5cbb4 \ + --hash=sha256:cd0e85dd2067159848c7672acd517f0c38b7b98867a347411ea01b432003f8d9 \ + --hash=sha256:cd68c5f9d13ffc8f4d6802cceee786678c5b1c668c97bc07b9f4a60883f36cd1 \ + --hash=sha256:cec1a4c6ddf5f82191301a25504f0e675eccd86635f0d5e4c69e0661691931c5 \ + --hash=sha256:d9667260125688c71ccf9af321c37e9fb71c2693575af8210f763bfbbee847c7 \ + --hash=sha256:e0ce4a2e48fe0a9ea3a5160411a4c5135da5255ed9ac9c15f15f2bcf58c34194 \ + --hash=sha256:e9d4f4552aa5e0d1417fc64a2ce1cdf56a30bab346ba6b0dd5e838eb56db4d29 # via -r requirements/mypy.in +sqlalchemy2-stubs==0.0.2a11 \ + --hash=sha256:c4acfba94a8fde6293c7c48a615c2247efb05096b6b5e95ada712fa95ede4a81 \ + --hash=sha256:c5e9a206fa11003bc73365762c1f4139e78f8668653f30d46186c344d335e156 + # via sqlalchemy toml==0.10.2 \ --hash=sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b \ --hash=sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f @@ -188,5 +278,9 @@ typing-extensions==3.10.0.0 \ --hash=sha256:779383f6086d90c99ae41cf0ff39aac8a7937a9283ce0a414e5dd782f4c94a84 # via # boto3-stubs + # importlib-metadata # mypy - # sqlalchemy-stubs +zipp==3.5.0 \ + --hash=sha256:957cfda87797e389580cb8b9e3870841ca991e2125350677b2ca83a0e99390a3 \ + --hash=sha256:f5812b1e007e48cff63449a5e9f4e7ebea716b4111f9c4f9a645f91d579bf0c4 + # via importlib-metadata diff --git a/requirements/prod.txt b/requirements/prod.txt index 9c6469d8cf..a10d496ce8 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -283,6 +283,58 @@ ecdsa==0.17.0 \ future==0.18.2 \ --hash=sha256:b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d # via python-twitter +greenlet==1.1.1 \ + --hash=sha256:04e1849c88aa56584d4a0a6e36af5ec7cc37993fdc1fda72b56aa1394a92ded3 \ + --hash=sha256:05e72db813c28906cdc59bd0da7c325d9b82aa0b0543014059c34c8c4ad20e16 \ + --hash=sha256:07e6d88242e09b399682b39f8dfa1e7e6eca66b305de1ff74ed9eb1a7d8e539c \ + --hash=sha256:090126004c8ab9cd0787e2acf63d79e80ab41a18f57d6448225bbfcba475034f \ + --hash=sha256:1796f2c283faab2b71c67e9b9aefb3f201fdfbee5cb55001f5ffce9125f63a45 \ + --hash=sha256:2f89d74b4f423e756a018832cd7a0a571e0a31b9ca59323b77ce5f15a437629b \ + --hash=sha256:34e6675167a238bede724ee60fe0550709e95adaff6a36bcc97006c365290384 \ + --hash=sha256:3e594015a2349ec6dcceda9aca29da8dc89e85b56825b7d1f138a3f6bb79dd4c \ + --hash=sha256:3f8fc59bc5d64fa41f58b0029794f474223693fd00016b29f4e176b3ee2cfd9f \ + --hash=sha256:3fc6a447735749d651d8919da49aab03c434a300e9f0af1c886d560405840fd1 \ + --hash=sha256:40abb7fec4f6294225d2b5464bb6d9552050ded14a7516588d6f010e7e366dcc \ + --hash=sha256:44556302c0ab376e37939fd0058e1f0db2e769580d340fb03b01678d1ff25f68 \ + --hash=sha256:476ba9435afaead4382fbab8f1882f75e3fb2285c35c9285abb3dd30237f9142 \ + --hash=sha256:4870b018ca685ff573edd56b93f00a122f279640732bb52ce3a62b73ee5c4a92 \ + --hash=sha256:4adaf53ace289ced90797d92d767d37e7cdc29f13bd3830c3f0a561277a4ae83 \ + --hash=sha256:4eae94de9924bbb4d24960185363e614b1b62ff797c23dc3c8a7c75bbb8d187e \ + --hash=sha256:5317701c7ce167205c0569c10abc4bd01c7f4cf93f642c39f2ce975fa9b78a3c \ + --hash=sha256:5c3b735ccf8fc8048664ee415f8af5a3a018cc92010a0d7195395059b4b39b7d \ + --hash=sha256:5cde7ee190196cbdc078511f4df0be367af85636b84d8be32230f4871b960687 \ + --hash=sha256:655ab836324a473d4cd8cf231a2d6f283ed71ed77037679da554e38e606a7117 \ + --hash=sha256:6ce9d0784c3c79f3e5c5c9c9517bbb6c7e8aa12372a5ea95197b8a99402aa0e6 \ + --hash=sha256:6e0696525500bc8aa12eae654095d2260db4dc95d5c35af2b486eae1bf914ccd \ + --hash=sha256:75ff270fd05125dce3303e9216ccddc541a9e072d4fc764a9276d44dee87242b \ + --hash=sha256:8039f5fe8030c43cd1732d9a234fdcbf4916fcc32e21745ca62e75023e4d4649 \ + --hash=sha256:84488516639c3c5e5c0e52f311fff94ebc45b56788c2a3bfe9cf8e75670f4de3 \ + --hash=sha256:84782c80a433d87530ae3f4b9ed58d4a57317d9918dfcc6a59115fa2d8731f2c \ + --hash=sha256:8ddb38fb6ad96c2ef7468ff73ba5c6876b63b664eebb2c919c224261ae5e8378 \ + --hash=sha256:98b491976ed656be9445b79bc57ed21decf08a01aaaf5fdabf07c98c108111f6 \ + --hash=sha256:990e0f5e64bcbc6bdbd03774ecb72496224d13b664aa03afd1f9b171a3269272 \ + --hash=sha256:9b02e6039eafd75e029d8c58b7b1f3e450ca563ef1fe21c7e3e40b9936c8d03e \ + --hash=sha256:a11b6199a0b9dc868990456a2667167d0ba096c5224f6258e452bfbe5a9742c5 \ + --hash=sha256:a414f8e14aa7bacfe1578f17c11d977e637d25383b6210587c29210af995ef04 \ + --hash=sha256:a91ee268f059583176c2c8b012a9fce7e49ca6b333a12bbc2dd01fc1a9783885 \ + --hash=sha256:ac991947ca6533ada4ce7095f0e28fe25d5b2f3266ad5b983ed4201e61596acf \ + --hash=sha256:b050dbb96216db273b56f0e5960959c2b4cb679fe1e58a0c3906fa0a60c00662 \ + --hash=sha256:b97a807437b81f90f85022a9dcfd527deea38368a3979ccb49d93c9198b2c722 \ + --hash=sha256:bad269e442f1b7ffa3fa8820b3c3aa66f02a9f9455b5ba2db5a6f9eea96f56de \ + --hash=sha256:bf3725d79b1ceb19e83fb1aed44095518c0fcff88fba06a76c0891cfd1f36837 \ + --hash=sha256:c0f22774cd8294078bdf7392ac73cf00bfa1e5e0ed644bd064fdabc5f2a2f481 \ + --hash=sha256:c1862f9f1031b1dee3ff00f1027fcd098ffc82120f43041fe67804b464bbd8a7 \ + --hash=sha256:c8d4ed48eed7414ccb2aaaecbc733ed2a84c299714eae3f0f48db085342d5629 \ + --hash=sha256:cf31e894dabb077a35bbe6963285d4515a387ff657bd25b0530c7168e48f167f \ + --hash=sha256:d15cb6f8706678dc47fb4e4f8b339937b04eda48a0af1cca95f180db552e7663 \ + --hash=sha256:dfcb5a4056e161307d103bc013478892cfd919f1262c2bb8703220adcb986362 \ + --hash=sha256:e02780da03f84a671bb4205c5968c120f18df081236d7b5462b380fd4f0b497b \ + --hash=sha256:e2002a59453858c7f3404690ae80f10c924a39f45f6095f18a985a1234c37334 \ + --hash=sha256:e22a82d2b416d9227a500c6860cf13e74060cf10e7daf6695cbf4e6a94e0eee4 \ + --hash=sha256:e41f72f225192d5d4df81dad2974a8943b0f2d664a2a5cfccdf5a01506f5523c \ + --hash=sha256:f253dad38605486a4590f9368ecbace95865fea0f2b66615d121ac91fd1a1563 \ + --hash=sha256:fddfb31aa2ac550b938d952bca8a87f1db0f8dc930ffa14ce05b5c08d27e7fd1 + # via sqlalchemy h2==4.0.0 \ --hash=sha256:ac9e293a1990b339d5d71b19c5fe630e3dd4d768c620d1730d355485323f1b25 \ --hash=sha256:bb7ac7099dd67a857ed52c815a6192b6b1f5ba6b516237fc24a085341340593d @@ -317,6 +369,7 @@ importlib-metadata==4.6.4 ; python_version < "3.8" \ # cssutils # jsonschema # markdown + # sqlalchemy ipython==7.16.1 \ --hash=sha256:2dbcc8c27ca7d3cfe4fcdff7f45b27f9a8d3edfa70ff8024a71c7a8eb5f09d64 \ --hash=sha256:9f4fcb31d3b2c533333893b9172264e4821c1ac91839500f31bd43f2c59b3ccf @@ -1031,41 +1084,37 @@ sourcemap==0.2.1 \ --hash=sha256:be00a90185e7a16b87bbe62a68ffd5e38bc438ef4700806d9b90e44d8027787c \ --hash=sha256:c448a8c48f9482e522e4582106b0c641a83b5dbc7f13927b178848e3ea20967b # via -r requirements/common.in -sqlalchemy==1.3.24 \ - --hash=sha256:014ea143572fee1c18322b7908140ad23b3994036ef4c0d630110faf942652f8 \ - --hash=sha256:0172423a27fbcae3751ef016663b72e1a516777de324a76e30efa170dbd3dd2d \ - --hash=sha256:01aa5f803db724447c1d423ed583e42bf5264c597fd55e4add4301f163b0be48 \ - --hash=sha256:0352db1befcbed2f9282e72843f1963860bf0e0472a4fa5cf8ee084318e0e6ab \ - --hash=sha256:09083c2487ca3c0865dc588e07aeaa25416da3d95f7482c07e92f47e080aa17b \ - --hash=sha256:0d5d862b1cfbec5028ce1ecac06a3b42bc7703eb80e4b53fceb2738724311443 \ - --hash=sha256:14f0eb5db872c231b20c18b1e5806352723a3a89fb4254af3b3e14f22eaaec75 \ - --hash=sha256:1e2f89d2e5e3c7a88e25a3b0e43626dba8db2aa700253023b82e630d12b37109 \ - --hash=sha256:26155ea7a243cbf23287f390dba13d7927ffa1586d3208e0e8d615d0c506f996 \ - --hash=sha256:2ed6343b625b16bcb63c5b10523fd15ed8934e1ed0f772c534985e9f5e73d894 \ - --hash=sha256:34fcec18f6e4b24b4a5f6185205a04f1eab1e56f8f1d028a2a03694ebcc2ddd4 \ - --hash=sha256:4d0e3515ef98aa4f0dc289ff2eebb0ece6260bbf37c2ea2022aad63797eacf60 \ - --hash=sha256:5de2464c254380d8a6c20a2746614d5a436260be1507491442cf1088e59430d2 \ - --hash=sha256:6607ae6cd3a07f8a4c3198ffbf256c261661965742e2b5265a77cd5c679c9bba \ - --hash=sha256:8110e6c414d3efc574543109ee618fe2c1f96fa31833a1ff36cc34e968c4f233 \ - --hash=sha256:816de75418ea0953b5eb7b8a74933ee5a46719491cd2b16f718afc4b291a9658 \ - --hash=sha256:861e459b0e97673af6cc5e7f597035c2e3acdfb2608132665406cded25ba64c7 \ - --hash=sha256:87a2725ad7d41cd7376373c15fd8bf674e9c33ca56d0b8036add2d634dba372e \ - --hash=sha256:a006d05d9aa052657ee3e4dc92544faae5fcbaafc6128217310945610d862d39 \ - --hash=sha256:bce28277f308db43a6b4965734366f533b3ff009571ec7ffa583cb77539b84d6 \ - --hash=sha256:c10ff6112d119f82b1618b6dc28126798481b9355d8748b64b9b55051eb4f01b \ - --hash=sha256:d375d8ccd3cebae8d90270f7aa8532fe05908f79e78ae489068f3b4eee5994e8 \ - --hash=sha256:d37843fb8df90376e9e91336724d78a32b988d3d20ab6656da4eb8ee3a45b63c \ - --hash=sha256:e47e257ba5934550d7235665eee6c911dc7178419b614ba9e1fbb1ce6325b14f \ - --hash=sha256:e98d09f487267f1e8d1179bf3b9d7709b30a916491997137dd24d6ae44d18d79 \ - --hash=sha256:ebbb777cbf9312359b897bf81ba00dae0f5cb69fba2a18265dcc18a6f5ef7519 \ - --hash=sha256:ee5f5188edb20a29c1cc4a039b074fdc5575337c9a68f3063449ab47757bb064 \ - --hash=sha256:f03bd97650d2e42710fbe4cf8a59fae657f191df851fc9fc683ecef10746a375 \ - --hash=sha256:f1149d6e5c49d069163e58a3196865e4321bad1803d7886e07d8710de392c548 \ - --hash=sha256:f3c5c52f7cb8b84bfaaf22d82cb9e6e9a8297f7c2ed14d806a0f5e4d22e83fb7 \ - --hash=sha256:f597a243b8550a3a0b15122b14e49d8a7e622ba1c9d29776af741f1845478d79 \ - --hash=sha256:fc1f2a5a5963e2e73bac4926bdaf7790c4d7d77e8fc0590817880e22dd9d0b8b \ - --hash=sha256:fc4cddb0b474b12ed7bdce6be1b9edc65352e8ce66bc10ff8cbbfb3d4047dbf4 \ - --hash=sha256:fcb251305fa24a490b6a9ee2180e5f8252915fb778d3dafc70f9cc3f863827b9 +sqlalchemy==1.4.23 \ + --hash=sha256:059c5f41e8630f51741a234e6ba2a034228c11b3b54a15478e61d8b55fa8bd9d \ + --hash=sha256:07b9099a95dd2b2620498544300eda590741ac54915c6b20809b6de7e3c58090 \ + --hash=sha256:0aa312f9906ecebe133d7f44168c3cae4c76f27a25192fa7682f3fad505543c9 \ + --hash=sha256:0aa746d1173587743960ff17b89b540e313aacfe6c1e9c81aa48393182c36d4f \ + --hash=sha256:1c15191f2430a30082f540ec6f331214746fc974cfdf136d7a1471d1c61d68ff \ + --hash=sha256:25e9b2e5ca088879ce3740d9ccd4d58cb9061d49566a0b5e12166f403d6f4da0 \ + --hash=sha256:2bca9a6e30ee425cc321d988a152a5fe1be519648e7541ac45c36cd4f569421f \ + --hash=sha256:355024cf061ed04271900414eb4a22671520241d2216ddb691bdd8a992172389 \ + --hash=sha256:370f4688ce47f0dc1e677a020a4d46252a31a2818fd67f5c256417faefc938af \ + --hash=sha256:37f2bd1b8e32c5999280f846701712347fc0ee7370e016ede2283c71712e127a \ + --hash=sha256:3a0d3b3d51c83a66f5b72c57e1aad061406e4c390bd42cf1fda94effe82fac81 \ + --hash=sha256:43fc207be06e50158e4dae4cc4f27ce80afbdbfa7c490b3b22feb64f6d9775a0 \ + --hash=sha256:448612570aa1437a5d1b94ada161805778fe80aba5b9a08a403e8ae4e071ded6 \ + --hash=sha256:4803a481d4c14ce6ad53dc35458c57821863e9a079695c27603d38355e61fb7f \ + --hash=sha256:512f52a8872e8d63d898e4e158eda17e2ee40b8d2496b3b409422e71016db0bd \ + --hash=sha256:6a8dbf3d46e889d864a57ee880c4ad3a928db5aa95e3d359cbe0da2f122e50c4 \ + --hash=sha256:76ff246881f528089bf19385131b966197bb494653990396d2ce138e2a447583 \ + --hash=sha256:82c03325111eab88d64e0ff48b6fe15c75d23787429fa1d84c0995872e702787 \ + --hash=sha256:967307ea52985985224a79342527c36ec2d1daa257a39748dd90e001a4be4d90 \ + --hash=sha256:9b128a78581faea7a5ee626ad4471353eee051e4e94616dfeff4742b6e5ba262 \ + --hash=sha256:a8395c4db3e1450eef2b68069abf500cc48af4b442a0d98b5d3c9535fe40cde8 \ + --hash=sha256:ae07895b55c7d58a7dd47438f437ac219c0f09d24c2e7d69fdebc1ea75350f00 \ + --hash=sha256:bd41f8063a9cd11b76d6d7d6af8139ab3c087f5dbbe5a50c02cb8ece7da34d67 \ + --hash=sha256:be185b3daf651c6c0639987a916bf41e97b60e68f860f27c9cb6574385f5cbb4 \ + --hash=sha256:cd0e85dd2067159848c7672acd517f0c38b7b98867a347411ea01b432003f8d9 \ + --hash=sha256:cd68c5f9d13ffc8f4d6802cceee786678c5b1c668c97bc07b9f4a60883f36cd1 \ + --hash=sha256:cec1a4c6ddf5f82191301a25504f0e675eccd86635f0d5e4c69e0661691931c5 \ + --hash=sha256:d9667260125688c71ccf9af321c37e9fb71c2693575af8210f763bfbbee847c7 \ + --hash=sha256:e0ce4a2e48fe0a9ea3a5160411a4c5135da5255ed9ac9c15f15f2bcf58c34194 \ + --hash=sha256:e9d4f4552aa5e0d1417fc64a2ce1cdf56a30bab346ba6b0dd5e838eb56db4d29 # via -r requirements/common.in sqlparse==0.4.1 \ --hash=sha256:017cde379adbd6a1f15a61873f43e8274179378e95ef3fede90b5aa64d304ed0 \ diff --git a/version.py b/version.py index 556c71c86c..bb19ae49db 100644 --- a/version.py +++ b/version.py @@ -48,4 +48,4 @@ API_FEATURE_LEVEL = 93 # historical commits sharing the same major version, in which case a # minor version bump suffices. -PROVISION_VERSION = "156.0" +PROVISION_VERSION = "157.0" diff --git a/zerver/lib/sqlalchemy_utils.py b/zerver/lib/sqlalchemy_utils.py index fc916cbb14..9f47a869cd 100644 --- a/zerver/lib/sqlalchemy_utils.py +++ b/zerver/lib/sqlalchemy_utils.py @@ -19,7 +19,6 @@ class NonClosingPool(sqlalchemy.pool.NullPool): return self.__class__( creator=self._creator, # type: ignore[attr-defined] # implementation detail recycle=self._recycle, # type: ignore[attr-defined] # implementation detail - use_threadlocal=self._use_threadlocal, # type: ignore[attr-defined] # implementation detail reset_on_return=self._reset_on_return, # type: ignore[attr-defined] # implementation detail echo=self.echo, logging_name=self._orig_logging_name, # type: ignore[attr-defined] # implementation detail @@ -42,7 +41,7 @@ def get_sqlalchemy_connection() -> sqlalchemy.engine.base.Connection: "postgresql://", creator=get_dj_conn, poolclass=NonClosingPool, - pool_reset_on_return=False, + pool_reset_on_return=None, ) sa_connection = sqlalchemy_engine.connect() sa_connection.execution_options(autocommit=False) diff --git a/zerver/lib/topic.py b/zerver/lib/topic.py index 91351547ad..6dadc741c9 100644 --- a/zerver/lib/topic.py +++ b/zerver/lib/topic.py @@ -4,8 +4,8 @@ from typing import Any, Dict, List, Optional, Tuple import orjson from django.db import connection from django.db.models.query import Q, QuerySet -from sqlalchemy import Text from sqlalchemy.sql import ColumnElement, column, func, literal +from sqlalchemy.types import Boolean, Text from zerver.lib.request import REQ from zerver.models import Message, Stream, UserMessage, UserProfile @@ -75,19 +75,19 @@ DB_TOPIC_NAME = "subject" MESSAGE__TOPIC = "message__subject" -def topic_match_sa(topic_name: str) -> "ColumnElement[bool]": +def topic_match_sa(topic_name: str) -> "ColumnElement[Boolean]": # _sa is short for SQLAlchemy, which we use mostly for # queries that search messages topic_cond = func.upper(column("subject", Text)) == func.upper(literal(topic_name)) return topic_cond -def get_resolved_topic_condition_sa() -> "ColumnElement[bool]": +def get_resolved_topic_condition_sa() -> "ColumnElement[Boolean]": resolved_topic_cond = column("subject", Text).startswith(RESOLVED_TOPIC_PREFIX) return resolved_topic_cond -def topic_column_sa() -> "ColumnElement[str]": +def topic_column_sa() -> "ColumnElement[Text]": return column("subject", Text) diff --git a/zerver/lib/topic_mutes.py b/zerver/lib/topic_mutes.py index fe5becad5d..9025e8c194 100644 --- a/zerver/lib/topic_mutes.py +++ b/zerver/lib/topic_mutes.py @@ -3,6 +3,7 @@ from typing import Any, Callable, Dict, List, Optional, Tuple from django.utils.timezone import now as timezone_now from sqlalchemy.sql import ClauseElement, and_, column, not_, or_ +from sqlalchemy.types import Integer from zerver.lib.timestamp import datetime_to_timestamp from zerver.lib.topic import topic_match_sa @@ -119,7 +120,7 @@ def exclude_topic_mutes( def mute_cond(row: Dict[str, Any]) -> ClauseElement: recipient_id = row["recipient_id"] topic_name = row["topic_name"] - stream_cond = column("recipient_id") == recipient_id + stream_cond = column("recipient_id", Integer) == recipient_id topic_cond = topic_match_sa(topic_name) return and_(stream_cond, topic_cond) diff --git a/zerver/tests/test_message_fetch.py b/zerver/tests/test_message_fetch.py index 48a0ce55f2..1df155b290 100644 --- a/zerver/tests/test_message_fetch.py +++ b/zerver/tests/test_message_fetch.py @@ -8,8 +8,8 @@ from django.db import connection from django.http import HttpResponse from django.test import override_settings from django.utils.timezone import now as timezone_now -from sqlalchemy.sql import Select, and_, column, select, table -from sqlalchemy.sql.elements import ClauseElement +from sqlalchemy.sql import ClauseElement, Select, and_, column, select, table +from sqlalchemy.types import Integer from analytics.lib.counts import COUNT_STATS from analytics.models import RealmCount @@ -99,8 +99,8 @@ class NarrowBuilderTest(ZulipTestCase): super().setUp() self.realm = get_realm("zulip") self.user_profile = self.example_user("hamlet") - self.builder = NarrowBuilder(self.user_profile, column("id"), self.realm) - self.raw_query = select([column("id")], None, table("zerver_message")) + self.builder = NarrowBuilder(self.user_profile, column("id", Integer), self.realm) + self.raw_query = select([column("id", Integer)], None, table("zerver_message")) self.hamlet_email = self.example_user("hamlet").email self.othello_email = self.example_user("othello").email @@ -136,7 +136,7 @@ class NarrowBuilderTest(ZulipTestCase): term = dict(operator="streams", operand="public") self._do_add_term_test( term, - "WHERE recipient_id IN (%(recipient_id_1)s, %(recipient_id_2)s, %(recipient_id_3)s, %(recipient_id_4)s, %(recipient_id_5)s)", + "WHERE recipient_id IN ([POSTCOMPILE_recipient_id_1])", ) # Add new streams @@ -165,14 +165,14 @@ class NarrowBuilderTest(ZulipTestCase): # Number of recipient ids will increase by 1 and not 3 self._do_add_term_test( term, - "WHERE recipient_id IN (%(recipient_id_1)s, %(recipient_id_2)s, %(recipient_id_3)s, %(recipient_id_4)s, %(recipient_id_5)s, %(recipient_id_6)s", + "WHERE recipient_id IN ([POSTCOMPILE_recipient_id_1])", ) def test_add_term_using_streams_operator_and_public_stream_operand_negated(self) -> None: term = dict(operator="streams", operand="public", negated=True) self._do_add_term_test( term, - "WHERE recipient_id NOT IN (%(recipient_id_1)s, %(recipient_id_2)s, %(recipient_id_3)s, %(recipient_id_4)s, %(recipient_id_5)s)", + "WHERE (recipient_id NOT IN ([POSTCOMPILE_recipient_id_1]))", ) # Add new streams @@ -201,7 +201,7 @@ class NarrowBuilderTest(ZulipTestCase): # Number of recipient ids will increase by 1 and not 3 self._do_add_term_test( term, - "WHERE recipient_id NOT IN (%(recipient_id_1)s, %(recipient_id_2)s, %(recipient_id_3)s, %(recipient_id_4)s, %(recipient_id_5)s, %(recipient_id_6)s)", + "WHERE (recipient_id NOT IN ([POSTCOMPILE_recipient_id_1]))", ) def test_add_term_using_is_operator_private_operand_and_negated(self) -> None: # NEGATED @@ -398,7 +398,7 @@ class NarrowBuilderTest(ZulipTestCase): def test_add_term_using_group_pm_operator_and_not_the_same_user_as_operand(self) -> None: # Test wtihout any such group PM threads existing term = dict(operator="group-pm-with", operand=self.othello_email) - self._do_add_term_test(term, "WHERE 1 != 1") + self._do_add_term_test(term, "WHERE recipient_id IN ([POSTCOMPILE_recipient_id_1])") # Test with at least one such group PM thread existing self.send_huddle_message( @@ -406,13 +406,13 @@ class NarrowBuilderTest(ZulipTestCase): ) term = dict(operator="group-pm-with", operand=self.othello_email) - self._do_add_term_test(term, "WHERE recipient_id IN (%(recipient_id_1)s)") + self._do_add_term_test(term, "WHERE recipient_id IN ([POSTCOMPILE_recipient_id_1])") def test_add_term_using_group_pm_operator_not_the_same_user_as_operand_and_negated( self, ) -> None: # NEGATED term = dict(operator="group-pm-with", operand=self.othello_email, negated=True) - self._do_add_term_test(term, "WHERE 1 = 1") + self._do_add_term_test(term, "WHERE (recipient_id NOT IN ([POSTCOMPILE_recipient_id_1]))") def test_add_term_using_group_pm_operator_with_non_existing_user_as_operand(self) -> None: term = dict(operator="group-pm-with", operand="non-existing@zulip.com") @@ -477,13 +477,13 @@ class NarrowBuilderTest(ZulipTestCase): def test_add_term_using_in_operator(self) -> None: mute_stream(self.realm, self.user_profile, "Verona") term = dict(operator="in", operand="home") - self._do_add_term_test(term, "WHERE recipient_id NOT IN (%(recipient_id_1)s)") + self._do_add_term_test(term, "WHERE (recipient_id NOT IN ([POSTCOMPILE_recipient_id_1]))") def test_add_term_using_in_operator_and_negated(self) -> None: # negated = True should not change anything mute_stream(self.realm, self.user_profile, "Verona") term = dict(operator="in", operand="home", negated=True) - self._do_add_term_test(term, "WHERE recipient_id NOT IN (%(recipient_id_1)s)") + self._do_add_term_test(term, "WHERE (recipient_id NOT IN ([POSTCOMPILE_recipient_id_1]))") def test_add_term_using_in_operator_and_all_operand(self) -> None: mute_stream(self.realm, self.user_profile, "Verona") @@ -510,7 +510,7 @@ class NarrowBuilderTest(ZulipTestCase): def test_add_term_non_web_public_stream_in_web_public_query(self) -> None: self.make_stream("non-web-public-stream", realm=self.realm) term = dict(operator="stream", operand="non-web-public-stream") - builder = NarrowBuilder(self.user_profile, column("id"), self.realm, True) + builder = NarrowBuilder(self.user_profile, column("id", Integer), self.realm, True) def _build_query(term: Dict[str, Any]) -> Select: return builder.add_term(self.raw_query, term) @@ -3329,7 +3329,7 @@ class GetOldMessagesTest(ZulipTestCase): ] muting_conditions = exclude_muting_conditions(user_profile, narrow) - query = select([column("id").label("message_id")], None, table("zerver_message")) + query = select([column("id", Integer).label("message_id")], None, table("zerver_message")) query = query.where(*muting_conditions) expected_query = """\ SELECT id AS message_id \n\ @@ -3354,13 +3354,13 @@ WHERE NOT (recipient_id = %(recipient_id_1)s AND upper(subject) = upper(%(param_ ] muting_conditions = exclude_muting_conditions(user_profile, narrow) - query = select([column("id")], None, table("zerver_message")) + query = select([column("id", Integer)], None, table("zerver_message")) query = query.where(and_(*muting_conditions)) expected_query = """\ SELECT id \n\ FROM zerver_message \n\ -WHERE recipient_id NOT IN (%(recipient_id_1)s) \ +WHERE (recipient_id NOT IN ([POSTCOMPILE_recipient_id_1])) \ AND NOT \ (recipient_id = %(recipient_id_2)s AND upper(subject) = upper(%(param_1)s) OR \ recipient_id = %(recipient_id_3)s AND upper(subject) = upper(%(param_2)s))\ @@ -3368,7 +3368,7 @@ recipient_id = %(recipient_id_3)s AND upper(subject) = upper(%(param_2)s))\ self.assertEqual(get_sqlalchemy_sql(query), expected_query) params = get_sqlalchemy_query_params(query) self.assertEqual( - params["recipient_id_1"], get_recipient_id_for_stream_name(realm, "Verona") + params["recipient_id_1"], [get_recipient_id_for_stream_name(realm, "Verona")] ) self.assertEqual( params["recipient_id_2"], get_recipient_id_for_stream_name(realm, "Scotland") @@ -3480,7 +3480,7 @@ recipient_id = %(recipient_id_3)s AND upper(subject) = upper(%(param_2)s))\ {"anchor": 0, "num_before": 0, "num_after": 9, "narrow": '[["streams", "public"]]'}, sql ) - sql_template = "SELECT anon_1.message_id, anon_1.flags \nFROM (SELECT message_id, flags \nFROM zerver_usermessage JOIN zerver_message ON zerver_usermessage.message_id = zerver_message.id \nWHERE user_profile_id = {hamlet_id} AND recipient_id NOT IN ({public_streams_recipents}) ORDER BY message_id ASC \n LIMIT 10) AS anon_1 ORDER BY message_id ASC" + sql_template = "SELECT anon_1.message_id, anon_1.flags \nFROM (SELECT message_id, flags \nFROM zerver_usermessage JOIN zerver_message ON zerver_usermessage.message_id = zerver_message.id \nWHERE user_profile_id = {hamlet_id} AND (recipient_id NOT IN ({public_streams_recipents})) ORDER BY message_id ASC \n LIMIT 10) AS anon_1 ORDER BY message_id ASC" sql = sql_template.format(**query_ids) self.common_check_get_messages_query( { @@ -3542,9 +3542,9 @@ recipient_id = %(recipient_id_3)s AND upper(subject) = upper(%(param_2)s))\ sql_template = """\ SELECT anon_1.message_id, anon_1.flags, anon_1.subject, anon_1.rendered_content, anon_1.content_matches, anon_1.topic_matches \n\ FROM (SELECT message_id, flags, subject, rendered_content, array((SELECT ARRAY[sum(length(anon_3) - 11) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) + 11, strpos(anon_3, '') - 1] AS anon_2 \n\ -FROM unnest(string_to_array(ts_headline('zulip.english_us_search', rendered_content, plainto_tsquery('zulip.english_us_search', 'jumping'), 'HighlightAll = TRUE, StartSel = , StopSel = '), '')) AS anon_3 \n\ +FROM unnest(string_to_array(ts_headline('zulip.english_us_search', rendered_content, plainto_tsquery('zulip.english_us_search', 'jumping'), 'HighlightAll = TRUE, StartSel = , StopSel = '), '')) AS anon_3\n\ LIMIT ALL OFFSET 1)) AS content_matches, array((SELECT ARRAY[sum(length(anon_5) - 11) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) + 11, strpos(anon_5, '') - 1] AS anon_4 \n\ -FROM unnest(string_to_array(ts_headline('zulip.english_us_search', escape_html(subject), plainto_tsquery('zulip.english_us_search', 'jumping'), 'HighlightAll = TRUE, StartSel = , StopSel = '), '')) AS anon_5 \n\ +FROM unnest(string_to_array(ts_headline('zulip.english_us_search', escape_html(subject), plainto_tsquery('zulip.english_us_search', 'jumping'), 'HighlightAll = TRUE, StartSel = , StopSel = '), '')) AS anon_5\n\ LIMIT ALL OFFSET 1)) AS topic_matches \n\ FROM zerver_usermessage JOIN zerver_message ON zerver_usermessage.message_id = zerver_message.id \n\ WHERE user_profile_id = {hamlet_id} AND (search_tsvector @@ plainto_tsquery('zulip.english_us_search', 'jumping')) ORDER BY message_id ASC \n\ @@ -3558,9 +3558,9 @@ WHERE user_profile_id = {hamlet_id} AND (search_tsvector @@ plainto_tsquery('zul sql_template = """\ SELECT anon_1.message_id, anon_1.subject, anon_1.rendered_content, anon_1.content_matches, anon_1.topic_matches \n\ FROM (SELECT id AS message_id, subject, rendered_content, array((SELECT ARRAY[sum(length(anon_3) - 11) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) + 11, strpos(anon_3, '') - 1] AS anon_2 \n\ -FROM unnest(string_to_array(ts_headline('zulip.english_us_search', rendered_content, plainto_tsquery('zulip.english_us_search', 'jumping'), 'HighlightAll = TRUE, StartSel = , StopSel = '), '')) AS anon_3 \n\ +FROM unnest(string_to_array(ts_headline('zulip.english_us_search', rendered_content, plainto_tsquery('zulip.english_us_search', 'jumping'), 'HighlightAll = TRUE, StartSel = , StopSel = '), '')) AS anon_3\n\ LIMIT ALL OFFSET 1)) AS content_matches, array((SELECT ARRAY[sum(length(anon_5) - 11) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) + 11, strpos(anon_5, '') - 1] AS anon_4 \n\ -FROM unnest(string_to_array(ts_headline('zulip.english_us_search', escape_html(subject), plainto_tsquery('zulip.english_us_search', 'jumping'), 'HighlightAll = TRUE, StartSel = , StopSel = '), '')) AS anon_5 \n\ +FROM unnest(string_to_array(ts_headline('zulip.english_us_search', escape_html(subject), plainto_tsquery('zulip.english_us_search', 'jumping'), 'HighlightAll = TRUE, StartSel = , StopSel = '), '')) AS anon_5\n\ LIMIT ALL OFFSET 1)) AS topic_matches \n\ FROM zerver_message \n\ WHERE recipient_id = {scotland_recipient} AND (search_tsvector @@ plainto_tsquery('zulip.english_us_search', 'jumping')) ORDER BY zerver_message.id ASC \n\ @@ -3580,9 +3580,9 @@ WHERE recipient_id = {scotland_recipient} AND (search_tsvector @@ plainto_tsquer sql_template = """\ SELECT anon_1.message_id, anon_1.flags, anon_1.subject, anon_1.rendered_content, anon_1.content_matches, anon_1.topic_matches \n\ FROM (SELECT message_id, flags, subject, rendered_content, array((SELECT ARRAY[sum(length(anon_3) - 11) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) + 11, strpos(anon_3, '') - 1] AS anon_2 \n\ -FROM unnest(string_to_array(ts_headline('zulip.english_us_search', rendered_content, plainto_tsquery('zulip.english_us_search', '"jumping" quickly'), 'HighlightAll = TRUE, StartSel = , StopSel = '), '')) AS anon_3 \n\ +FROM unnest(string_to_array(ts_headline('zulip.english_us_search', rendered_content, plainto_tsquery('zulip.english_us_search', '"jumping" quickly'), 'HighlightAll = TRUE, StartSel = , StopSel = '), '')) AS anon_3\n\ LIMIT ALL OFFSET 1)) AS content_matches, array((SELECT ARRAY[sum(length(anon_5) - 11) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) + 11, strpos(anon_5, '') - 1] AS anon_4 \n\ -FROM unnest(string_to_array(ts_headline('zulip.english_us_search', escape_html(subject), plainto_tsquery('zulip.english_us_search', '"jumping" quickly'), 'HighlightAll = TRUE, StartSel = , StopSel = '), '')) AS anon_5 \n\ +FROM unnest(string_to_array(ts_headline('zulip.english_us_search', escape_html(subject), plainto_tsquery('zulip.english_us_search', '"jumping" quickly'), 'HighlightAll = TRUE, StartSel = , StopSel = '), '')) AS anon_5\n\ LIMIT ALL OFFSET 1)) AS topic_matches \n\ FROM zerver_usermessage JOIN zerver_message ON zerver_usermessage.message_id = zerver_message.id \n\ WHERE user_profile_id = {hamlet_id} AND (content ILIKE '%jumping%' OR subject ILIKE '%jumping%') AND (search_tsvector @@ plainto_tsquery('zulip.english_us_search', '"jumping" quickly')) ORDER BY message_id ASC \n\ diff --git a/zerver/views/message_fetch.py b/zerver/views/message_fetch.py index d11c001750..e0ac19c11b 100644 --- a/zerver/views/message_fetch.py +++ b/zerver/views/message_fetch.py @@ -9,17 +9,17 @@ from django.db import connection from django.http import HttpRequest, HttpResponse from django.utils.html import escape as escape_html from django.utils.translation import gettext as _ -from sqlalchemy import func from sqlalchemy.dialects import postgresql -from sqlalchemy.engine import Connection, RowProxy +from sqlalchemy.engine import Connection, Row from sqlalchemy.sql import ( ClauseElement, ColumnElement, - FromClause, Select, + Selectable, alias, and_, column, + func, join, literal, literal_column, @@ -29,7 +29,7 @@ from sqlalchemy.sql import ( table, union_all, ) -from sqlalchemy.types import Boolean, Integer, Text +from sqlalchemy.types import ARRAY, Boolean, Integer, Text from zerver.context_processors import get_valid_realm_from_request from zerver.lib.actions import recipient_for_user_profiles @@ -106,28 +106,22 @@ TS_STOP = "" def ts_locs_array( - config: "ColumnElement[str]", - text: "ColumnElement[str]", - tsquery: "ColumnElement[object]", -) -> "ColumnElement[List[List[int]]]": + config: "ColumnElement[Text]", + text: "ColumnElement[Text]", + tsquery: "ColumnElement[Any]", +) -> "ColumnElement[ARRAY[Integer]]": options = f"HighlightAll = TRUE, StartSel = {TS_START}, StopSel = {TS_STOP}" - delimited = func.ts_headline(config, text, tsquery, options) - parts = func.unnest(func.string_to_array(delimited, TS_START)).alias() - part = column(parts.name, Text) - part_len = func.length(part) - len(TS_STOP) - match_pos = func.sum(part_len).over(rows=(None, -1)) + len(TS_STOP) - match_len = func.strpos(part, TS_STOP) - 1 - ret = func.array( - select( - [ - postgresql.array([match_pos, match_len]), # type: ignore[call-overload] # https://github.com/dropbox/sqlalchemy-stubs/issues/188 - ] - ) - .select_from(parts) - .offset(1) - .as_scalar(), + delimited = func.ts_headline(config, text, tsquery, options, type_=Text) + part = func.unnest( + func.string_to_array(delimited, TS_START, type_=ARRAY(Text)), type_=Text + ).column_valued() + part_len = func.length(part, type_=Integer) - len(TS_STOP) + match_pos = func.sum(part_len, type_=Integer).over(rows=(None, -1)) + len(TS_STOP) + match_len = func.strpos(part, TS_STOP, type_=Integer) - 1 + return func.array( + select([postgresql.array([match_pos, match_len])]).offset(1).scalar_subquery(), + type_=ARRAY(Integer), ) - return ret # When you add a new operator to this, also update zerver/lib/narrow.py @@ -156,7 +150,7 @@ class NarrowBuilder: def __init__( self, user_profile: Optional[UserProfile], - msg_id_column: "ColumnElement[int]", + msg_id_column: "ColumnElement[Integer]", realm: Realm, is_web_public_query: bool = False, ) -> None: @@ -512,7 +506,7 @@ class NarrowBuilder: ) -> Select: match_positions_character = func.pgroonga_match_positions_character query_extract_keywords = func.pgroonga_query_extract_keywords - operand_escaped = func.escape_html(operand) + operand_escaped = func.escape_html(operand, type_=Text) keywords = query_extract_keywords(operand_escaped) query = query.column( match_positions_character(column("rendered_content", Text), keywords).label( @@ -520,11 +514,11 @@ class NarrowBuilder: ) ) query = query.column( - match_positions_character(func.escape_html(topic_column_sa()), keywords).label( - "topic_matches" - ) + match_positions_character( + func.escape_html(topic_column_sa(), type_=Text), keywords + ).label("topic_matches") ) - condition = column("search_pgroonga").op("&@~")(operand_escaped) + condition = column("search_pgroonga", Text).op("&@~")(operand_escaped) return query.where(maybe_negate(condition)) def _by_search_tsearch( @@ -533,13 +527,15 @@ class NarrowBuilder: tsquery = func.plainto_tsquery(literal("zulip.english_us_search"), literal(operand)) query = query.column( ts_locs_array( - literal("zulip.english_us_search"), column("rendered_content", Text), tsquery + literal("zulip.english_us_search", Text), column("rendered_content", Text), tsquery ).label("content_matches") ) # We HTML-escape the topic in PostgreSQL to avoid doing a server round-trip query = query.column( ts_locs_array( - literal("zulip.english_us_search"), func.escape_html(topic_column_sa()), tsquery + literal("zulip.english_us_search", Text), + func.escape_html(topic_column_sa(), type_=Text), + tsquery, ).label("topic_matches") ) @@ -551,7 +547,9 @@ class NarrowBuilder: if term[0] == '"' and term[-1] == '"': term = term[1:-1] term = "%" + connection.ops.prep_for_like_query(term) + "%" - cond = or_(column("content", Text).ilike(term), topic_column_sa().ilike(term)) + cond: ClauseElement = or_( + column("content", Text).ilike(term), topic_column_sa().ilike(term) + ) query = query.where(maybe_negate(cond)) cond = column("search_tsvector", postgresql.TSVECTOR).op("@@")(tsquery) @@ -733,7 +731,7 @@ def get_stream_from_narrow_access_unchecked( def exclude_muting_conditions( user_profile: UserProfile, narrow: OptionalNarrowListT ) -> List[ClauseElement]: - conditions = [] + conditions: List[ClauseElement] = [] stream_id = None try: # Note: It is okay here to not check access to stream @@ -777,20 +775,19 @@ def exclude_muting_conditions( def get_base_query_for_search( user_profile: Optional[UserProfile], need_message: bool, need_user_message: bool -) -> Tuple[Select, "ColumnElement[int]"]: +) -> Tuple[Select, "ColumnElement[Integer]"]: # Handle the simple case where user_message isn't involved first. if not need_user_message: assert need_message query = select([column("id", Integer).label("message_id")], None, table("zerver_message")) - inner_msg_id_col: ColumnElement[int] - inner_msg_id_col = literal_column("zerver_message.id", Integer) # type: ignore[assignment] # https://github.com/dropbox/sqlalchemy-stubs/pull/189 + inner_msg_id_col = literal_column("zerver_message.id", Integer) return (query, inner_msg_id_col) assert user_profile is not None if need_message: query = select( - [column("message_id"), column("flags", Integer)], - column("user_profile_id") == literal(user_profile.id), + [column("message_id", Integer), column("flags", Integer)], + column("user_profile_id", Integer) == literal(user_profile.id), join( table("zerver_usermessage"), table("zerver_message"), @@ -802,8 +799,8 @@ def get_base_query_for_search( return (query, inner_msg_id_col) query = select( - [column("message_id"), column("flags", Integer)], - column("user_profile_id") == literal(user_profile.id), + [column("message_id", Integer), column("flags", Integer)], + column("user_profile_id", Integer) == literal(user_profile.id), table("zerver_usermessage"), ) inner_msg_id_col = column("message_id", Integer) @@ -812,7 +809,7 @@ def get_base_query_for_search( def add_narrow_conditions( user_profile: Optional[UserProfile], - inner_msg_id_col: "ColumnElement[int]", + inner_msg_id_col: "ColumnElement[Integer]", query: Select, narrow: OptionalNarrowListT, is_web_public_query: bool, @@ -1019,7 +1016,7 @@ def get_messages_backend( need_message = True need_user_message = True - query: FromClause + query: Selectable query, inner_msg_id_col = get_base_query_for_search( user_profile=user_profile, need_message=need_message, @@ -1176,9 +1173,9 @@ def limit_query_to_range( anchor: int, anchored_to_left: bool, anchored_to_right: bool, - id_col: "ColumnElement[int]", + id_col: "ColumnElement[Integer]", first_visible_message_id: int, -) -> FromClause: +) -> Selectable: """ This code is actually generic enough that we could move it to a library, but our only caller for now is message search. @@ -1251,7 +1248,7 @@ def limit_query_to_range( def post_process_limited_query( - rows: Sequence[Union[RowProxy, Sequence[Any]]], + rows: Sequence[Union[Row, Sequence[Any]]], num_before: int, num_after: int, anchor: int, @@ -1268,7 +1265,7 @@ def post_process_limited_query( # that the clients will know that they got complete results. if first_visible_message_id > 0: - visible_rows: Sequence[Union[RowProxy, Sequence[Any]]] = [ + visible_rows: Sequence[Union[Row, Sequence[Any]]] = [ r for r in rows if r[0] >= first_visible_message_id ] else: