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, JoinRules,
PublicRoomsFilterFields, PublicRoomsFilterFields,
) )
from synapse.types import Requester
from synapse.api.errors import ( from synapse.api.errors import (
Codes, Codes,
HttpResponseException, HttpResponseException,
RequestSendFailed, RequestSendFailed,
SynapseError, 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.descriptors import _CacheContext, cached
from synapse.util.caches.response_cache import ResponseCache from synapse.util.caches.response_cache import ResponseCache
@ -213,7 +212,7 @@ class RoomListHandler:
response: JsonDict = {} response: JsonDict = {}
num_results = len(results) 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 more_to_come = num_results >= probing_limit
# Depending on direction we trim either the front or back. # Depending on direction we trim either the front or back.

View File

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

View File

@ -14,9 +14,9 @@
import logging import logging
from typing import Awaitable, Callable, Iterable, List, Optional, Tuple 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__) logger = logging.getLogger(__name__)

View File

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

View File

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

View File

@ -11,22 +11,15 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from twisted.test.proto_helpers import MemoryReactor
from http import HTTPStatus from http import HTTPStatus
from typing import ( from typing import (
TYPE_CHECKING,
Callable,
Dict,
List,
Optional,
TypeVar,
Tuple,
cast,
Iterable, 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.rest import admin, login, room
from synapse.server import HomeServer from synapse.server import HomeServer
from synapse.types import PublicRoom from synapse.types import PublicRoom