Fix stuffs

This commit is contained in:
Mathieu Velten 2023-05-19 16:56:26 +02:00
parent 74dbcaaab2
commit 2362ef10a3
6 changed files with 17 additions and 25 deletions

View File

@ -27,14 +27,13 @@ from synapse.api.constants import (
JoinRules,
PublicRoomsFilterFields,
)
from synapse.types import Requester
from synapse.api.errors import (
Codes,
HttpResponseException,
RequestSendFailed,
SynapseError,
)
from synapse.types import JsonDict, PublicRoom, ThirdPartyInstanceID
from synapse.types import JsonDict, ThirdPartyInstanceID
from synapse.util.caches.descriptors import _CacheContext, cached
from synapse.util.caches.response_cache import ResponseCache
@ -213,7 +212,7 @@ class RoomListHandler:
response: JsonDict = {}
num_results = len(results)
if limit is not None:
if limit is not None and probing_limit is not None:
more_to_come = num_results >= probing_limit
# Depending on direction we trim either the front or back.

View File

@ -122,7 +122,6 @@ from synapse.types import (
DomainSpecificString,
JsonDict,
JsonMapping,
PublicRoom,
Requester,
RoomAlias,
StateMap,

View File

@ -14,9 +14,9 @@
import logging
from typing import Awaitable, Callable, Iterable, List, Optional, Tuple
from synapse.types import PublicRoom
import attr
from synapse.types import PublicRoom
logger = logging.getLogger(__name__)

View File

@ -16,7 +16,6 @@
import logging
from abc import abstractmethod
from enum import Enum
from synapse.api.constants import HistoryVisibility
from typing import (
TYPE_CHECKING,
AbstractSet,
@ -39,6 +38,7 @@ from synapse.api.constants import (
Direction,
EventContentFields,
EventTypes,
HistoryVisibility,
JoinRules,
PublicRoomsFilterFields,
)
@ -543,7 +543,7 @@ class RoomWorkerStore(CacheInvalidationWorkerStore):
# Filter out Nones rather omit the field altogether
for key in list(entry):
if entry[key] == None:
if entry[key] is None:
del entry[key]
return entry

View File

@ -27,6 +27,7 @@ from typing import (
MutableMapping,
NoReturn,
Optional,
Required,
Set,
Tuple,
Type,
@ -953,15 +954,15 @@ class UserInfo:
is_shadow_banned: bool
class PublicRoom(TypedDict):
room_id: str
class PublicRoom(TypedDict, total=False):
room_id: Required[str]
name: Optional[str]
topic: Optional[str]
num_joined_members: int
num_joined_members: Required[int]
canonical_alias: Optional[str]
avatar_url: Optional[str]
world_readable: bool
guest_can_join: bool
world_readable: Required[bool]
guest_can_join: Required[bool]
join_rule: Optional[str]
room_type: Optional[str]

View File

@ -11,22 +11,15 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from twisted.test.proto_helpers import MemoryReactor
from http import HTTPStatus
from typing import (
TYPE_CHECKING,
Callable,
Dict,
List,
Optional,
TypeVar,
Tuple,
cast,
Iterable,
Optional,
Tuple,
)
from synapse.api.errors import SynapseError
from twisted.test.proto_helpers import MemoryReactor
from synapse.rest import admin, login, room
from synapse.server import HomeServer
from synapse.types import PublicRoom
@ -119,4 +112,4 @@ class FetchPublicRoomsTestCase(HomeserverTestCase):
"GET", self.url + "?limit=1&since=" + channel.json_body["next_batch"]
)
self.assertEqual(channel.code, HTTPStatus.OK, channel.result)
self.assertEquals(channel.json_body["chunk"][0]["num_joined_members"], 1)
self.assertEquals(channel.json_body["chunk"][0]["num_joined_members"], 1)