1212# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313# See the License for the specific language governing permissions and
1414# limitations under the License.
15- from typing import Optional
15+ from typing import Any , Dict , List , Optional , Tuple , Union
1616
1717import attr
1818from nacl .signing import SigningKey
@@ -97,14 +97,14 @@ def state_key(self):
9797 def is_state (self ):
9898 return self ._state_key is not None
9999
100- async def build (self , prev_event_ids ) :
100+ async def build (self , prev_event_ids : List [ str ]) -> EventBase :
101101 """Transform into a fully signed and hashed event
102102
103103 Args:
104- prev_event_ids (list[str]) : The event IDs to use as the prev events
104+ prev_event_ids: The event IDs to use as the prev events
105105
106106 Returns:
107- FrozenEvent
107+ The signed and hashed event.
108108 """
109109
110110 state_ids = await self ._state .get_current_state_ids (
@@ -114,8 +114,13 @@ async def build(self, prev_event_ids):
114114
115115 format_version = self .room_version .event_format
116116 if format_version == EventFormatVersions .V1 :
117- auth_events = await self ._store .add_event_hashes (auth_ids )
118- prev_events = await self ._store .add_event_hashes (prev_event_ids )
117+ # The types of auth/prev events changes between event versions.
118+ auth_events = await self ._store .add_event_hashes (
119+ auth_ids
120+ ) # type: Union[List[str], List[Tuple[str, Dict[str, str]]]]
121+ prev_events = await self ._store .add_event_hashes (
122+ prev_event_ids
123+ ) # type: Union[List[str], List[Tuple[str, Dict[str, str]]]]
119124 else :
120125 auth_events = auth_ids
121126 prev_events = prev_event_ids
@@ -138,7 +143,7 @@ async def build(self, prev_event_ids):
138143 "unsigned" : self .unsigned ,
139144 "depth" : depth ,
140145 "prev_state" : [],
141- }
146+ } # type: Dict[str, Any]
142147
143148 if self .is_state ():
144149 event_dict ["state_key" ] = self ._state_key
0 commit comments