diff --git a/tildes/consumers/site_icon_downloader.py b/tildes/consumers/site_icon_downloader.py index c37afee..127f30e 100644 --- a/tildes/consumers/site_icon_downloader.py +++ b/tildes/consumers/site_icon_downloader.py @@ -23,7 +23,7 @@ class SiteIconDownloader(PgsqlQueueConsumer): ICON_FOLDER = "/var/lib/site-icons-spriter/site-icons" - def __init__(self, queue_name: str, routing_keys: Sequence[str]) -> None: + def __init__(self, queue_name: str, routing_keys: Sequence[str]): """Initialize the consumer, including the public suffix list.""" super().__init__(queue_name, routing_keys) diff --git a/tildes/consumers/topic_embedly_extractor.py b/tildes/consumers/topic_embedly_extractor.py index fa4209c..79653e8 100644 --- a/tildes/consumers/topic_embedly_extractor.py +++ b/tildes/consumers/topic_embedly_extractor.py @@ -28,9 +28,7 @@ RESCRAPE_DELAY = timedelta(hours=24) class TopicEmbedlyExtractor(PgsqlQueueConsumer): """Consumer that fetches data from Embedly's Extract API for link topics.""" - def __init__( - self, api_key: str, queue_name: str, routing_keys: Sequence[str] - ) -> None: + def __init__(self, api_key: str, queue_name: str, routing_keys: Sequence[str]): """Initialize the consumer, including creating a scraper instance.""" super().__init__(queue_name, routing_keys) diff --git a/tildes/consumers/topic_metadata_generator.py b/tildes/consumers/topic_metadata_generator.py index d6214f5..9b31f19 100644 --- a/tildes/consumers/topic_metadata_generator.py +++ b/tildes/consumers/topic_metadata_generator.py @@ -19,7 +19,7 @@ from tildes.models.topic import Topic class TopicMetadataGenerator(PgsqlQueueConsumer): """Consumer that generates content_metadata for topics.""" - def __init__(self, queue_name: str, routing_keys: Sequence[str]) -> None: + def __init__(self, queue_name: str, routing_keys: Sequence[str]): """Initialize the consumer, including the public suffix list.""" super().__init__(queue_name, routing_keys) diff --git a/tildes/scripts/clean_private_data.py b/tildes/scripts/clean_private_data.py index ee3dd1a..230e0cf 100644 --- a/tildes/scripts/clean_private_data.py +++ b/tildes/scripts/clean_private_data.py @@ -39,7 +39,7 @@ def clean_all_data(config_path: str) -> None: class DataCleaner: """Container class for all methods related to cleaning up old data.""" - def __init__(self, db_session: Session, retention_period: timedelta) -> None: + def __init__(self, db_session: Session, retention_period: timedelta): """Create a new DataCleaner.""" self.db_session = db_session self.retention_cutoff = datetime.now() - retention_period diff --git a/tildes/tildes/api.py b/tildes/tildes/api.py index c69ed44..4677ab8 100644 --- a/tildes/tildes/api.py +++ b/tildes/tildes/api.py @@ -15,7 +15,7 @@ class APIv0(Service): name_prefix = "apiv0_" base_path = "/api/v0" - def __init__(self, name: str, path: str, **kwargs: Any) -> None: + def __init__(self, name: str, path: str, **kwargs: Any): """Create a new service.""" name = self.name_prefix + name path = self.base_path + path diff --git a/tildes/tildes/auth.py b/tildes/tildes/auth.py index be1a2ef..4f29e2a 100644 --- a/tildes/tildes/auth.py +++ b/tildes/tildes/auth.py @@ -26,7 +26,7 @@ class DefaultRootFactory: __acl__ = ((Allow, Everyone, "view"),) - def __init__(self, request: Request) -> None: + def __init__(self, request: Request): """Root factory constructor - must take a request argument.""" pass diff --git a/tildes/tildes/lib/amqp.py b/tildes/tildes/lib/amqp.py index b55461f..27a8aed 100644 --- a/tildes/tildes/lib/amqp.py +++ b/tildes/tildes/lib/amqp.py @@ -30,7 +30,7 @@ class PgsqlQueueConsumer(AbstractConsumer): def __init__( self, queue_name: str, routing_keys: Sequence[str], uses_db: bool = True - ) -> None: + ): """Initialize a new queue, bindings, and consumer for it.""" self.connection = Connection() self.channel = self.connection.channel() diff --git a/tildes/tildes/lib/datetime.py b/tildes/tildes/lib/datetime.py index efd54d0..e97d4ce 100644 --- a/tildes/tildes/lib/datetime.py +++ b/tildes/tildes/lib/datetime.py @@ -15,7 +15,7 @@ class SimpleHoursPeriod: _SHORT_FORM_REGEX = re.compile(r"\d+[hd]", re.IGNORECASE) - def __init__(self, hours: int) -> None: + def __init__(self, hours: int): """Initialize a SimpleHoursPeriod from a number of hours.""" if hours <= 0: raise ValueError("Period must be at least 1 hour.") diff --git a/tildes/tildes/lib/markdown.py b/tildes/tildes/lib/markdown.py index 60d25f5..53f9214 100644 --- a/tildes/tildes/lib/markdown.py +++ b/tildes/tildes/lib/markdown.py @@ -298,7 +298,7 @@ class LinkifyFilter(Filter): def __init__( self, source: NonRecursiveTreeWalker, skip_tags: Optional[List[str]] = None - ) -> None: + ): """Initialize a linkification filter to apply to HTML. The skip_tags argument can be a list of tag names, and the contents of any of diff --git a/tildes/tildes/lib/ratelimit.py b/tildes/tildes/lib/ratelimit.py index 0edcee0..d52925b 100644 --- a/tildes/tildes/lib/ratelimit.py +++ b/tildes/tildes/lib/ratelimit.py @@ -33,7 +33,7 @@ class RateLimitResult: remaining_limit: int, time_until_max: timedelta, time_until_retry: Optional[timedelta] = None, - ) -> None: + ): """Initialize a RateLimitResult.""" # pylint: disable=too-many-arguments if is_allowed and time_until_retry is not None: @@ -171,7 +171,7 @@ class RateLimitedAction: by_user: bool = True, by_ip: bool = True, redis: Optional[StrictRedis] = None, - ) -> None: + ): """Initialize the limits on a particular action. The action will be limited to a maximum of `limit` calls over the time period diff --git a/tildes/tildes/models/comment/comment.py b/tildes/tildes/models/comment/comment.py index a4f52f2..89a4a6e 100644 --- a/tildes/tildes/models/comment/comment.py +++ b/tildes/tildes/models/comment/comment.py @@ -125,7 +125,7 @@ class Comment(DatabaseModel): author: User, markdown: str, parent_comment: Optional["Comment"] = None, - ) -> None: + ): """Create a new comment.""" self.topic = topic self.user_id = author.user_id diff --git a/tildes/tildes/models/comment/comment_label.py b/tildes/tildes/models/comment/comment_label.py index 4ac6208..3d95b62 100644 --- a/tildes/tildes/models/comment/comment_label.py +++ b/tildes/tildes/models/comment/comment_label.py @@ -53,7 +53,7 @@ class CommentLabel(DatabaseModel): label: CommentLabelOption, weight: float, reason: Optional[str] = None, - ) -> None: + ): """Add a new label to a comment.""" # pylint: disable=too-many-arguments self.comment_id = comment.comment_id diff --git a/tildes/tildes/models/comment/comment_notification.py b/tildes/tildes/models/comment/comment_notification.py index e075862..784df07 100644 --- a/tildes/tildes/models/comment/comment_notification.py +++ b/tildes/tildes/models/comment/comment_notification.py @@ -52,7 +52,7 @@ class CommentNotification(DatabaseModel): def __init__( self, user: User, comment: Comment, notification_type: CommentNotificationType - ) -> None: + ): """Create a new notification for a user from a comment.""" self.user = user self.comment = comment diff --git a/tildes/tildes/models/comment/comment_notification_query.py b/tildes/tildes/models/comment/comment_notification_query.py index 447b5f1..e54b4a0 100644 --- a/tildes/tildes/models/comment/comment_notification_query.py +++ b/tildes/tildes/models/comment/comment_notification_query.py @@ -17,7 +17,7 @@ from .comment_vote import CommentVote class CommentNotificationQuery(PaginatedQuery): """Specialized query class for CommentNotifications.""" - def __init__(self, request: Request) -> None: + def __init__(self, request: Request): """Initialize a CommentNotificationQuery for the request.""" super().__init__(CommentNotification, request) diff --git a/tildes/tildes/models/comment/comment_query.py b/tildes/tildes/models/comment/comment_query.py index de6e042..5b35d05 100644 --- a/tildes/tildes/models/comment/comment_query.py +++ b/tildes/tildes/models/comment/comment_query.py @@ -15,7 +15,7 @@ from .comment_vote import CommentVote class CommentQuery(PaginatedQuery): """Specialized ModelQuery for Comments.""" - def __init__(self, request: Request) -> None: + def __init__(self, request: Request): """Initialize a CommentQuery for the request. If the user is logged in, additional user-specific data will be fetched along diff --git a/tildes/tildes/models/comment/comment_tree.py b/tildes/tildes/models/comment/comment_tree.py index f9ca3f6..706a716 100644 --- a/tildes/tildes/models/comment/comment_tree.py +++ b/tildes/tildes/models/comment/comment_tree.py @@ -23,7 +23,7 @@ class CommentTree: comments: Sequence[Comment], sort: CommentSortOption, viewer: Optional[User] = None, - ) -> None: + ): """Create a sorted CommentTree from a flat list of Comments.""" self.tree: List[CommentInTree] = [] self.sort = sort @@ -225,7 +225,7 @@ class CommentTree: class CommentInTree(ObjectProxy): """Wrapper for Comments inside a CommentTree that adds some methods/properties.""" - def __init__(self, comment: Comment) -> None: + def __init__(self, comment: Comment): """Wrap a comment and add the new attributes needed by CommentTree.""" super().__init__(comment) diff --git a/tildes/tildes/models/comment/comment_vote.py b/tildes/tildes/models/comment/comment_vote.py index b982716..337c714 100644 --- a/tildes/tildes/models/comment/comment_vote.py +++ b/tildes/tildes/models/comment/comment_vote.py @@ -42,7 +42,7 @@ class CommentVote(DatabaseModel): user: User = relationship("User", innerjoin=True) comment: Comment = relationship("Comment", innerjoin=True) - def __init__(self, user: User, comment: Comment) -> None: + def __init__(self, user: User, comment: Comment): """Create a new vote on a comment.""" self.user = user self.comment = comment diff --git a/tildes/tildes/models/group/group.py b/tildes/tildes/models/group/group.py index e43d092..15f7759 100644 --- a/tildes/tildes/models/group/group.py +++ b/tildes/tildes/models/group/group.py @@ -65,7 +65,7 @@ class Group(DatabaseModel): """Order groups by their string representation.""" return str(self) < str(other) - def __init__(self, path: str, short_desc: Optional[str] = None) -> None: + def __init__(self, path: str, short_desc: Optional[str] = None): """Create a new group.""" self.path = path self.short_description = short_desc diff --git a/tildes/tildes/models/group/group_query.py b/tildes/tildes/models/group/group_query.py index e2255b0..5bfc7f7 100644 --- a/tildes/tildes/models/group/group_query.py +++ b/tildes/tildes/models/group/group_query.py @@ -15,7 +15,7 @@ from .group_subscription import GroupSubscription class GroupQuery(ModelQuery): """Specialized ModelQuery for Groups.""" - def __init__(self, request: Request) -> None: + def __init__(self, request: Request): """Initialize a GroupQuery for the request. If the user is logged in, additional user-specific data will be fetched along diff --git a/tildes/tildes/models/group/group_subscription.py b/tildes/tildes/models/group/group_subscription.py index 109de11..2eeff37 100644 --- a/tildes/tildes/models/group/group_subscription.py +++ b/tildes/tildes/models/group/group_subscription.py @@ -42,7 +42,7 @@ class GroupSubscription(DatabaseModel): user: User = relationship("User", innerjoin=True, backref="subscriptions") group: Group = relationship("Group", innerjoin=True, lazy=False) - def __init__(self, user: User, group: Group) -> None: + def __init__(self, user: User, group: Group): """Create a new subscription to a group.""" self.user = user self.group = group diff --git a/tildes/tildes/models/log/log.py b/tildes/tildes/models/log/log.py index f466857..46ca2ed 100644 --- a/tildes/tildes/models/log/log.py +++ b/tildes/tildes/models/log/log.py @@ -77,7 +77,7 @@ class Log(DatabaseModel, BaseLog): event_type: LogEventType, request: Request, info: Optional[Dict[str, Any]] = None, - ) -> None: + ): """Create a new log entry. User and IP address info is extracted from the Request object. `info` is an @@ -108,7 +108,7 @@ class LogComment(DatabaseModel, BaseLog): request: Request, comment: Comment, info: Optional[Dict[str, Any]] = None, - ) -> None: + ): """Create a new log entry related to a specific comment.""" # pylint: disable=non-parent-init-called Log.__init__(self, event_type, request, info) @@ -137,7 +137,7 @@ class LogTopic(DatabaseModel, BaseLog): request: Request, topic: Topic, info: Optional[Dict[str, Any]] = None, - ) -> None: + ): """Create a new log entry related to a specific topic.""" # pylint: disable=non-parent-init-called Log.__init__(self, event_type, request, info) diff --git a/tildes/tildes/models/message/message.py b/tildes/tildes/models/message/message.py index 3451788..f8c374e 100644 --- a/tildes/tildes/models/message/message.py +++ b/tildes/tildes/models/message/message.py @@ -109,9 +109,7 @@ class MessageConversation(DatabaseModel): ), ) - def __init__( - self, sender: User, recipient: User, subject: str, markdown: str - ) -> None: + def __init__(self, sender: User, recipient: User, subject: str, markdown: str): """Create a new message conversation between two users.""" self.sender_id = sender.user_id self.recipient_id = recipient.user_id @@ -235,9 +233,7 @@ class MessageReply(DatabaseModel): sender: User = relationship("User", lazy=False, innerjoin=True) - def __init__( - self, conversation: MessageConversation, sender: User, markdown: str - ) -> None: + def __init__(self, conversation: MessageConversation, sender: User, markdown: str): """Add a new reply to a message conversation.""" self.conversation_id = conversation.conversation_id self.sender_id = sender.user_id diff --git a/tildes/tildes/models/model_query.py b/tildes/tildes/models/model_query.py index 27b7b0f..1d944f0 100644 --- a/tildes/tildes/models/model_query.py +++ b/tildes/tildes/models/model_query.py @@ -18,7 +18,7 @@ ModelType = TypeVar("ModelType") class ModelQuery(Query): """Class for querying models via request.query().""" - def __init__(self, model_cls: Any, request: Request) -> None: + def __init__(self, model_cls: Any, request: Request): """Initialize a ModelQuery for the specified model and request.""" super().__init__(model_cls, session=request.db_session) diff --git a/tildes/tildes/models/pagination.py b/tildes/tildes/models/pagination.py index 1305218..324740b 100644 --- a/tildes/tildes/models/pagination.py +++ b/tildes/tildes/models/pagination.py @@ -18,7 +18,7 @@ ModelType = TypeVar("ModelType") class PaginatedQuery(ModelQuery): """ModelQuery subclass that supports being split into pages.""" - def __init__(self, model_cls: Any, request: Request) -> None: + def __init__(self, model_cls: Any, request: Request): """Initialize a PaginatedQuery for the specified model and request.""" super().__init__(model_cls, request) @@ -168,7 +168,7 @@ class PaginatedResults: Has a few extra attributes that give info about the pagination. """ - def __init__(self, query: PaginatedQuery, per_page: int) -> None: + def __init__(self, query: PaginatedQuery, per_page: int): """Fetch results from a PaginatedQuery.""" self.per_page = per_page diff --git a/tildes/tildes/models/scraper/scraper_result.py b/tildes/tildes/models/scraper/scraper_result.py index 4eb5dcd..97b1271 100644 --- a/tildes/tildes/models/scraper/scraper_result.py +++ b/tildes/tildes/models/scraper/scraper_result.py @@ -30,7 +30,7 @@ class ScraperResult(DatabaseModel): ) data: Any = Column(JSONB(none_as_null=True)) - def __init__(self, url: str, scraper_type: ScraperType, data: Any) -> None: + def __init__(self, url: str, scraper_type: ScraperType, data: Any): """Create a new ScraperResult.""" self.url = url self.scraper_type = scraper_type diff --git a/tildes/tildes/models/topic/topic_query.py b/tildes/tildes/models/topic/topic_query.py index 46adfdf..751f4d3 100644 --- a/tildes/tildes/models/topic/topic_query.py +++ b/tildes/tildes/models/topic/topic_query.py @@ -22,7 +22,7 @@ from .topic_vote import TopicVote class TopicQuery(PaginatedQuery): """Specialized query class for Topics.""" - def __init__(self, request: Request) -> None: + def __init__(self, request: Request): """Initialize a TopicQuery for the request. If the user is logged in, additional user-specific data will be fetched along diff --git a/tildes/tildes/models/topic/topic_vote.py b/tildes/tildes/models/topic/topic_vote.py index b5f9aa1..df94a9a 100644 --- a/tildes/tildes/models/topic/topic_vote.py +++ b/tildes/tildes/models/topic/topic_vote.py @@ -42,7 +42,7 @@ class TopicVote(DatabaseModel): user: User = relationship("User", innerjoin=True) topic: Topic = relationship("Topic", innerjoin=True) - def __init__(self, user: User, topic: Topic) -> None: + def __init__(self, user: User, topic: Topic): """Create a new vote on a topic.""" self.user = user self.topic = topic diff --git a/tildes/tildes/models/user/user.py b/tildes/tildes/models/user/user.py index 317e22a..2302fb8 100644 --- a/tildes/tildes/models/user/user.py +++ b/tildes/tildes/models/user/user.py @@ -123,7 +123,7 @@ class User(DatabaseModel): """Use the username for the string representation.""" return self.username - def __init__(self, username: str, password: str) -> None: + def __init__(self, username: str, password: str): """Create a new user account.""" self.username = username self.password = password diff --git a/tildes/tildes/models/user/user_invite_code.py b/tildes/tildes/models/user/user_invite_code.py index 381b5b7..10de921 100644 --- a/tildes/tildes/models/user/user_invite_code.py +++ b/tildes/tildes/models/user/user_invite_code.py @@ -42,7 +42,7 @@ class UserInviteCode(DatabaseModel): """Format the code into a more easily readable version.""" return separate_string(self.code, "-", 5) - def __init__(self, user: User) -> None: + def __init__(self, user: User): """Create a new (random) invite code owned by the user. Note that uniqueness is not confirmed here, so there is the potential to create diff --git a/tildes/tildes/routes.py b/tildes/tildes/routes.py index ae051ec..5e91beb 100644 --- a/tildes/tildes/routes.py +++ b/tildes/tildes/routes.py @@ -176,6 +176,6 @@ class LoggedInFactory: __acl__ = ((Allow, Authenticated, "view"),) - def __init__(self, request: Request) -> None: + def __init__(self, request: Request): """Initialize - no-op, but needs to take the request as an arg.""" pass diff --git a/tildes/tildes/schemas/fields.py b/tildes/tildes/schemas/fields.py index 370711d..d7fa9b7 100644 --- a/tildes/tildes/schemas/fields.py +++ b/tildes/tildes/schemas/fields.py @@ -19,9 +19,7 @@ from tildes.lib.string import simplify_string class Enum(Field): """Field for a native Python Enum (or subclasses).""" - def __init__( - self, enum_class: Optional[Type] = None, *args: Any, **kwargs: Any - ) -> None: + def __init__(self, enum_class: Optional[Type] = None, *args: Any, **kwargs: Any): """Initialize the field with an optional enum class.""" # pylint: disable=keyword-arg-before-vararg super().__init__(*args, **kwargs) @@ -83,7 +81,7 @@ class Markdown(Field): DEFAULT_MAX_LENGTH = 50000 - def __init__(self, max_length: Optional[int] = None, **kwargs: Any) -> None: + def __init__(self, max_length: Optional[int] = None, **kwargs: Any): """Initialize the field with a length validator.""" if not max_length: max_length = self.DEFAULT_MAX_LENGTH @@ -121,7 +119,7 @@ class SimpleString(Field): DEFAULT_MAX_LENGTH = 200 - def __init__(self, max_length: Optional[int] = None, **kwargs: Any) -> None: + def __init__(self, max_length: Optional[int] = None, **kwargs: Any): """Initialize the field with a length validator.""" if not max_length: max_length = self.DEFAULT_MAX_LENGTH diff --git a/tildes/tildes/scrapers/embedly_scraper.py b/tildes/tildes/scrapers/embedly_scraper.py index fc0a4c5..667e612 100644 --- a/tildes/tildes/scrapers/embedly_scraper.py +++ b/tildes/tildes/scrapers/embedly_scraper.py @@ -15,7 +15,7 @@ from tildes.models.scraper import ScraperResult class EmbedlyScraper: """Scraper that uses Embedly's "Extract" API.""" - def __init__(self, api_key: str) -> None: + def __init__(self, api_key: str): """Create a new scraper using the specified Embedly API key.""" self.api_key = api_key