Browse Source

Apply isort to make import styles consistent

This adds settings into pyproject.toml for the isort tool to match up
with the styles I've generally been using, and then applies it to the
whole project (by running "isort -rc").

Most of these changes are very minor, but it's good to fix the few
inconsistencies that were around.
merge-requests/72/head
Deimos 5 years ago
parent
commit
31ab15fe51
  1. 4
      tildes/consumers/site_icon_downloader.py
  2. 2
      tildes/consumers/topic_embedly_extractor.py
  3. 2
      tildes/consumers/topic_metadata_generator.py
  4. 2
      tildes/consumers/topic_youtube_scraper.py
  5. 1
      tildes/prospector.yaml
  6. 9
      tildes/pyproject.toml
  7. 6
      tildes/scripts/backup_database.py
  8. 2
      tildes/scripts/clean_private_data.py
  9. 1
      tildes/scripts/generate_site_icons_css.py
  10. 2
      tildes/tests/conftest.py
  11. 1
      tildes/tests/test_comment_user_mentions.py
  12. 2
      tildes/tests/test_id.py
  13. 2
      tildes/tests/test_ratelimit.py
  14. 2
      tildes/tildes/__init__.py
  15. 2
      tildes/tildes/api.py
  16. 3
      tildes/tildes/enums.py
  17. 2
      tildes/tildes/lib/amqp.py
  18. 2
      tildes/tildes/lib/cmark.py
  19. 1
      tildes/tildes/lib/database.py
  20. 2
      tildes/tildes/lib/datetime.py
  21. 1
      tildes/tildes/lib/hash.py
  22. 7
      tildes/tildes/lib/markdown.py
  23. 1
      tildes/tildes/lib/password.py
  24. 5
      tildes/tildes/lib/string.py
  25. 4
      tildes/tildes/lib/url_transform.py
  26. 2
      tildes/tildes/models/comment/__init__.py
  27. 1
      tildes/tildes/models/comment/comment_label.py
  28. 3
      tildes/tildes/models/comment/comment_notification.py
  29. 1
      tildes/tildes/models/comment/comment_notification_query.py
  30. 1
      tildes/tildes/models/comment/comment_query.py
  31. 1
      tildes/tildes/models/comment/comment_tree.py
  32. 1
      tildes/tildes/models/comment/comment_vote.py
  33. 1
      tildes/tildes/models/group/group_query.py
  34. 1
      tildes/tildes/models/group/group_subscription.py
  35. 1
      tildes/tildes/models/group/group_wiki_page.py
  36. 3
      tildes/tildes/models/pagination.py
  37. 1
      tildes/tildes/models/topic/topic_query.py
  38. 1
      tildes/tildes/models/topic/topic_visit.py
  39. 1
      tildes/tildes/models/topic/topic_vote.py
  40. 3
      tildes/tildes/models/user/user_invite_code.py
  41. 2
      tildes/tildes/schemas/fields.py
  42. 2
      tildes/tildes/schemas/group.py
  43. 3
      tildes/tildes/schemas/topic.py
  44. 5
      tildes/tildes/scrapers/youtube_scraper.py
  45. 4
      tildes/tildes/views/api/web/comment.py
  46. 2
      tildes/tildes/views/api/web/topic.py
  47. 2
      tildes/tildes/views/settings.py

4
tildes/consumers/site_icon_downloader.py

@ -7,10 +7,10 @@ from io import BytesIO
from os import path from os import path
from typing import Optional, Sequence from typing import Optional, Sequence
from amqpy import Message
from PIL import Image
import publicsuffix import publicsuffix
import requests import requests
from amqpy import Message
from PIL import Image
from tildes.enums import ScraperType from tildes.enums import ScraperType
from tildes.lib.amqp import PgsqlQueueConsumer from tildes.lib.amqp import PgsqlQueueConsumer

2
tildes/consumers/topic_embedly_extractor.py

@ -3,8 +3,8 @@
"""Consumer that fetches data from Embedly's Extract API for link topics.""" """Consumer that fetches data from Embedly's Extract API for link topics."""
from datetime import timedelta
import os import os
from datetime import timedelta
from typing import Sequence from typing import Sequence
from amqpy import Message from amqpy import Message

2
tildes/consumers/topic_metadata_generator.py

@ -5,8 +5,8 @@
from typing import Any, Dict, Sequence from typing import Any, Dict, Sequence
from amqpy import Message
import publicsuffix import publicsuffix
from amqpy import Message
from sqlalchemy import cast, func from sqlalchemy import cast, func
from sqlalchemy.dialects.postgresql import JSONB from sqlalchemy.dialects.postgresql import JSONB

2
tildes/consumers/topic_youtube_scraper.py

@ -3,8 +3,8 @@
"""Consumer that fetches data from YouTube's data API for relevant link topics.""" """Consumer that fetches data from YouTube's data API for relevant link topics."""
from datetime import timedelta
import os import os
from datetime import timedelta
from typing import Sequence from typing import Sequence
from amqpy import Message from amqpy import Message

1
tildes/prospector.yaml

@ -31,3 +31,4 @@ pylint:
- no-self-use # schemas do this a lot, would be nice to only disable for schemas - no-self-use # schemas do this a lot, would be nice to only disable for schemas
- too-few-public-methods # plenty of classes that don't need multiple methods - too-few-public-methods # plenty of classes that don't need multiple methods
- too-many-instance-attributes # models have many instance attributes - too-many-instance-attributes # models have many instance attributes
- ungrouped-imports # let isort handle this

9
tildes/pyproject.toml

@ -1,2 +1,11 @@
[tool.black] [tool.black]
exclude = "(\\.mypy_cache|node_modules|scss|sql|static)" exclude = "(\\.mypy_cache|node_modules|scss|sql|static)"
[tool.isort]
skip = "alembic"
line_length = 88
multi_line_output = 3 # "Vertical Hanging Indent" style
include_trailing_comma = true
lines_after_imports = 2
known_third_party = "alembic"
order_by_type = false

6
tildes/scripts/backup_database.py

@ -13,12 +13,12 @@ place, and will probably just crash completely if they aren't:
* The specified GPG recipient's public key is in the keyring * The specified GPG recipient's public key is in the keyring
""" """
from datetime import datetime, timedelta
from ftplib import FTP
import logging import logging
from netrc import netrc
import os import os
import subprocess import subprocess
from datetime import datetime, timedelta
from ftplib import FTP
from netrc import netrc
import click import click

2
tildes/scripts/clean_private_data.py

@ -9,8 +9,8 @@ Other things that should probably be added here eventually:
- Delete old used invite codes (30 days after used?) - Delete old used invite codes (30 days after used?)
""" """
from datetime import datetime, timedelta
import logging import logging
from datetime import datetime, timedelta
from sqlalchemy.orm.session import Session from sqlalchemy.orm.session import Session
from sqlalchemy.sql.expression import text from sqlalchemy.sql.expression import text

1
tildes/scripts/generate_site_icons_css.py

@ -8,6 +8,7 @@ import shutil
import stat import stat
from tempfile import NamedTemporaryFile from tempfile import NamedTemporaryFile
ICON_FOLDER = "/opt/tildes/static/images/site-icons" ICON_FOLDER = "/opt/tildes/static/images/site-icons"
OUTPUT_FILE = "/opt/tildes/static/css/site-icons.css" OUTPUT_FILE = "/opt/tildes/static/css/site-icons.css"

2
tildes/tests/conftest.py

@ -1,8 +1,8 @@
# Copyright (c) 2018 Tildes contributors <code@tildes.net> # Copyright (c) 2018 Tildes contributors <code@tildes.net>
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
from http.cookiejar import CookieJar
import os import os
from http.cookiejar import CookieJar
from pyramid import testing from pyramid import testing
from pyramid.paster import get_app, get_appsettings from pyramid.paster import get_app, get_appsettings

1
tildes/tests/test_comment_user_mentions.py

@ -2,7 +2,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
from pytest import fixture from pytest import fixture
from sqlalchemy import and_ from sqlalchemy import and_
from tildes.enums import CommentNotificationType from tildes.enums import CommentNotificationType

2
tildes/tests/test_id.py

@ -5,7 +5,7 @@
from pytest import raises from pytest import raises
from tildes.lib.id import id_to_id36, id36_to_id
from tildes.lib.id import id36_to_id, id_to_id36
def test_id_to_id36(): def test_id_to_id36():

2
tildes/tests/test_ratelimit.py

@ -8,10 +8,10 @@ from random import randint
from pytest import raises from pytest import raises
from tildes.lib.ratelimit import ( from tildes.lib.ratelimit import (
RATE_LIMITED_ACTIONS,
RateLimitedAction, RateLimitedAction,
RateLimitError, RateLimitError,
RateLimitResult, RateLimitResult,
RATE_LIMITED_ACTIONS,
) )

2
tildes/tildes/__init__.py

@ -5,13 +5,13 @@
from typing import Any, Dict, Optional, Tuple from typing import Any, Dict, Optional, Tuple
import sentry_sdk
from marshmallow.exceptions import ValidationError from marshmallow.exceptions import ValidationError
from paste.deploy.config import PrefixMiddleware from paste.deploy.config import PrefixMiddleware
from pyramid.config import Configurator from pyramid.config import Configurator
from pyramid.httpexceptions import HTTPTooManyRequests from pyramid.httpexceptions import HTTPTooManyRequests
from pyramid.request import Request from pyramid.request import Request
from redis import Redis from redis import Redis
import sentry_sdk
from sentry_sdk.integrations.pyramid import PyramidIntegration from sentry_sdk.integrations.pyramid import PyramidIntegration
from webassets import Bundle from webassets import Bundle

2
tildes/tildes/api.py

@ -5,8 +5,8 @@
from typing import Any from typing import Any
from cornice import Service
import venusian import venusian
from cornice import Service
class APIv0(Service): class APIv0(Service):

3
tildes/tildes/enums.py

@ -3,9 +3,8 @@
"""Contains Enum classes.""" """Contains Enum classes."""
from typing import Optional
import enum import enum
from typing import Optional
class CommentNotificationType(enum.Enum): class CommentNotificationType(enum.Enum):

2
tildes/tildes/lib/amqp.py

@ -3,9 +3,9 @@
"""Contains classes related to handling AMQP (rabbitmq) messages.""" """Contains classes related to handling AMQP (rabbitmq) messages."""
from abc import abstractmethod
import json import json
import os import os
from abc import abstractmethod
from typing import Sequence from typing import Sequence
from amqpy import AbstractConsumer, Connection, Message from amqpy import AbstractConsumer, Connection, Message

2
tildes/tildes/lib/cmark.py

@ -1,7 +1,7 @@
"""Set up the shared libcmark-gfm library and extensions.""" """Set up the shared libcmark-gfm library and extensions."""
# pylint: disable=invalid-name # pylint: disable=invalid-name
from ctypes import CDLL, c_char_p, c_int, c_size_t, c_void_p
from ctypes import c_char_p, c_int, c_size_t, c_void_p, CDLL
CMARK_DLL = CDLL("/usr/local/lib/libcmark-gfm.so") CMARK_DLL = CDLL("/usr/local/lib/libcmark-gfm.so")

1
tildes/tildes/lib/database.py

@ -7,7 +7,6 @@ import enum
from typing import Any, Callable, List, Optional from typing import Any, Callable, List, Optional
from pyramid.paster import bootstrap from pyramid.paster import bootstrap
from sqlalchemy import cast, func from sqlalchemy import cast, func
from sqlalchemy.dialects.postgresql import ARRAY from sqlalchemy.dialects.postgresql import ARRAY
from sqlalchemy.engine.interfaces import Dialect from sqlalchemy.engine.interfaces import Dialect

2
tildes/tildes/lib/datetime.py

@ -3,8 +3,8 @@
"""Functions/classes related to dates and times.""" """Functions/classes related to dates and times."""
from datetime import datetime, timedelta, timezone
import re import re
from datetime import datetime, timedelta, timezone
from typing import Any, Optional from typing import Any, Optional
from ago import human from ago import human

1
tildes/tildes/lib/hash.py

@ -6,6 +6,7 @@
from argon2 import PasswordHasher from argon2 import PasswordHasher
from argon2.exceptions import VerifyMismatchError from argon2.exceptions import VerifyMismatchError
# These parameter values were chosen to achieve a hash-verification time of about 10ms # These parameter values were chosen to achieve a hash-verification time of about 10ms
# on the current production server. They can be updated to different values if the # on the current production server. They can be updated to different values if the
# server changes (consider upgrading old password hashes on login as well if that # server changes (consider upgrading old password hashes on login as well if that

7
tildes/tildes/lib/markdown.py

@ -3,12 +3,12 @@
"""Functions/constants related to markdown handling.""" """Functions/constants related to markdown handling."""
from functools import partial
import re import re
from functools import partial
from typing import Any, Callable, Iterator, List, Match, Optional, Pattern, Tuple from typing import Any, Callable, Iterator, List, Match, Optional, Pattern, Tuple
from bs4 import BeautifulSoup
import bleach import bleach
from bs4 import BeautifulSoup
from html5lib.filters.base import Filter from html5lib.filters.base import Filter
from html5lib.treewalkers.base import NonRecursiveTreeWalker from html5lib.treewalkers.base import NonRecursiveTreeWalker
from pygments import highlight from pygments import highlight
@ -20,11 +20,12 @@ from tildes.enums import HTMLSanitizationContext
from tildes.metrics import histogram_timer from tildes.metrics import histogram_timer
from tildes.schemas.group import is_valid_group_path from tildes.schemas.group import is_valid_group_path
from tildes.schemas.user import is_valid_username from tildes.schemas.user import is_valid_username
from .cmark import ( from .cmark import (
CMARK_EXTENSIONS, CMARK_EXTENSIONS,
CMARK_OPTS,
cmark_find_syntax_extension, cmark_find_syntax_extension,
cmark_node_free, cmark_node_free,
CMARK_OPTS,
cmark_parser_attach_syntax_extension, cmark_parser_attach_syntax_extension,
cmark_parser_feed, cmark_parser_feed,
cmark_parser_finish, cmark_parser_finish,

1
tildes/tildes/lib/password.py

@ -7,6 +7,7 @@ from hashlib import sha1
from redis import ConnectionError, Redis, ResponseError # noqa from redis import ConnectionError, Redis, ResponseError # noqa
# unix socket path for redis server with the breached passwords bloom filter # unix socket path for redis server with the breached passwords bloom filter
BREACHED_PASSWORDS_REDIS_SOCKET = "/run/redis_breached_passwords/socket" BREACHED_PASSWORDS_REDIS_SOCKET = "/run/redis_breached_passwords/socket"

5
tildes/tildes/lib/string.py

@ -3,12 +3,11 @@
"""Functions related to processing/manipulating strings.""" """Functions related to processing/manipulating strings."""
from xml.etree.ElementTree import Element
import re import re
from typing import Iterator, List, Optional
import unicodedata import unicodedata
from typing import Iterator, List, Optional
from urllib.parse import quote from urllib.parse import quote
from xml.etree.ElementTree import Element
from html5lib import HTMLParser from html5lib import HTMLParser

4
tildes/tildes/lib/url_transform.py

@ -3,13 +3,13 @@
"""Functions related to transforming URLs (sanitization, cleanup, etc.).""" """Functions related to transforming URLs (sanitization, cleanup, etc.)."""
import logging
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from collections import Counter from collections import Counter
import logging
from urllib.parse import ( from urllib.parse import (
ParseResult,
parse_qs, parse_qs,
parse_qsl, parse_qsl,
ParseResult,
urlencode, urlencode,
urlparse, urlparse,
urlunparse, urlunparse,

2
tildes/tildes/models/comment/__init__.py

@ -2,9 +2,9 @@
from .comment import Comment, EDIT_GRACE_PERIOD from .comment import Comment, EDIT_GRACE_PERIOD
from .comment_bookmark import CommentBookmark from .comment_bookmark import CommentBookmark
from .comment_label import CommentLabel
from .comment_notification import CommentNotification from .comment_notification import CommentNotification
from .comment_notification_query import CommentNotificationQuery from .comment_notification_query import CommentNotificationQuery
from .comment_query import CommentQuery from .comment_query import CommentQuery
from .comment_label import CommentLabel
from .comment_tree import CommentInTree, CommentTree from .comment_tree import CommentInTree, CommentTree
from .comment_vote import CommentVote from .comment_vote import CommentVote

1
tildes/tildes/models/comment/comment_label.py

@ -15,6 +15,7 @@ from tildes.enums import CommentLabelOption
from tildes.metrics import incr_counter from tildes.metrics import incr_counter
from tildes.models import DatabaseModel from tildes.models import DatabaseModel
from tildes.models.user import User from tildes.models.user import User
from .comment import Comment from .comment import Comment

3
tildes/tildes/models/comment/comment_notification.py

@ -3,8 +3,8 @@
"""Contains the CommentNotification class.""" """Contains the CommentNotification class."""
from datetime import datetime
import re import re
from datetime import datetime
from typing import Any, List, Sequence, Tuple from typing import Any, List, Sequence, Tuple
from pyramid.security import Allow, DENY_ALL from pyramid.security import Allow, DENY_ALL
@ -17,6 +17,7 @@ from tildes.enums import CommentNotificationType
from tildes.lib.markdown import LinkifyFilter from tildes.lib.markdown import LinkifyFilter
from tildes.models import DatabaseModel from tildes.models import DatabaseModel
from tildes.models.user import User from tildes.models.user import User
from .comment import Comment from .comment import Comment

1
tildes/tildes/models/comment/comment_notification_query.py

@ -10,6 +10,7 @@ from sqlalchemy.orm import joinedload
from tildes.lib.id import id_to_id36 from tildes.lib.id import id_to_id36
from tildes.models.pagination import PaginatedQuery, PaginatedResults from tildes.models.pagination import PaginatedQuery, PaginatedResults
from .comment_notification import CommentNotification from .comment_notification import CommentNotification
from .comment_vote import CommentVote from .comment_vote import CommentVote

1
tildes/tildes/models/comment/comment_query.py

@ -10,6 +10,7 @@ from sqlalchemy.sql.expression import and_
from tildes.enums import CommentSortOption from tildes.enums import CommentSortOption
from tildes.models.pagination import PaginatedQuery from tildes.models.pagination import PaginatedQuery
from .comment import Comment from .comment import Comment
from .comment_bookmark import CommentBookmark from .comment_bookmark import CommentBookmark
from .comment_vote import CommentVote from .comment_vote import CommentVote

1
tildes/tildes/models/comment/comment_tree.py

@ -12,6 +12,7 @@ from wrapt import ObjectProxy
from tildes.enums import CommentTreeSortOption from tildes.enums import CommentTreeSortOption
from tildes.metrics import get_histogram from tildes.metrics import get_histogram
from tildes.models.user import User from tildes.models.user import User
from .comment import Comment from .comment import Comment

1
tildes/tildes/models/comment/comment_vote.py

@ -12,6 +12,7 @@ from sqlalchemy.sql.expression import text
from tildes.metrics import incr_counter from tildes.metrics import incr_counter
from tildes.models import DatabaseModel from tildes.models import DatabaseModel
from tildes.models.user import User from tildes.models.user import User
from .comment import Comment from .comment import Comment

1
tildes/tildes/models/group/group_query.py

@ -8,6 +8,7 @@ from typing import Any
from pyramid.request import Request from pyramid.request import Request
from tildes.models import ModelQuery from tildes.models import ModelQuery
from .group import Group from .group import Group
from .group_subscription import GroupSubscription from .group_subscription import GroupSubscription

1
tildes/tildes/models/group/group_subscription.py

@ -12,6 +12,7 @@ from sqlalchemy.sql.expression import text
from tildes.metrics import incr_counter from tildes.metrics import incr_counter
from tildes.models import DatabaseModel from tildes.models import DatabaseModel
from tildes.models.user import User from tildes.models.user import User
from .group import Group from .group import Group

1
tildes/tildes/models/group/group_wiki_page.py

@ -21,6 +21,7 @@ from tildes.lib.string import convert_to_url_slug
from tildes.models import DatabaseModel from tildes.models import DatabaseModel
from tildes.models.user import User from tildes.models.user import User
from tildes.schemas.group_wiki_page import GroupWikiPageSchema, PAGE_NAME_MAX_LENGTH from tildes.schemas.group_wiki_page import GroupWikiPageSchema, PAGE_NAME_MAX_LENGTH
from .group import Group from .group import Group

3
tildes/tildes/models/pagination.py

@ -9,7 +9,8 @@ from typing import Any, Iterator, List, Optional, Sequence, TypeVar
from pyramid.request import Request from pyramid.request import Request
from sqlalchemy import Column, func, inspect from sqlalchemy import Column, func, inspect
from tildes.lib.id import id_to_id36, id36_to_id
from tildes.lib.id import id36_to_id, id_to_id36
from .model_query import ModelQuery from .model_query import ModelQuery

1
tildes/tildes/models/topic/topic_query.py

@ -14,6 +14,7 @@ from tildes.enums import TopicSortOption
from tildes.lib.datetime import SimpleHoursPeriod, utc_now from tildes.lib.datetime import SimpleHoursPeriod, utc_now
from tildes.models.group import Group from tildes.models.group import Group
from tildes.models.pagination import PaginatedQuery from tildes.models.pagination import PaginatedQuery
from .topic import Topic from .topic import Topic
from .topic_bookmark import TopicBookmark from .topic_bookmark import TopicBookmark
from .topic_visit import TopicVisit from .topic_visit import TopicVisit

1
tildes/tildes/models/topic/topic_visit.py

@ -13,6 +13,7 @@ from sqlalchemy.orm import relationship
from tildes.lib.datetime import utc_now from tildes.lib.datetime import utc_now
from tildes.models import DatabaseModel from tildes.models import DatabaseModel
from tildes.models.user import User from tildes.models.user import User
from .topic import Topic from .topic import Topic

1
tildes/tildes/models/topic/topic_vote.py

@ -12,6 +12,7 @@ from sqlalchemy.sql.expression import text
from tildes.metrics import incr_counter from tildes.metrics import incr_counter
from tildes.models import DatabaseModel from tildes.models import DatabaseModel
from tildes.models.user import User from tildes.models.user import User
from .topic import Topic from .topic import Topic

3
tildes/tildes/models/user/user_invite_code.py

@ -3,15 +3,16 @@
"""Contains the UserInviteCode class.""" """Contains the UserInviteCode class."""
from datetime import datetime
import random import random
import string import string
from datetime import datetime
from sqlalchemy import CheckConstraint, Column, ForeignKey, Integer, Text, TIMESTAMP from sqlalchemy import CheckConstraint, Column, ForeignKey, Integer, Text, TIMESTAMP
from sqlalchemy.sql.expression import text from sqlalchemy.sql.expression import text
from tildes.lib.string import separate_string from tildes.lib.string import separate_string
from tildes.models import DatabaseModel from tildes.models import DatabaseModel
from .user import User from .user import User

2
tildes/tildes/schemas/fields.py

@ -6,10 +6,10 @@
import enum import enum
from typing import Any, Optional, Type from typing import Any, Optional, Type
import sqlalchemy_utils
from marshmallow.exceptions import ValidationError from marshmallow.exceptions import ValidationError
from marshmallow.fields import Field, String from marshmallow.fields import Field, String
from marshmallow.validate import Length, OneOf, Regexp from marshmallow.validate import Length, OneOf, Regexp
import sqlalchemy_utils
from tildes.lib.datetime import SimpleHoursPeriod from tildes.lib.datetime import SimpleHoursPeriod
from tildes.lib.id import ID36_REGEX from tildes.lib.id import ID36_REGEX

2
tildes/tildes/schemas/group.py

@ -5,10 +5,10 @@
import re import re
import sqlalchemy_utils
from marshmallow import pre_load, Schema, validates from marshmallow import pre_load, Schema, validates
from marshmallow.exceptions import ValidationError from marshmallow.exceptions import ValidationError
from marshmallow.fields import DateTime from marshmallow.fields import DateTime
import sqlalchemy_utils
from tildes.schemas.fields import Ltree, Markdown, SimpleString from tildes.schemas.fields import Ltree, Markdown, SimpleString

3
tildes/tildes/schemas/topic.py

@ -7,15 +7,16 @@ import re
import typing import typing
from urllib.parse import urlparse from urllib.parse import urlparse
import sqlalchemy_utils
from marshmallow import pre_load, Schema, validates, validates_schema, ValidationError from marshmallow import pre_load, Schema, validates, validates_schema, ValidationError
from marshmallow.fields import DateTime, List, Nested, String, URL from marshmallow.fields import DateTime, List, Nested, String, URL
import sqlalchemy_utils
from tildes.lib.url_transform import apply_url_transformations from tildes.lib.url_transform import apply_url_transformations
from tildes.schemas.fields import Enum, ID36, Ltree, Markdown, SimpleString from tildes.schemas.fields import Enum, ID36, Ltree, Markdown, SimpleString
from tildes.schemas.group import GroupSchema from tildes.schemas.group import GroupSchema
from tildes.schemas.user import UserSchema from tildes.schemas.user import UserSchema
TITLE_MAX_LENGTH = 200 TITLE_MAX_LENGTH = 200
TAG_SYNONYMS = {"spoiler": ["spoilers"]} TAG_SYNONYMS = {"spoiler": ["spoilers"]}

5
tildes/tildes/scrapers/youtube_scraper.py

@ -3,16 +3,17 @@
"""Contains the YoutubeScraper class.""" """Contains the YoutubeScraper class."""
from datetime import timedelta
import re import re
from datetime import timedelta
from typing import Any, Dict from typing import Any, Dict
from urllib.parse import parse_qs, urlparse from urllib.parse import parse_qs, urlparse
from dateutil import parser
import requests import requests
from dateutil import parser
from tildes.enums import ScraperType from tildes.enums import ScraperType
from tildes.models.scraper import ScraperResult from tildes.models.scraper import ScraperResult
from .exceptions import ScraperError from .exceptions import ScraperError

4
tildes/tildes/views/api/web/comment.py

@ -14,7 +14,7 @@ from sqlalchemy.orm.exc import FlushError
from webargs.pyramidparser import use_kwargs from webargs.pyramidparser import use_kwargs
from zope.sqlalchemy import mark_changed from zope.sqlalchemy import mark_changed
from tildes.enums import CommentNotificationType, CommentLabelOption, LogEventType
from tildes.enums import CommentLabelOption, CommentNotificationType, LogEventType
from tildes.lib.datetime import utc_now from tildes.lib.datetime import utc_now
from tildes.models.comment import ( from tildes.models.comment import (
Comment, Comment,
@ -25,7 +25,7 @@ from tildes.models.comment import (
) )
from tildes.models.log import LogComment from tildes.models.log import LogComment
from tildes.models.topic import TopicVisit from tildes.models.topic import TopicVisit
from tildes.schemas.comment import CommentSchema, CommentLabelSchema
from tildes.schemas.comment import CommentLabelSchema, CommentSchema
from tildes.views import IC_NOOP from tildes.views import IC_NOOP
from tildes.views.decorators import ic_view_config, rate_limit_view from tildes.views.decorators import ic_view_config, rate_limit_view

2
tildes/tildes/views/api/web/topic.py

@ -6,8 +6,8 @@
from marshmallow import ValidationError from marshmallow import ValidationError
from marshmallow.fields import String from marshmallow.fields import String
from pyramid.httpexceptions import HTTPNotFound from pyramid.httpexceptions import HTTPNotFound
from pyramid.response import Response
from pyramid.request import Request from pyramid.request import Request
from pyramid.response import Response
from sqlalchemy import cast, Text from sqlalchemy import cast, Text
from sqlalchemy.dialects.postgresql import ARRAY from sqlalchemy.dialects.postgresql import ARRAY
from sqlalchemy.exc import IntegrityError from sqlalchemy.exc import IntegrityError

2
tildes/tildes/views/settings.py

@ -6,11 +6,11 @@
from io import BytesIO from io import BytesIO
import pyotp import pyotp
import qrcode
from pyramid.httpexceptions import HTTPForbidden, HTTPUnprocessableEntity from pyramid.httpexceptions import HTTPForbidden, HTTPUnprocessableEntity
from pyramid.request import Request from pyramid.request import Request
from pyramid.response import Response from pyramid.response import Response
from pyramid.view import view_config from pyramid.view import view_config
import qrcode
from webargs.pyramidparser import use_kwargs from webargs.pyramidparser import use_kwargs
from tildes.lib.string import separate_string from tildes.lib.string import separate_string

Loading…
Cancel
Save