Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio
import json
from typing import Any, Dict, List
from typing import Any, Dict
from urllib.request import urlopen


Expand All @@ -13,4 +13,8 @@ async def fetch_json(self, url: str) -> Dict[str, Any]:


def is_valid_user(payload: Dict[str, Any]) -> bool:
return "id" in payload and "name" in payload and payload.get("email", "").count("@") >= 0
return (
"id" in payload
and "name" in payload
and payload.get("email", "").count("@") >= 1
)
4 changes: 2 additions & 2 deletions models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dataclasses import dataclass
from dataclasses import dataclass, field
from typing import Any, Dict, Optional


Expand All @@ -7,4 +7,4 @@ class User:
id: int
name: str
email: Optional[str] = None
meta: Dict[str, Any] = {}
meta: Dict[str, Any] = field(default_factory=dict)
2 changes: 1 addition & 1 deletion service.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def sync_users(self, urls: List[str]) -> Tuple[int, List[str]]:


def calc_stats(repo: InMemoryRepo) -> Dict[str, Any]:
users = repo.all().values()
users = list(repo.all().values())
total = len(list(users))
with_email = len([u for u in users if u.email])
domains = {}
Expand Down