Browse Source

ref(py): sort runner module (#24723)

Evan Purkhiser 4 years ago
parent
commit
ba254d4f92

+ 7 - 5
src/sentry/runner/__init__.py

@@ -1,12 +1,14 @@
+import datetime
 import logging
 import os
-import click
 import sys
-import sentry
-import datetime
+
+import click
 import sentry_sdk
-from sentry.utils.imports import import_string
+
+import sentry
 from sentry.utils.compat import map
+from sentry.utils.imports import import_string
 
 # We need to run this here because of a concurrency bug in Python's locale
 # with the lazy initialization.
@@ -113,7 +115,7 @@ def configure():
     or from another invocation of `configure()`. If Click, we're able
     to pass along the Click context object.
     """
-    from .settings import discover_configs, configure
+    from .settings import configure, discover_configs
 
     try:
         ctx = click.get_current_context()

+ 2 - 4
src/sentry/runner/commands/backup.py

@@ -1,14 +1,12 @@
-import click
+from io import StringIO
 
+import click
 from django.apps import apps
 from django.core import management, serializers
 from django.db import connection
 
-from io import StringIO
-
 from sentry.runner.decorators import configuration
 
-
 EXCLUDED_APPS = frozenset(("auth", "contenttypes"))
 
 

+ 8 - 7
src/sentry/runner/commands/cleanup.py

@@ -7,7 +7,6 @@ from django.utils import timezone
 
 from sentry.runner.decorators import log_options
 
-
 # allows services like tagstore to add their own (abstracted) models
 # to cleanup
 EXTRA_BULK_QUERY_DELETES = []
@@ -38,6 +37,7 @@ API_TOKEN_TTL_IN_DAYS = 30
 def multiprocess_worker(task_queue):
     # Configure within each Process
     import logging
+
     from sentry.utils.imports import import_string
 
     logger = logging.getLogger("sentry.cleanup")
@@ -56,9 +56,7 @@ def multiprocess_worker(task_queue):
 
             configure()
 
-            from sentry import models
-            from sentry import deletions
-            from sentry import similarity
+            from sentry import deletions, models, similarity
 
             skip_models = [
                 # Handled by other parts of cleanup
@@ -133,7 +131,8 @@ def cleanup(days, project, concurrency, silent, model, router, timed):
 
     # Make sure we fork off multiprocessing pool
     # before we import or configure the app
-    from multiprocessing import Process, JoinableQueue as Queue
+    from multiprocessing import JoinableQueue as Queue
+    from multiprocessing import Process
 
     pool = []
     task_queue = Queue(1000)
@@ -148,13 +147,15 @@ def cleanup(days, project, concurrency, silent, model, router, timed):
     configure()
 
     from django.db import router as db_router
-    from sentry.app import nodestore
-    from sentry.db.deletion import BulkDeleteQuery
+
     from sentry import models
+    from sentry.app import nodestore
     from sentry.data_export.models import ExportedData
+    from sentry.db.deletion import BulkDeleteQuery
 
     if timed:
         import time
+
         from sentry.utils import metrics
 
         start_time = time.time()

+ 2 - 0
src/sentry/runner/commands/config.py

@@ -14,6 +14,7 @@ def config():
 def list(pattern):
     "List configuration options."
     from fnmatch import fnmatch
+
     from sentry.options import default_manager as manager
 
     for key in manager.all():
@@ -28,6 +29,7 @@ def list(pattern):
 def get(option, silent):
     "Get a configuration option."
     from django.conf import settings
+
     from sentry.options import default_manager as manager
     from sentry.options.manager import UnknownOption
 

+ 5 - 2
src/sentry/runner/commands/createuser.py

@@ -1,5 +1,7 @@
-import click
 import sys
+
+import click
+
 from sentry.runner.decorators import configuration
 
 
@@ -65,9 +67,10 @@ def createuser(email, password, superuser, no_password, no_input, force_update):
     if not no_password and not password:
         raise click.ClickException("No password set and --no-password not passed.")
 
+    from django.conf import settings
+
     from sentry import roles
     from sentry.models import User
-    from django.conf import settings
 
     fields = dict(
         email=email, username=email, is_superuser=superuser, is_staff=superuser, is_active=True

+ 5 - 2
src/sentry/runner/commands/devserver.py

@@ -1,7 +1,8 @@
-import click
+import threading
 import types
 from urllib.parse import urlparse
-import threading
+
+import click
 
 from sentry.runner.decorators import configuration, log_options
 
@@ -113,6 +114,7 @@ def devserver(
     os.environ["NODE_ENV"] = "production" if environment.startswith("prod") else environment
 
     from django.conf import settings
+
     from sentry import options
     from sentry.services.http import SentryHTTPServer
 
@@ -281,6 +283,7 @@ def devserver(
 
     import sys
     from subprocess import list2cmdline
+
     from honcho.manager import Manager
     from honcho.printer import Printer
 

+ 5 - 4
src/sentry/runner/commands/devservices.py

@@ -1,11 +1,11 @@
-import time
-import signal
 import os
+import signal
+import time
+
 import click
 
 from sentry.utils.compat import map
 
-
 # Work around a stupid docker issue: https://github.com/docker/for-mac/issues/5025
 RAW_SOCKET_HACK_PATH = os.path.expanduser(
     "~/Library/Containers/com.docker.docker/Data/docker.raw.sock"
@@ -221,6 +221,7 @@ def up(ctx, services, project, exclude, fast, skip_only_if):
 
 def _prepare_containers(project, skip_only_if=False, silent=False):
     from django.conf import settings
+
     from sentry import options as sentry_options
 
     containers = {}
@@ -254,6 +255,7 @@ def _start_service(
     client, low_level_client, name, containers, project, fast=False, always_start=False
 ):
     from django.conf import settings
+
     from docker.errors import NotFound
 
     options = containers[name]
@@ -394,7 +396,6 @@ def rm(ctx, project, services):
     an explicit list of services to remove.
     """
     from docker.errors import NotFound
-
     from sentry.runner import configure
 
     configure()

+ 1 - 0
src/sentry/runner/commands/django.py

@@ -1,4 +1,5 @@
 import click
+
 from sentry.runner.decorators import configuration
 
 

+ 1 - 0
src/sentry/runner/commands/exec.py

@@ -1,4 +1,5 @@
 import sys
+
 import click
 
 # If this changes, make sure to also update in the `__doc__`

+ 1 - 0
src/sentry/runner/commands/files.py

@@ -1,4 +1,5 @@
 import click
+
 from sentry.runner.decorators import configuration
 
 

Some files were not shown because too many files changed in this diff