mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-07-21 12:58:42 -04:00
Convert all namedtuples to attrs. (#11665)
To improve type hints throughout the code.
This commit is contained in:
parent
07a3b5daba
commit
cbd82d0b2d
22 changed files with 231 additions and 206 deletions
|
@ -13,11 +13,22 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import collections
|
||||
import logging
|
||||
from abc import abstractmethod
|
||||
from enum import Enum
|
||||
from typing import TYPE_CHECKING, Any, Awaitable, Dict, List, Optional, Tuple, cast
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
Awaitable,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
Union,
|
||||
cast,
|
||||
)
|
||||
|
||||
import attr
|
||||
|
||||
from synapse.api.constants import EventContentFields, EventTypes, JoinRules
|
||||
from synapse.api.errors import StoreError
|
||||
|
@ -43,9 +54,10 @@ if TYPE_CHECKING:
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
RatelimitOverride = collections.namedtuple(
|
||||
"RatelimitOverride", ("messages_per_second", "burst_count")
|
||||
)
|
||||
@attr.s(slots=True, frozen=True, auto_attribs=True)
|
||||
class RatelimitOverride:
|
||||
messages_per_second: int
|
||||
burst_count: int
|
||||
|
||||
|
||||
class RoomSortOrder(Enum):
|
||||
|
@ -207,6 +219,7 @@ class RoomWorkerStore(CacheInvalidationWorkerStore):
|
|||
WHERE appservice_id = ? AND network_id = ?
|
||||
"""
|
||||
query_args.append(network_tuple.appservice_id)
|
||||
assert network_tuple.network_id is not None
|
||||
query_args.append(network_tuple.network_id)
|
||||
else:
|
||||
published_sql = """
|
||||
|
@ -284,7 +297,7 @@ class RoomWorkerStore(CacheInvalidationWorkerStore):
|
|||
"""
|
||||
|
||||
where_clauses = []
|
||||
query_args = []
|
||||
query_args: List[Union[str, int]] = []
|
||||
|
||||
if network_tuple:
|
||||
if network_tuple.appservice_id:
|
||||
|
@ -293,6 +306,7 @@ class RoomWorkerStore(CacheInvalidationWorkerStore):
|
|||
WHERE appservice_id = ? AND network_id = ?
|
||||
"""
|
||||
query_args.append(network_tuple.appservice_id)
|
||||
assert network_tuple.network_id is not None
|
||||
query_args.append(network_tuple.network_id)
|
||||
else:
|
||||
published_sql = """
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue