Linted code
Browse files
postly/clients/postly_client.py
CHANGED
@@ -54,13 +54,13 @@ class PostlyClient:
|
|
54 |
"""
|
55 |
if user_name not in self.userPosts:
|
56 |
raise KeyError(f"User {user_name} not found.")
|
57 |
-
|
58 |
if len(post_text) > self.post_max_length:
|
59 |
raise RuntimeError("Post is too long")
|
60 |
|
61 |
if not post_text.strip():
|
62 |
raise ValueError("Post cannot be empty.")
|
63 |
-
|
64 |
if not isinstance(timestamp, int) or timestamp < 0:
|
65 |
raise ValueError("Timestamp must be a non-negative integer.")
|
66 |
|
@@ -80,7 +80,7 @@ class PostlyClient:
|
|
80 |
"""
|
81 |
if user_name not in self.userPosts:
|
82 |
raise KeyError(f"User '{user_name}' not found.")
|
83 |
-
|
84 |
self.userPosts.pop(user_name, None)
|
85 |
|
86 |
def get_posts_for_user(self, user_name: str) -> List[str]:
|
@@ -94,7 +94,7 @@ class PostlyClient:
|
|
94 |
"""
|
95 |
if user_name not in self.userPosts:
|
96 |
raise KeyError(f"User '{user_name} not found.")
|
97 |
-
|
98 |
return [post_data.content for post_data in self.userPosts[user_name][::-1]]
|
99 |
|
100 |
def get_posts_for_topic(self, topic: str) -> List[str]:
|
@@ -126,13 +126,13 @@ class PostlyClient:
|
|
126 |
"""
|
127 |
if not isinstance(from_timestamp, int) or from_timestamp < 0:
|
128 |
raise ValueError("from_timestamp must be a non-negative integer.")
|
129 |
-
|
130 |
if not isinstance(to_timestamp, int) or to_timestamp < 0:
|
131 |
raise ValueError("to_timestamp must be a non-negative integer.")
|
132 |
-
|
133 |
if from_timestamp > to_timestamp:
|
134 |
raise ValueError("from_timestamp cannot be greater than to_timestamp.")
|
135 |
-
|
136 |
# construct topic histogram
|
137 |
topics_frequency = Counter()
|
138 |
for user in self.userPosts:
|
|
|
54 |
"""
|
55 |
if user_name not in self.userPosts:
|
56 |
raise KeyError(f"User {user_name} not found.")
|
57 |
+
|
58 |
if len(post_text) > self.post_max_length:
|
59 |
raise RuntimeError("Post is too long")
|
60 |
|
61 |
if not post_text.strip():
|
62 |
raise ValueError("Post cannot be empty.")
|
63 |
+
|
64 |
if not isinstance(timestamp, int) or timestamp < 0:
|
65 |
raise ValueError("Timestamp must be a non-negative integer.")
|
66 |
|
|
|
80 |
"""
|
81 |
if user_name not in self.userPosts:
|
82 |
raise KeyError(f"User '{user_name}' not found.")
|
83 |
+
|
84 |
self.userPosts.pop(user_name, None)
|
85 |
|
86 |
def get_posts_for_user(self, user_name: str) -> List[str]:
|
|
|
94 |
"""
|
95 |
if user_name not in self.userPosts:
|
96 |
raise KeyError(f"User '{user_name} not found.")
|
97 |
+
|
98 |
return [post_data.content for post_data in self.userPosts[user_name][::-1]]
|
99 |
|
100 |
def get_posts_for_topic(self, topic: str) -> List[str]:
|
|
|
126 |
"""
|
127 |
if not isinstance(from_timestamp, int) or from_timestamp < 0:
|
128 |
raise ValueError("from_timestamp must be a non-negative integer.")
|
129 |
+
|
130 |
if not isinstance(to_timestamp, int) or to_timestamp < 0:
|
131 |
raise ValueError("to_timestamp must be a non-negative integer.")
|
132 |
+
|
133 |
if from_timestamp > to_timestamp:
|
134 |
raise ValueError("from_timestamp cannot be greater than to_timestamp.")
|
135 |
+
|
136 |
# construct topic histogram
|
137 |
topics_frequency = Counter()
|
138 |
for user in self.userPosts:
|
postly/common/models.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
from dataclasses import dataclass
|
2 |
-
from pydantic import BaseModel
|
3 |
from typing import List
|
4 |
|
|
|
|
|
5 |
|
6 |
class StrictPost(BaseModel):
|
7 |
content: str
|
|
|
1 |
from dataclasses import dataclass
|
|
|
2 |
from typing import List
|
3 |
|
4 |
+
from pydantic import BaseModel
|
5 |
+
|
6 |
|
7 |
class StrictPost(BaseModel):
|
8 |
content: str
|