10570: Add isort support to project (#10573)

* Update requirements to avoid requests version clash

* 10570: Add isort to project

* 10570: Add isort config to project

* 10570: Add isort as a test run/CI step

* 10570: Add isort to pre-commit config

* 10570: Update isort config to allow tests/pages.py to be first-party, which is more appropriate

* 10570: Apply isort to entire codebase, using project config

* 10570: Explicitly include lib/ as a first-party import

This behaviour is already implicit in the current config, but making it explicit, partly to protect against a future change. Also makes it easier to grok what will happen to various bedrock-codebase imports

* 10570: Update isort config to stack Django imports above third-party ones

* 10570: [nit-fix] Update run-tests.sh to call isort with the same syntax pattern as we call black
This commit is contained in:
Steve Jalim 2021-10-11 18:08:58 +01:00 коммит произвёл GitHub
Родитель e1ad669b32
Коммит ab38b080ab
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
264 изменённых файлов: 600 добавлений и 584 удалений

Просмотреть файл

@ -17,6 +17,10 @@ repos:
hooks:
- id: black
language_version: python3
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
hooks:
- id: isort
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.7
hooks:

Просмотреть файл

@ -1,9 +1,4 @@
from everett.manager import (
ConfigEnvFileEnv,
ConfigManager,
ConfigOSEnv,
)
from everett.manager import ConfigEnvFileEnv, ConfigManager, ConfigOSEnv
config = ConfigManager(
[

Просмотреть файл

@ -4,8 +4,8 @@ import socket
from django.conf import settings
import commonware.log
import cef
import commonware.log
import dictconfig

Просмотреть файл

@ -9,12 +9,13 @@ import urllib.parse
from urllib.parse import unquote
from warnings import warn
from commonware.middleware import FrameOptionsHeader as OldFrameOptionsHeader
from django.conf import settings
from django.core.exceptions import MiddlewareNotUsed
from django.http import HttpResponse, HttpResponsePermanentRedirect
from django.utils.deprecation import MiddlewareMixin
from commonware.middleware import FrameOptionsHeader as OldFrameOptionsHeader
from lib.l10n_utils import translation
from . import urlresolvers

Просмотреть файл

@ -6,13 +6,13 @@ from django.conf import settings
from django.contrib.staticfiles.storage import staticfiles_storage
from django.utils.encoding import smart_str
from django_jinja import library
import jinja2
from django_jinja import library
from ..urlresolvers import reverse
from bedrock.base import waffle
from bedrock.utils import expand_locale_groups
from ..urlresolvers import reverse
CSS_TEMPLATE = '<link href="%s" rel="stylesheet" type="text/css" />'
JS_TEMPLATE = '<script type="text/javascript" src="%s" charset="utf-8"></script>'

Просмотреть файл

@ -4,7 +4,7 @@ import shutil
from django.conf import settings
from django.test import TestCase
from bedrock.settings.base import get_dev_languages, data_path
from bedrock.settings.base import data_path, get_dev_languages
class AcceptedLocalesTest(TestCase):

Просмотреть файл

@ -1,5 +1,5 @@
from django.template.loader import render_to_string
from django.test import override_settings, TestCase, RequestFactory
from django.test import RequestFactory, TestCase, override_settings
import jinja2

Просмотреть файл

@ -1,4 +1,4 @@
from django.test import override_settings, TestCase, RequestFactory
from django.test import RequestFactory, TestCase, override_settings
from bedrock.base.geo import get_country_from_request

Просмотреть файл

@ -1,12 +1,10 @@
from django.test import TestCase
from django.test import override_settings
from django.test import TestCase, override_settings
from django_jinja.backend import Jinja2
from mock import patch
from bedrock.base.templatetags import helpers
jinja_env = Jinja2.get_default()
SEND_TO_DEVICE_MESSAGE_SETS = {
"default": {

Просмотреть файл

@ -1,6 +1,6 @@
from urllib.parse import urlencode
from django.test import TestCase, RequestFactory
from django.test import RequestFactory, TestCase
from django.test.utils import override_settings
from bedrock.base.middleware import LocaleURLMiddleware

Просмотреть файл

@ -8,8 +8,8 @@ import os
import time
import warnings
from django.core.cache import cache, caches, CacheKeyWarning
from django.test import override_settings, RequestFactory, TestCase
from django.core.cache import CacheKeyWarning, cache, caches
from django.test import RequestFactory, TestCase, override_settings
# functions/classes for complex data type tests

Просмотреть файл

@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from django.urls import re_path
from django.test import TestCase
from django.test.client import RequestFactory
from django.test.utils import override_settings
from django.urls import re_path
import pytest
from bedrock.base.urlresolvers import find_supported, reverse, split_path, Prefixer
from mock import patch, Mock
from mock import Mock, patch
from bedrock.base.urlresolvers import Prefixer, find_supported, reverse, split_path
@pytest.mark.parametrize(

Просмотреть файл

@ -1,10 +1,9 @@
import json
from unittest.mock import patch
from django.test import TestCase, RequestFactory
from django.test import override_settings
from django.test import RequestFactory, TestCase, override_settings
from bedrock.base.views import geolocate, GeoRedirectView, GeoTemplateView
from bedrock.base.views import GeoRedirectView, GeoTemplateView, geolocate
class TestGeolocate(TestCase):

Просмотреть файл

@ -4,7 +4,6 @@ from mock import patch
from bedrock.base import waffle_config
from bedrock.mozorg.tests import TestCase
GOOD_CONFIG = {
"THE_DUDE": "abides",
"BOWLING": "true",

Просмотреть файл

@ -6,7 +6,6 @@ from django.utils.encoding import iri_to_uri
from django.utils.functional import lazy
from django.utils.translation.trans_real import parse_accept_lang_header
# Thread-local storage for URL prefixes. Access with (get|set)_url_prefix.
_local = local()

Просмотреть файл

@ -5,17 +5,18 @@ from datetime import datetime
from os import getenv
from time import time
import timeago
from django.conf import settings
from django.http import JsonResponse
from django.shortcuts import render
from django.views.generic import RedirectView
from django.views.decorators.cache import never_cache
from django.views.decorators.http import require_safe
from lib import l10n_utils
from django.views.generic import RedirectView
import timeago
from bedrock.base.geo import get_country_from_request
from bedrock.utils import git
from lib import l10n_utils
class GeoTemplateView(l10n_utils.L10nTemplateView):

Просмотреть файл

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from django.db import migrations, models
import django_extensions.db.fields.json

Просмотреть файл

@ -1,16 +1,15 @@
import json
import re
from pathlib import Path
from django.conf import settings
from django.db import models, transaction
from django_extensions.db.fields.json import JSONField
from jinja2 import Markup
from pathlib import Path
from bedrock.base.urlresolvers import reverse
URL_RE = re.compile(r"^https?://", re.I)

Просмотреть файл

@ -1,13 +1,13 @@
# coding=utf-8
from pathlib import Path
from django.test import override_settings
from jinja2 import Markup
from pathlib import Path
from bedrock.contentcards import models
from bedrock.mozorg.tests import TestCase
DATA_PATH = Path(__file__).parent.joinpath("test_data")

Просмотреть файл

@ -1,17 +1,17 @@
from functools import partialmethod
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
from django.conf import settings
from urllib.parse import urlparse, urlunparse, urlencode, parse_qs
from django.utils.functional import cached_property
import contentful as api
from crum import get_current_request, set_current_request
from django.utils.functional import cached_property
from rich_text_renderer import RichTextRenderer
from rich_text_renderer.base_node_renderer import BaseNodeRenderer
from rich_text_renderer.block_renderers import BaseBlockRenderer
from rich_text_renderer.text_renderers import BaseInlineRenderer
from lib.l10n_utils import render_to_string, get_locale
from lib.l10n_utils import get_locale, render_to_string
# Bedrock to Contentful locale map
LOCALE_MAP = {

Просмотреть файл

@ -1,7 +1,8 @@
# Generated by Django 2.2.21 on 2021-08-30 18:38
from django.db import migrations, models
import django.utils.timezone
from django.db import migrations, models
import django_extensions.db.fields.json

Просмотреть файл

@ -2,7 +2,6 @@ import bleach
import jinja2
from django_jinja import library
# based on bleach.sanitizer.ALLOWED_TAGS
ALLOWED_TAGS = [
"a",

Просмотреть файл

@ -6,7 +6,7 @@
from django.test import override_settings
from django.test.client import RequestFactory
from mock import patch, ANY
from mock import ANY, patch
from bedrock.exp import views
from bedrock.mozorg.tests import TestCase

Просмотреть файл

@ -4,10 +4,9 @@
from django.conf.urls import url
from bedrock.exp import views
from bedrock.mozorg.util import page
from bedrock.releasenotes import version_re
from bedrock.exp import views
latest_re = r"^firefox(?:/(?P<version>%s))?/%s/$"
whatsnew_re_all = latest_re % (version_re, "whatsnew/all")

Просмотреть файл

@ -2,11 +2,11 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from lib import l10n_utils
from django.conf import settings
from bedrock.contentcards.models import get_page_content_cards
from bedrock.pocketfeed.models import PocketArticle
from lib import l10n_utils
def new(request):

Просмотреть файл

@ -5,14 +5,13 @@
import codecs
import logging
import os.path
from time import mktime
from io import StringIO
from time import mktime
from django.conf import settings
from django.core.cache import caches
from django.utils.http import http_date
log = logging.getLogger(__name__)

Просмотреть файл

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from django.db import models, migrations
from django.db import migrations, models
class Migration(migrations.Migration):

Просмотреть файл

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from django.db import models, migrations
from django.db import migrations, models
class Migration(migrations.Migration):

Просмотреть файл

@ -1,4 +1,4 @@
from bedrock.redirects.util import redirect, platform_redirector, no_redirect
from bedrock.redirects.util import no_redirect, platform_redirector, redirect
def firefox_mobile_faq(request, *args, **kwargs):

Просмотреть файл

@ -1,11 +1,15 @@
from django.conf import settings
from django.template.loader import render_to_string
import jinja2
from django.template.loader import render_to_string
from django_jinja import library
from bedrock.firefox.firefox_details import firefox_desktop, firefox_android, firefox_ios
from bedrock.base.urlresolvers import reverse
from bedrock.firefox.firefox_details import (
firefox_android,
firefox_desktop,
firefox_ios,
)
from lib.l10n_utils import get_locale

Просмотреть файл

@ -10,16 +10,15 @@ from django.test.client import RequestFactory
from django.test.utils import override_settings
from django_jinja.backend import Jinja2
from mock import call, Mock, patch
from pyquery import PyQuery as pq
from jinja2 import Markup
from mock import Mock, call, patch
from pyquery import PyQuery as pq
from bedrock.base.urlresolvers import reverse
from bedrock.firefox import views as fx_views
from bedrock.firefox.firefox_details import FirefoxDesktop
from bedrock.mozorg.tests import TestCase
TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "test_data")
PROD_DETAILS_DIR = os.path.join(TEST_DATA_DIR, "product_details_json")
GOOD_PLATS = {"Windows": {}, "OS X": {}, "Linux": {}}

Просмотреть файл

@ -6,9 +6,10 @@ import os
from urllib.parse import parse_qsl, urlparse
from django.core.cache import caches
from mock import Mock, patch
from bedrock.firefox.firefox_details import FirefoxDesktop, FirefoxAndroid, FirefoxIOS
from bedrock.firefox.firefox_details import FirefoxAndroid, FirefoxDesktop, FirefoxIOS
from bedrock.mozorg.tests import TestCase
TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "test_data")

Просмотреть файл

@ -12,7 +12,7 @@ from django.test import override_settings
from django.test.client import RequestFactory
import querystringsafe_base64
from mock import patch, ANY
from mock import ANY, patch
from pyquery import PyQuery as pq
from bedrock.firefox import views

Просмотреть файл

@ -1,19 +1,17 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from django.conf.urls import url
from django.conf import settings
from django.conf.urls import url
from django.urls import path
import bedrock.releasenotes.views
from bedrock.firefox import views
from bedrock.mozorg.util import page
from bedrock.releasenotes import version_re
from bedrock.firefox import views
from bedrock.utils import views as utils_views
from bedrock.utils.views import VariationTemplateView
latest_re = r"^firefox(?:/(?P<version>%s))?/%s/$"
firstrun_re = latest_re % (version_re, "firstrun")
whatsnew_re = latest_re % (version_re, "whatsnew")

Просмотреть файл

@ -4,6 +4,7 @@
from product_details import product_details
from product_details.version_compare import Version
from bedrock.firefox.firefox_details import firefox_desktop

Просмотреть файл

@ -10,37 +10,40 @@ from collections import OrderedDict
from random import random
from urllib.parse import urlparse
import basket
import querystringsafe_base64
from django.conf import settings
from django.http import (
HttpResponsePermanentRedirect,
HttpResponseRedirect,
JsonResponse,
)
from django.utils.cache import add_never_cache_headers, patch_response_headers
from django.utils.encoding import force_text
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_GET, require_POST
from django.views.generic.base import TemplateView
from lib import l10n_utils
from lib.l10n_utils import L10nTemplateView
from lib.l10n_utils.dotlang import get_translations_native_names
from lib.l10n_utils.fluent import ftl, ftl_file_is_active
import basket
import querystringsafe_base64
from product_details.version_compare import Version
from bedrock.base.urlresolvers import reverse
from bedrock.base.views import GeoRedirectView
from bedrock.base.waffle import switch
from bedrock.base.waffle_config import config, DictOf
from bedrock.base.waffle_config import DictOf, config
from bedrock.contentful.api import ContentfulPage
from bedrock.firefox.firefox_details import firefox_android, firefox_desktop, firefox_ios
from bedrock.firefox.firefox_details import (
firefox_android,
firefox_desktop,
firefox_ios,
)
from bedrock.firefox.forms import SendToDeviceWidgetForm
from bedrock.newsletter.forms import NewsletterFooterForm
from bedrock.products.forms import VPNWaitlistForm
from bedrock.releasenotes import version_re
from bedrock.base.views import GeoRedirectView
from lib import l10n_utils
from lib.l10n_utils import L10nTemplateView
from lib.l10n_utils.dotlang import get_translations_native_names
from lib.l10n_utils.fluent import ftl, ftl_file_is_active
UA_REGEXP = re.compile(r"Firefox/(%s)" % version_re)

Просмотреть файл

@ -6,10 +6,8 @@
from django import forms
from lib.l10n_utils.dotlang import _, _lazy
from bedrock.mozorg.forms import HoneyPotWidget
from lib.l10n_utils.dotlang import _, _lazy
FRAUD_REPORT_FILE_SIZE_LIMIT = 5242880 # 5MB

Просмотреть файл

@ -1,6 +1,5 @@
from bedrock.redirects.util import redirect
redirectpatterns = (
# bug 1243240
redirect(r"^about/legal/report-abuse/?$", "legal.report-infringement"),

Просмотреть файл

@ -4,10 +4,9 @@
from django.conf.urls import url
from bedrock.mozorg.util import page
from bedrock.legal import views
from bedrock.legal_docs.views import LegalDocView
from bedrock.mozorg.util import page
urlpatterns = (
page("", "legal/index.html", ftl_files=["mozorg/about/legal"]),

Просмотреть файл

@ -1,11 +1,10 @@
from django.conf import settings
from django.core.management.base import BaseCommand
from bedrock.utils.git import GitRepo
import requests
from bedrock.legal_docs.models import LegalDoc
from bedrock.utils.git import GitRepo
class Command(BaseCommand):

Просмотреть файл

@ -7,7 +7,6 @@ from django.db import models, transaction
import markdown as md
from mdx_outline import OutlineExtension
LEGAL_DOCS_LOCALES_TO_BEDROCK = {
"hi": "hi-IN",
}

Просмотреть файл

@ -2,11 +2,12 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from mock import patch
from pathlib import Path
from django.http import Http404, HttpResponse
from django.test import override_settings, RequestFactory
from django.test import RequestFactory, override_settings
from mock import patch
from bedrock.legal_docs import views
from bedrock.legal_docs.models import LegalDoc, get_data_from_file_path

Просмотреть файл

@ -10,7 +10,6 @@ from django.views.generic import TemplateView
from bedrock.legal_docs.models import LegalDoc
from lib import l10n_utils
CACHE_TIMEOUT = settings.LEGAL_DOCS_CACHE_TIMEOUT

Просмотреть файл

@ -11,7 +11,6 @@ from django.urls import reverse
from bedrock.mozorg.util import get_fb_like_locale
from lib.l10n_utils import get_locale
# match 1 - 4 digits only
FC_RE = re.compile(r"^\d{1,4}$")

Просмотреть файл

@ -7,7 +7,6 @@ import unicodedata
from collections import OrderedDict
from operator import itemgetter
from bedrock.externalfiles import ExternalFile

Просмотреть файл

@ -8,13 +8,12 @@ import re
from datetime import datetime
from random import randrange
from django.urls import reverse
from django.forms import widgets
from django.urls import reverse
from django.utils.safestring import mark_safe
from lib.l10n_utils.fluent import ftl, ftl_lazy
FORMATS = (("H", ftl_lazy("newsletter-form-html")), ("T", ftl_lazy("newsletter-form-text")))
LANGS_TO_STRIP = ["en-US", "es"]
PARENTHETIC_RE = re.compile(r" \([^)]+\)$")

Просмотреть файл

@ -3,7 +3,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from bedrock.base.urlresolvers import reverse
from bedrock.mozorg.util import page

Просмотреть файл

@ -3,8 +3,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import datetime
from email.utils import formatdate
import time
from email.utils import formatdate
from django.conf import settings
from django.core.exceptions import MiddlewareNotUsed

Просмотреть файл

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from django.db import models, migrations
import django.utils.timezone
from django.db import migrations, models
import django_extensions.db.fields
import picklefield.fields

Просмотреть файл

@ -2,9 +2,9 @@
import random
import re
import urllib.parse
from os import path
from os.path import splitext
import urllib.parse
from django.conf import settings
from django.contrib.staticfiles.finders import find as find_static
@ -27,7 +27,6 @@ from django_jinja import library
from bedrock.base.templatetags.helpers import static
from bedrock.firefox.firefox_details import firefox_ios
ALL_FX_PLATFORMS = ("windows", "linux", "mac", "android", "ios")

Просмотреть файл

@ -8,7 +8,6 @@ from django_jinja import library
from jinja2 import Markup
from qrcode.image.svg import SvgPathImage
cache = caches["qrcode"]

Просмотреть файл

@ -6,7 +6,7 @@ from contextlib import contextmanager
from django.test import RequestFactory, TestCase as DjTestCase
from bedrock.base.urlresolvers import get_url_prefix, Prefixer, set_url_prefix
from bedrock.base.urlresolvers import Prefixer, get_url_prefix, set_url_prefix
from lib.l10n_utils import translation

Просмотреть файл

@ -2,14 +2,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from django.test import override_settings
from mock import patch, DEFAULT
from pathlib import Path
from bedrock.mozorg.tests import TestCase
from bedrock.mozorg.management.commands import update_product_details_files
from django.test import override_settings
from mock import DEFAULT, patch
from bedrock.mozorg.management.commands import update_product_details_files
from bedrock.mozorg.tests import TestCase
PD_REPO_TEST_PATH = Path(__file__).parent.joinpath("test_pd_repo")

Просмотреть файл

@ -3,9 +3,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from django.test.client import RequestFactory
from bedrock.base.urlresolvers import reverse
from bedrock.mozorg.context_processors import funnelcake_param
from bedrock.mozorg.tests import TestCase

Просмотреть файл

@ -8,8 +8,7 @@ from math import floor
from django.test import RequestFactory
from django.utils.http import parse_http_date
from bedrock.mozorg.tests import TestCase
from bedrock.mozorg.tests import views
from bedrock.mozorg.tests import TestCase, views
class ViewDecoratorTests(TestCase):

Просмотреть файл

@ -1,8 +1,8 @@
# coding: utf-8
import os.path
from datetime import datetime
from django.conf import settings
from django.test.client import RequestFactory
from django.test.utils import override_settings
@ -18,7 +18,6 @@ from bedrock.mozorg.templatetags import misc
from bedrock.mozorg.tests import TestCase
from lib.l10n_utils.fluent import fluent_l10n
TEST_FILES_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_files")
TEST_L10N_MEDIA_PATH = os.path.join(TEST_FILES_ROOT, "media", "%s", "l10n")

Просмотреть файл

@ -1,9 +1,8 @@
from mock import patch
from qrcode.image.svg import SvgPathImage
from bedrock.mozorg.tests import TestCase
from bedrock.mozorg.templatetags.qrcode import qrcode
from bedrock.mozorg.tests import TestCase
@patch("bedrock.mozorg.templatetags.qrcode.cache")

Просмотреть файл

@ -7,13 +7,11 @@
import os
from django.test import RequestFactory
from mock import ANY, patch
from bedrock.mozorg.tests import TestCase
from bedrock.mozorg.util import (
get_fb_like_locale,
page,
)
from bedrock.mozorg.util import get_fb_like_locale, page
ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_files")

Просмотреть файл

@ -6,11 +6,11 @@ import os
from django.test.client import RequestFactory
from bedrock.base.urlresolvers import reverse
from mock import ANY, patch
from bedrock.mozorg.tests import TestCase
from bedrock.base.urlresolvers import reverse
from bedrock.mozorg import views
from bedrock.mozorg.tests import TestCase
class TestViews(TestCase):

Просмотреть файл

@ -6,7 +6,6 @@ from django.http import HttpResponse
from bedrock.mozorg.decorators import cache_control_expires
RESPONSE_CONTENT = "The Dude abides, man."

Просмотреть файл

@ -6,10 +6,10 @@ from django.conf import settings
from django.conf.urls import url
from django.urls import path
from .util import page
from . import views
from bedrock.redirects.util import redirect
from . import views
from .util import page
urlpatterns = (
url(r"^$", views.home_view, name="mozorg.home"),

Просмотреть файл

@ -9,6 +9,7 @@ from django.conf.urls import url
from django.views.decorators.csrf import csrf_exempt
import commonware.log
from lib import l10n_utils
try:

Просмотреть файл

@ -10,8 +10,6 @@ from django.views.decorators.http import require_safe
from django.views.generic import TemplateView
from commonware.decorators import xframe_allow
from lib import l10n_utils
from lib.l10n_utils import L10nTemplateView
from bedrock.base.waffle import switch
from bedrock.contentcards.models import get_page_content_cards
@ -19,6 +17,8 @@ from bedrock.contentful.api import ContentfulPage
from bedrock.contentful.models import ContentfulEntry
from bedrock.mozorg.credits import CreditsFile
from bedrock.pocketfeed.models import PocketArticle
from lib import l10n_utils
from lib.l10n_utils import L10nTemplateView
credits_file = CreditsFile("credits")
TECH_BLOG_SLUGS = ["hacks", "cd", "futurereleases"]

Просмотреть файл

@ -9,11 +9,12 @@ from django import forms
from django.core.exceptions import ValidationError
from django.forms import widgets
from django.utils.safestring import mark_safe
from lib.l10n_utils.fluent import ftl, ftl_lazy
from product_details import product_details
from bedrock.mozorg.forms import FORMATS, EmailInput, PrivacyWidget, strip_parenthetical
from bedrock.newsletter import utils
from lib.l10n_utils.fluent import ftl, ftl_lazy
_newsletters_re = re.compile(r"^[\w,-]+$")

Просмотреть файл

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from django.db import migrations, models
import django_extensions.db.fields.json

Просмотреть файл

@ -1,6 +1,5 @@
from bedrock.redirects.util import redirect
redirectpatterns = (
# bug 926629
redirect(r"^newsletter/about_mobile(?:/(?:index\.html)?)?$", "newsletter.subscribe"),

Просмотреть файл

@ -4,13 +4,13 @@
import logging
import jinja2
from django.template.loader import render_to_string
import jinja2
from django_jinja import library
from lib.l10n_utils import get_locale
from bedrock.newsletter.forms import NewsletterFooterForm
from lib.l10n_utils import get_locale
log = logging.getLogger(__name__)

Просмотреть файл

@ -2,7 +2,6 @@ from mock import Mock
from bedrock.newsletter import utils
# patch basket client to never hit the network
# causes get_newsletters to use fallback newsletters
# in settings/newsletters.py

Просмотреть файл

@ -1,8 +1,9 @@
from django.test.utils import override_settings
from bedrock.base.urlresolvers import reverse
from mock import patch
from pyquery import PyQuery as pq
from bedrock.base.urlresolvers import reverse
from bedrock.mozorg.tests import TestCase

Просмотреть файл

@ -12,7 +12,6 @@ from bedrock.newsletter.forms import (
)
from bedrock.newsletter.tests import newsletters
newsletters_mock = mock.Mock()
newsletters_mock.return_value = newsletters

Просмотреть файл

@ -5,7 +5,6 @@ from bedrock.newsletter import utils
from bedrock.newsletter.models import Newsletter
from bedrock.newsletter.tests import newsletters
newsletters_mock = mock.Mock()
newsletters_mock.return_value = newsletters

Просмотреть файл

@ -3,8 +3,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from django.conf.urls import url
from bedrock.newsletter import views
from bedrock.mozorg.util import page
from bedrock.newsletter import views
# A UUID looks like: f81d4fae-7dec-11d0-a765-00a0c91e6bf6
# Here's a regex to match a UUID:

Просмотреть файл

@ -4,15 +4,10 @@
import json
import re
from html import escape
from collections import defaultdict
from html import escape
from operator import itemgetter
import basket
import basket.errors
import commonware.log
import lib.l10n_utils as l10n_utils
import requests
from django.conf import settings
from django.contrib import messages
from django.forms.formsets import formset_factory
@ -20,18 +15,30 @@ from django.http import HttpResponseRedirect, JsonResponse
from django.shortcuts import redirect
from django.utils.safestring import mark_safe
from django.views.decorators.cache import never_cache
from jinja2 import Markup
from lib.l10n_utils.fluent import ftl, ftl_lazy
import basket
import basket.errors
import commonware.log
import requests
from jinja2 import Markup
import lib.l10n_utils as l10n_utils
from bedrock.base import waffle
from bedrock.base.urlresolvers import reverse
# Cannot use short "from . import utils" because we need to mock
# utils.get_newsletters in our tests
from bedrock.base.geo import get_country_from_request
from bedrock.base.urlresolvers import reverse
from bedrock.newsletter import utils
from lib.l10n_utils.fluent import ftl, ftl_lazy
from .forms import CountrySelectForm, EmailForm, ManageSubscriptionsForm, NewsletterFooterForm, NewsletterForm
from .forms import (
CountrySelectForm,
EmailForm,
ManageSubscriptionsForm,
NewsletterFooterForm,
NewsletterForm,
)
log = commonware.log.getLogger("b.newsletter")

Просмотреть файл

@ -1,12 +1,12 @@
import datetime
import re
import requests
from sentry_sdk import capture_exception
from django.conf import settings
from django.utils.timezone import make_aware, utc
import requests
from sentry_sdk import capture_exception
def get_articles_data(count=8):
payload = {

Просмотреть файл

@ -6,7 +6,7 @@ from django.db.utils import DatabaseError
from jinja2 import Markup
from sentry_sdk import capture_exception
from bedrock.pocketfeed.api import get_articles_data, complete_articles_data
from bedrock.pocketfeed.api import complete_articles_data, get_articles_data
class PocketArticleManager(models.Manager):

Просмотреть файл

@ -1,11 +1,12 @@
import datetime
from django.test import override_settings
from django.utils.timezone import make_aware, utc
from bedrock.pocketfeed import api
import datetime
from mock import patch
from bedrock.pocketfeed import api
@override_settings(POCKET_API_URL="test_url", POCKET_CONSUMER_KEY="1234", POCKET_ACCESS_TOKEN="5678")
@patch.object(api, "requests")

Просмотреть файл

@ -1,14 +1,14 @@
import json
from pathlib import Path
from django.test import override_settings
import pytest
import responses
from bedrock.pocketfeed import api
from bedrock.pocketfeed.models import PocketArticle
import json
import pytest
import responses
from pathlib import Path
TEST_DATA = Path(__file__).with_name("test_data")

Просмотреть файл

@ -6,11 +6,17 @@
from django import forms
from bedrock.mozorg.forms import (
DateInput,
EmailInput,
HoneyPotWidget,
NumberInput,
TelInput,
TimeInput,
URLInput,
)
from lib.l10n_utils.dotlang import _, _lazy
from bedrock.mozorg.forms import DateInput, EmailInput, HoneyPotWidget, NumberInput, TelInput, TimeInput, URLInput
SPEAKER_REQUEST_FILE_SIZE_LIMIT = 5242880 # 5MB

Просмотреть файл

@ -1,6 +1,5 @@
from bedrock.redirects.util import redirect
redirectpatterns = (
# Bug 608370, 957664
redirect(r"^press/kit(?:.*\.html|s/?)$", "https://blog.mozilla.org/press/kits/"),

Просмотреть файл

@ -8,12 +8,12 @@ import datetime
from django.core import mail
from django.test.client import RequestFactory
from bedrock.base.urlresolvers import reverse
from mock import Mock, patch
from bedrock.base.urlresolvers import reverse
from bedrock.mozorg.tests import TestCase
from bedrock.press import forms as press_forms, views as press_views
from bedrock.press.forms import PressInquiryForm, SpeakerRequestForm
from bedrock.mozorg.tests import TestCase
class TestPressInquiry(TestCase):

Просмотреть файл

@ -9,9 +9,9 @@ from django.views.decorators.csrf import csrf_protect
from django.views.generic.edit import FormView
from bedrock.base.urlresolvers import reverse
from lib import l10n_utils
from .forms import PressInquiryForm, SpeakerRequestForm
from lib import l10n_utils
PRESS_INQUIRY_EMAIL_SUBJECT = "New Press Inquiry"
PRESS_INQUIRY_EMAIL_TO = ["press@mozilla.com"]

Просмотреть файл

@ -5,13 +5,11 @@ import re
from django.views.decorators.cache import cache_page
from commonware.response.decorators import xframe_allow
from bs4 import BeautifulSoup
from lib import l10n_utils
from commonware.response.decorators import xframe_allow
from bedrock.legal_docs.views import LegalDocView, load_legal_doc
from lib import l10n_utils
HN_PATTERN = re.compile(r"^h(\d)$")
HREF_PATTERN = re.compile(r"^https?\:\/\/www\.mozilla\.org")

Просмотреть файл

@ -2,9 +2,9 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import jinja2
from django.conf import settings
import jinja2
from django_jinja import library
from bedrock.base.urlresolvers import reverse

Просмотреть файл

@ -9,7 +9,6 @@ from django_jinja.backend import Jinja2
from bedrock.mozorg.tests import TestCase
TEST_FXA_ENDPOINT = "https://accounts.firefox.com/"
TEST_VPN_ENDPOINT = "https://vpn.mozilla.org/"
TEST_VPN_PRODUCT_ID = "prod_FvnsFHIfezy3ZI"

Просмотреть файл

@ -4,13 +4,13 @@
import json
from django.test.client import RequestFactory
from django.http import HttpResponse
from django.test.client import RequestFactory
from mock import patch
from bedrock.products import views
from bedrock.mozorg.tests import TestCase
from bedrock.products import views
@patch("bedrock.newsletter.forms.get_lang_choices", lambda *x: [["en", "English"]])

Просмотреть файл

@ -3,6 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from django.urls import path
from bedrock.mozorg.util import page
from bedrock.products import views

Просмотреть файл

@ -3,12 +3,13 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from html import escape
import basket
import basket.errors
from django.conf import settings
from django.http import JsonResponse
from django.views.decorators.http import require_POST, require_safe
import basket
import basket.errors
from bedrock.base.waffle import switch
from bedrock.newsletter.views import general_error, invalid_email_address
from bedrock.products.forms import VPNWaitlistForm

Просмотреть файл

@ -8,7 +8,6 @@ from bedrock.mozorg.tests import TestCase
from bedrock.redirects.middleware import RedirectsMiddleware
from bedrock.redirects.util import get_resolver, redirect
patterns = [
redirect(r"^dude/already/10th/", "/far/out/"),
redirect(r"^walter/prior/restraint/", "/finishes/coffee/"),

Просмотреть файл

@ -3,14 +3,22 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from urllib.parse import parse_qs, urlparse
from django.urls import URLPattern
from django.test import TestCase
from django.test.client import RequestFactory
from django.urls import URLPattern
from mock import patch
from bedrock.redirects.middleware import RedirectsMiddleware
from bedrock.redirects.util import get_resolver, header_redirector, is_firefox_redirector, no_redirect, redirect, ua_redirector, platform_redirector
from bedrock.redirects.util import (
get_resolver,
header_redirector,
is_firefox_redirector,
no_redirect,
platform_redirector,
redirect,
ua_redirector,
)
class TestHeaderRedirector(TestCase):

Просмотреть файл

@ -5,15 +5,20 @@
import re
from urllib.parse import parse_qs, urlencode
import commonware.log
from django.conf.urls import url
from django.http import HttpResponseGone, HttpResponsePermanentRedirect, HttpResponseRedirect
from django.http import (
HttpResponseGone,
HttpResponsePermanentRedirect,
HttpResponseRedirect,
)
from django.urls import NoReverseMatch, URLResolver, reverse
from django.urls.resolvers import RegexPattern
from django.utils.encoding import force_text
from django.utils.html import strip_tags
from django.views.decorators.vary import vary_on_headers
import commonware.log
from bedrock.mozorg.decorators import cache_control_expires
log = commonware.log.getLogger("redirects.util")

Просмотреть файл

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from django.db import migrations, models
import bedrock.releasenotes.models

Просмотреть файл

@ -19,7 +19,6 @@ from product_details.version_compare import Version
from bedrock.base.urlresolvers import reverse
from bedrock.releasenotes.utils import memoize
LONG_RN_CACHE_TIMEOUT = 7200 # 2 hours
cache = caches["release-notes"]
markdowner = markdown.Markdown(

Просмотреть файл

@ -1,13 +1,12 @@
import time
from mock import Mock, patch
from django.core.cache import caches
from mock import Mock, patch
from bedrock.mozorg.tests import TestCase
from bedrock.releasenotes import utils
release_cache = caches["release-notes"]

Просмотреть файл

@ -2,21 +2,21 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from pathlib import Path
from django.core.cache import caches
from django.http import Http404, HttpResponse
from django.test.client import RequestFactory
from django.test.utils import override_settings
from bedrock.base.urlresolvers import reverse
from mock import patch, Mock
from pathlib import Path
from mock import Mock, patch
from bedrock.base.urlresolvers import reverse
from bedrock.firefox.firefox_details import FirefoxDesktop
from bedrock.mozorg.tests import TestCase
from bedrock.releasenotes import views
from bedrock.releasenotes.models import ProductRelease
TESTS_PATH = Path(__file__).parent
DATA_PATH = str(TESTS_PATH.joinpath("data"))
RELEASES_PATH = str(TESTS_PATH)

Просмотреть файл

@ -3,17 +3,16 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from itertools import chain
from pathlib import Path
from django.core.cache import caches
from django.test.utils import override_settings
from mock import call, patch
from pathlib import Path
from bedrock.mozorg.tests import TestCase
from bedrock.releasenotes import models
RELEASES_PATH = str(Path(__file__).parent)
release_cache = caches["release-notes"]

Просмотреть файл

@ -9,12 +9,15 @@ from django.conf import settings
from django.http import Http404, HttpResponseRedirect
from django.urls import NoReverseMatch
from lib import l10n_utils
from bedrock.base.urlresolvers import reverse
from bedrock.firefox.firefox_details import firefox_desktop
from bedrock.firefox.templatetags.helpers import android_builds, ios_builds
from bedrock.releasenotes.models import get_latest_release_or_404, get_release_or_404, get_releases_or_404
from bedrock.releasenotes.models import (
get_latest_release_or_404,
get_release_or_404,
get_releases_or_404,
)
from lib import l10n_utils
SUPPORT_URLS = {
"Firefox for Android": "https://support.mozilla.org/products/mobile",

Просмотреть файл

@ -14,8 +14,6 @@ from django.db.models import Count
from dateutil.parser import parse as parsedate
from bedrock.security.models import HallOfFamer, MitreCVE, Product, SecurityAdvisory
from bedrock.utils.git import GitRepo
from bedrock.utils.management.cron_command import CronCommand
from bedrock.security.utils import (
FILENAME_RE,
check_hof_data,
@ -25,7 +23,8 @@ from bedrock.security.utils import (
parse_yml_file_base,
update_advisory_bugs,
)
from bedrock.utils.git import GitRepo
from bedrock.utils.management.cron_command import CronCommand
ADVISORIES_REPO = settings.MOFO_SECURITY_ADVISORIES_REPO
ADVISORIES_PATH = settings.MOFO_SECURITY_ADVISORIES_PATH

Просмотреть файл

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from django.db import models, migrations
import django.utils.timezone
from django.db import migrations, models
import django_extensions.db.fields
import django_extensions.db.fields.json

Просмотреть файл

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from django.db import migrations, models
import django_extensions.db.fields.json

Просмотреть файл

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from django.db import migrations
import django_extensions.db.fields.json

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше