mirror of
https://gitlab.com/tildes/tildes.git
synced 2026-04-17 14:59:11 +02:00
Update Black to version 20.8b1
Updates the Black code-formatter for Python to the latest version, and applies it to some files that had formatting that the new version does differently (splitting collections with trailing commas across lines).
This commit is contained in:
@@ -6,7 +6,7 @@ astroid==2.4.1 # via prospector, pylint, pylint-celery, pylint-flask,
|
||||
attrs==20.2.0 # via pytest
|
||||
backcall==0.2.0 # via ipython
|
||||
beautifulsoup4==4.9.3
|
||||
black==19.10b0
|
||||
black==20.8b1
|
||||
bleach==3.2.1
|
||||
cached-property==1.5.2 # via pygit2
|
||||
certifi==2020.6.20 # via requests, sentry-sdk
|
||||
|
||||
@@ -107,7 +107,8 @@ class ContentMetadataFields(enum.Enum):
|
||||
|
||||
@classmethod
|
||||
def detail_fields_for_content_type(
|
||||
cls, content_type: "TopicContentType",
|
||||
cls,
|
||||
content_type: "TopicContentType",
|
||||
) -> List["ContentMetadataFields"]:
|
||||
"""Return a list of fields to display for detail about a particular type."""
|
||||
if content_type is TopicContentType.ARTICLE:
|
||||
|
||||
@@ -57,10 +57,14 @@ class CommentNotification(DatabaseModel):
|
||||
self, user: User, comment: Comment, notification_type: CommentNotificationType
|
||||
):
|
||||
"""Create a new notification for a user from a comment."""
|
||||
if notification_type in (
|
||||
CommentNotificationType.COMMENT_REPLY,
|
||||
CommentNotificationType.TOPIC_REPLY,
|
||||
) and not self.should_create_reply_notification(comment):
|
||||
if (
|
||||
notification_type
|
||||
in (
|
||||
CommentNotificationType.COMMENT_REPLY,
|
||||
CommentNotificationType.TOPIC_REPLY,
|
||||
)
|
||||
and not self.should_create_reply_notification(comment)
|
||||
):
|
||||
raise ValueError("That comment shouldn't create a reply notification")
|
||||
|
||||
self.user = user
|
||||
|
||||
@@ -23,7 +23,10 @@ class GroupStat(DatabaseModel):
|
||||
__tablename__ = "group_stats"
|
||||
|
||||
group_id: int = Column(
|
||||
Integer, ForeignKey("groups.group_id"), nullable=False, primary_key=True,
|
||||
Integer,
|
||||
ForeignKey("groups.group_id"),
|
||||
nullable=False,
|
||||
primary_key=True,
|
||||
)
|
||||
stat: GroupStatType = Column(ENUM(GroupStatType), nullable=False, primary_key=True)
|
||||
period: DateTimeTZRange = Column(TSTZRANGE, nullable=False, primary_key=True)
|
||||
|
||||
@@ -87,14 +87,20 @@ class Topic(DatabaseModel):
|
||||
Integer, ForeignKey("topic_schedule.schedule_id"), index=True
|
||||
)
|
||||
created_time: datetime = Column(
|
||||
TIMESTAMP(timezone=True), nullable=False, server_default=text("NOW()"),
|
||||
TIMESTAMP(timezone=True),
|
||||
nullable=False,
|
||||
server_default=text("NOW()"),
|
||||
)
|
||||
last_edited_time: Optional[datetime] = Column(TIMESTAMP(timezone=True))
|
||||
last_activity_time: datetime = Column(
|
||||
TIMESTAMP(timezone=True), nullable=False, server_default=text("NOW()"),
|
||||
TIMESTAMP(timezone=True),
|
||||
nullable=False,
|
||||
server_default=text("NOW()"),
|
||||
)
|
||||
last_interesting_activity_time: datetime = Column(
|
||||
TIMESTAMP(timezone=True), nullable=False, server_default=text("NOW()"),
|
||||
TIMESTAMP(timezone=True),
|
||||
nullable=False,
|
||||
server_default=text("NOW()"),
|
||||
)
|
||||
is_deleted: bool = Column(
|
||||
Boolean, nullable=False, server_default="false", index=True
|
||||
|
||||
@@ -37,7 +37,11 @@ class Enum(Field):
|
||||
return value.name.lower()
|
||||
|
||||
def _deserialize(
|
||||
self, value: str, attr: Optional[str], data: DataType, **kwargs: Any,
|
||||
self,
|
||||
value: str,
|
||||
attr: Optional[str],
|
||||
data: DataType,
|
||||
**kwargs: Any,
|
||||
) -> enum.Enum:
|
||||
"""Deserialize a string to the enum member with that name."""
|
||||
if not self._enum_class:
|
||||
@@ -64,7 +68,11 @@ class ShortTimePeriod(Field):
|
||||
"""
|
||||
|
||||
def _deserialize(
|
||||
self, value: str, attr: Optional[str], data: DataType, **kwargs: Any,
|
||||
self,
|
||||
value: str,
|
||||
attr: Optional[str],
|
||||
data: DataType,
|
||||
**kwargs: Any,
|
||||
) -> Optional[SimpleHoursPeriod]:
|
||||
"""Deserialize to a SimpleHoursPeriod object."""
|
||||
if value == "all":
|
||||
@@ -76,7 +84,11 @@ class ShortTimePeriod(Field):
|
||||
raise ValidationError("Invalid time period")
|
||||
|
||||
def _serialize(
|
||||
self, value: Optional[SimpleHoursPeriod], attr: str, obj: object, **kwargs: Any,
|
||||
self,
|
||||
value: Optional[SimpleHoursPeriod],
|
||||
attr: str,
|
||||
obj: object,
|
||||
**kwargs: Any,
|
||||
) -> Optional[str]:
|
||||
"""Serialize the value to the "short form" string."""
|
||||
if not value:
|
||||
@@ -105,7 +117,11 @@ class Markdown(Field):
|
||||
raise ValidationError("Cannot be entirely whitespace.")
|
||||
|
||||
def _deserialize(
|
||||
self, value: str, attr: Optional[str], data: DataType, **kwargs: Any,
|
||||
self,
|
||||
value: str,
|
||||
attr: Optional[str],
|
||||
data: DataType,
|
||||
**kwargs: Any,
|
||||
) -> str:
|
||||
"""Deserialize the string, removing carriage returns in the process."""
|
||||
value = value.replace("\r", "")
|
||||
@@ -138,7 +154,11 @@ class SimpleString(Field):
|
||||
super().__init__(validate=Length(min=1, max=max_length), **kwargs)
|
||||
|
||||
def _deserialize(
|
||||
self, value: str, attr: Optional[str], data: DataType, **kwargs: Any,
|
||||
self,
|
||||
value: str,
|
||||
attr: Optional[str],
|
||||
data: DataType,
|
||||
**kwargs: Any,
|
||||
) -> str:
|
||||
"""Deserialize the string, removing/replacing as necessary."""
|
||||
return simplify_string(value)
|
||||
@@ -162,7 +182,11 @@ class Ltree(Field):
|
||||
return value.path
|
||||
|
||||
def _deserialize(
|
||||
self, value: str, attr: Optional[str], data: DataType, **kwargs: Any,
|
||||
self,
|
||||
value: str,
|
||||
attr: Optional[str],
|
||||
data: DataType,
|
||||
**kwargs: Any,
|
||||
) -> sqlalchemy_utils.Ltree:
|
||||
"""Deserialize a string path to an Ltree object."""
|
||||
# convert to lowercase and replace spaces with underscores
|
||||
|
||||
@@ -14,7 +14,10 @@ from tildes.views.decorators import use_kwargs
|
||||
@view_config(route_name="ignored_topics", renderer="ignored_topics.jinja2")
|
||||
@use_kwargs(PaginatedListingSchema())
|
||||
def get_ignored_topics(
|
||||
request: Request, after: Optional[str], before: Optional[str], per_page: int,
|
||||
request: Request,
|
||||
after: Optional[str],
|
||||
before: Optional[str],
|
||||
per_page: int,
|
||||
) -> dict:
|
||||
"""Generate the ignored topics page."""
|
||||
# pylint: disable=unused-argument
|
||||
|
||||
Reference in New Issue
Block a user