-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add type hints to synapse.storage.databases.main.client_ips
#10972
Changes from all commits
80c73c2
cf20c86
744756d
b452f8b
7637353
519bb6b
0acd03f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add type hints to `synapse.storage.databases.main.client_ips`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,18 @@ | |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
import logging | ||
from typing import TYPE_CHECKING, Collection, Dict, Iterable, List, Optional, Set, Tuple | ||
from typing import ( | ||
TYPE_CHECKING, | ||
Any, | ||
Collection, | ||
Dict, | ||
Iterable, | ||
List, | ||
Mapping, | ||
Optional, | ||
Set, | ||
Tuple, | ||
) | ||
|
||
from synapse.api import errors | ||
from synapse.api.constants import EventTypes | ||
|
@@ -595,7 +606,7 @@ async def rehydrate_device( | |
|
||
|
||
def _update_device_from_client_ips( | ||
device: JsonDict, client_ips: Dict[Tuple[str, str], JsonDict] | ||
device: JsonDict, client_ips: Mapping[Tuple[str, str], Mapping[str, Any]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was mypy unhappy here, sorry---something to do with a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's to do with the inner |
||
) -> None: | ||
ip = client_ips.get((device["user_id"], device["device_id"]), {}) | ||
device.update({"last_seen_ts": ip.get("last_seen"), "last_seen_ip": ip.get("ip")}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -773,9 +773,9 @@ async def get_user_ip_and_agents( | |
# Sanitize some of the data. We don't want to return tokens. | ||
return [ | ||
UserIpAndAgent( | ||
ip=str(data["ip"]), | ||
user_agent=str(data["user_agent"]), | ||
last_seen=int(data["last_seen"]), | ||
ip=data["ip"], | ||
user_agent=data["user_agent"], | ||
last_seen=data["last_seen"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to self: last_seen was There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you explain why this is safe? (Maybe I just need to chase the logic through next week?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought
|
||
) | ||
for data in raw_data | ||
] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3