Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 22, 2023
1 parent 3e28b14 commit 874d436
Show file tree
Hide file tree
Showing 44 changed files with 72 additions and 33 deletions.
3 changes: 2 additions & 1 deletion acceptance_tests/app/app_alembic/env.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os

import c2cwsgiutils.setup_process
from alembic import context
from sqlalchemy import engine_from_config, pool

import c2cwsgiutils.setup_process

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
Expand Down
6 changes: 3 additions & 3 deletions acceptance_tests/app/c2cwsgiutils_app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import c2cwsgiutils.pyramid
from c2cwsgiutils import broadcast, db
from c2cwsgiutils.health_check import HealthCheck, JsonCheckException
from pyramid.config import Configurator
from pyramid.httpexceptions import HTTPInternalServerError

import c2cwsgiutils.pyramid
from c2cwsgiutils import broadcast, db
from c2cwsgiutils.health_check import HealthCheck, JsonCheckException
from c2cwsgiutils_app import models


Expand Down
4 changes: 2 additions & 2 deletions acceptance_tests/app/c2cwsgiutils_app/get_hello.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import argparse

import c2cwsgiutils.db
import c2cwsgiutils.setup_process
import transaction

import c2cwsgiutils.db
import c2cwsgiutils.setup_process
from c2cwsgiutils_app import models


Expand Down
4 changes: 2 additions & 2 deletions acceptance_tests/app/c2cwsgiutils_app/services.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import logging

import requests
from c2cwsgiutils import sentry, services
from c2cwsgiutils.stats import increment_counter, set_gauge, timer_context
from pyramid.httpexceptions import (
HTTPBadRequest,
HTTPForbidden,
Expand All @@ -11,6 +9,8 @@
HTTPUnauthorized,
)

from c2cwsgiutils import sentry, services
from c2cwsgiutils.stats import increment_counter, set_gauge, timer_context
from c2cwsgiutils_app import models

ping_service = services.create("ping", "/ping")
Expand Down
1 change: 0 additions & 1 deletion acceptance_tests/app/models_graph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
from c2cwsgiutils.models_graph import generate_model_graph

from c2cwsgiutils_app import models


Expand Down
1 change: 1 addition & 0 deletions acceptance_tests/tests/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import psycopg2
import pytest

from c2cwsgiutils.acceptance import utils
from c2cwsgiutils.acceptance.composition import Composition
from c2cwsgiutils.acceptance.connection import Connection
Expand Down
3 changes: 2 additions & 1 deletion c2cwsgiutils/acceptance/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
from typing import Any, Callable, Dict, List, Mapping, Optional, cast

import netifaces
from c2cwsgiutils.acceptance import utils
from pyramid.request import Request

from c2cwsgiutils.acceptance import utils

LOG = logging.getLogger(__name__)
logging.basicConfig(
level=logging.DEBUG,
Expand Down
1 change: 1 addition & 0 deletions c2cwsgiutils/acceptance/print.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Any, Dict, Optional

import requests

from c2cwsgiutils.acceptance import connection, utils

LOG = logging.getLogger(__name__)
Expand Down
3 changes: 2 additions & 1 deletion c2cwsgiutils/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

import jwt
import pyramid.request
from c2cwsgiutils.config_utils import config_bool, env_or_config, env_or_settings
from pyramid.httpexceptions import HTTPForbidden
from requests_oauthlib import OAuth2Session

from c2cwsgiutils.config_utils import config_bool, env_or_config, env_or_settings

COOKIE_AGE = 7 * 24 * 3600
SECRET_PROP = "c2c.secret" # nosec # noqa
SECRET_ENV = "C2C_SECRET" # nosec # noqa
Expand Down
1 change: 1 addition & 0 deletions c2cwsgiutils/broadcast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Any, Callable, Dict, List, Optional, TypeVar

import pyramid.config

from c2cwsgiutils import config_utils, redis_utils
from c2cwsgiutils.broadcast import interface, local, redis

Expand Down
1 change: 1 addition & 0 deletions c2cwsgiutils/broadcast/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Any, Callable, List, Mapping, Optional

import redis

from c2cwsgiutils.broadcast import interface, local, utils

LOG = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions c2cwsgiutils/db_maintenance_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any, Mapping, Optional, cast

import pyramid.request

from c2cwsgiutils import auth, broadcast, config_utils, db, redis_utils

LOG = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions c2cwsgiutils/debug/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Optional

import pyramid.config

from c2cwsgiutils import auth, config_utils
from c2cwsgiutils.debug import utils

Expand Down
1 change: 1 addition & 0 deletions c2cwsgiutils/debug/_listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Any, Dict, List, Mapping, Optional, Tuple, cast

import objgraph

from c2cwsgiutils import broadcast
from c2cwsgiutils.debug.utils import get_size

Expand Down
3 changes: 2 additions & 1 deletion c2cwsgiutils/debug/_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import pyramid.config
import pyramid.request
import pyramid.response
from pyramid.httpexceptions import HTTPException, exception_response

from c2cwsgiutils import auth, broadcast, config_utils
from c2cwsgiutils.debug.utils import dump_memory_maps, get_size
from pyramid.httpexceptions import HTTPException, exception_response

LOG = logging.getLogger(__name__)
SPACE_RE = re.compile(r" +")
Expand Down
3 changes: 2 additions & 1 deletion c2cwsgiutils/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

import pyramid.request
import sqlalchemy.exc
from c2cwsgiutils import auth, config_utils
from cornice import cors
from pyramid.httpexceptions import HTTPError, HTTPException, HTTPRedirection, HTTPSuccessful
from webob.request import DisconnectionError

from c2cwsgiutils import auth, config_utils

DEVELOPMENT = os.environ.get("DEVELOPMENT", "0") != "0"
DEPRECATED_CONFIG_KEY = "c2c.error_details_secret"
DEPRECATED_ENV_KEY = "ERROR_DETAILS_SECRET"
Expand Down
5 changes: 3 additions & 2 deletions c2cwsgiutils/health_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@
cast,
)

import c2cwsgiutils.db
import pyramid.config
import pyramid.request
import requests
import sqlalchemy.engine
import sqlalchemy.orm
import sqlalchemy.sql
from c2cwsgiutils import auth, broadcast, config_utils, redis_utils, stats, version
from pyramid.httpexceptions import HTTPNotFound

import c2cwsgiutils.db
from c2cwsgiutils import auth, broadcast, config_utils, redis_utils, stats, version

if TYPE_CHECKING:
scoped_session = sqlalchemy.orm.scoped_session[sqlalchemy.orm.Session]
else:
Expand Down
5 changes: 3 additions & 2 deletions c2cwsgiutils/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import pyramid.config
import pyramid.request
import pyramid.response
from pyramid.httpexceptions import HTTPFound
from requests_oauthlib import OAuth2Session

from c2cwsgiutils import config_utils
from c2cwsgiutils.auth import (
GITHUB_AUTH_COOKIE_ENV,
Expand Down Expand Up @@ -38,8 +41,6 @@
is_auth_user,
)
from c2cwsgiutils.config_utils import env_or_settings
from pyramid.httpexceptions import HTTPFound
from requests_oauthlib import OAuth2Session

LOG = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion c2cwsgiutils/loader.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import logging
from typing import Dict, Optional, cast

from c2cwsgiutils import get_config_defaults
from plaster_pastedeploy import Loader as BaseLoader

from c2cwsgiutils import get_config_defaults

LOG = logging.getLogger(__name__)


Expand Down
1 change: 1 addition & 0 deletions c2cwsgiutils/logging_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any, Generator, Mapping, Tuple

import pyramid.request

from c2cwsgiutils import auth, broadcast, config_utils, redis_utils

LOG = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions c2cwsgiutils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import pyramid.request
import pyramid.response

from c2cwsgiutils.debug.utils import dump_memory_maps


Expand Down
3 changes: 2 additions & 1 deletion c2cwsgiutils/pretty_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

import pyramid.config
import ujson
from c2cwsgiutils.config_utils import config_bool, env_or_config
from cornice.renderer import CorniceRenderer
from pyramid.renderers import JSON

from c2cwsgiutils.config_utils import config_bool, env_or_config


class _FastDumps:
"""Dump the json fast using ujson."""
Expand Down
1 change: 1 addition & 0 deletions c2cwsgiutils/pyramid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cornice
import pyramid.config
import pyramid_tm

from c2cwsgiutils import (
broadcast,
coverage_setup,
Expand Down
1 change: 1 addition & 0 deletions c2cwsgiutils/redis_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any, Callable, Dict, Optional

import pyramid.config

from c2cwsgiutils import config_utils, stats

LOG = logging.getLogger(__name__)
Expand Down
3 changes: 2 additions & 1 deletion c2cwsgiutils/redis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import time
from typing import Any, Mapping, Optional, Tuple

import c2cwsgiutils.config_utils
import redis.client
import redis.exceptions
import redis.sentinel
import yaml

import c2cwsgiutils.config_utils

LOG = logging.getLogger(__name__)

REDIS_URL_KEY = "C2C_REDIS_URL"
Expand Down
3 changes: 2 additions & 1 deletion c2cwsgiutils/request_tracking/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
import pyramid.request
import requests.adapters
import requests.models
from c2cwsgiutils import config_utils, stats
from pyramid.threadlocal import get_current_request

from c2cwsgiutils import config_utils, stats

ID_HEADERS: List[str] = []
_HTTPAdapter_send = requests.adapters.HTTPAdapter.send
LOG = logging.getLogger(__name__)
Expand Down
5 changes: 3 additions & 2 deletions c2cwsgiutils/scripts/check_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
import warnings
from typing import Any, List, Optional

import c2cwsgiutils.setup_process
import requests.exceptions
from c2cwsgiutils import stats
from dateutil import parser as dp

import c2cwsgiutils.setup_process
from c2cwsgiutils import stats


def _ensure_slash(txt: Optional[str]) -> Optional[str]:
if txt is None:
Expand Down
5 changes: 3 additions & 2 deletions c2cwsgiutils/scripts/stats_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import time
from typing import TYPE_CHECKING, Dict, List, Optional

import c2cwsgiutils.setup_process
import sqlalchemy
import sqlalchemy.exc
import sqlalchemy.orm
import transaction
from zope.sqlalchemy import register

import c2cwsgiutils.setup_process
from c2cwsgiutils import stats
from c2cwsgiutils.prometheus import PushgatewayGroupPublisher
from zope.sqlalchemy import register

if TYPE_CHECKING:
scoped_session = sqlalchemy.orm.scoped_session[sqlalchemy.orm.Session]
Expand Down
3 changes: 2 additions & 1 deletion c2cwsgiutils/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

import pyramid.config
import sentry_sdk
from c2cwsgiutils import config_utils
from sentry_sdk.integrations.logging import LoggingIntegration, ignore_logger
from sentry_sdk.integrations.pyramid import PyramidIntegration
from sentry_sdk.integrations.redis import RedisIntegration
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware

from c2cwsgiutils import config_utils

LOG = logging.getLogger(__name__)
_client_setup = False

Expand Down
3 changes: 2 additions & 1 deletion c2cwsgiutils/setup_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
import pyramid.registry
import pyramid.request
import pyramid.router
from c2cwsgiutils import broadcast, coverage_setup, redis_stats, sentry, sql_profiler, stats
from pyramid.paster import bootstrap
from pyramid.scripts.common import get_config_loader, parse_vars

from c2cwsgiutils import broadcast, coverage_setup, redis_stats, sentry, sql_profiler, stats


def fill_arguments(
parser: argparse.ArgumentParser,
Expand Down
1 change: 1 addition & 0 deletions c2cwsgiutils/sql_profiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import warnings

import pyramid.request

from c2cwsgiutils import auth

ENV_KEY = "C2C_SQL_PROFILER_ENABLED"
Expand Down
1 change: 1 addition & 0 deletions c2cwsgiutils/sql_profiler/_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import pyramid.request
import sqlalchemy.engine
import sqlalchemy.event

from c2cwsgiutils import auth, broadcast, config_utils

LOG = logging.getLogger(__name__)
Expand Down
5 changes: 3 additions & 2 deletions c2cwsgiutils/sqlalchemylogger/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
from typing import Any, Dict, List

import sqlalchemy
from c2cwsgiutils.sqlalchemylogger._filters import ContainsExpression, DoesNotContainExpression
from c2cwsgiutils.sqlalchemylogger._models import Base, create_log_class
from sqlalchemy import create_engine
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.orm import sessionmaker
from sqlalchemy_utils import create_database, database_exists

from c2cwsgiutils.sqlalchemylogger._filters import ContainsExpression, DoesNotContainExpression
from c2cwsgiutils.sqlalchemylogger._models import Base, create_log_class

LOG = logging.getLogger(__name__)


Expand Down
1 change: 1 addition & 0 deletions c2cwsgiutils/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from typing import Any, Callable, Dict, Generator, List, Mapping, MutableMapping, Optional, Sequence, Tuple

import pyramid.request

from c2cwsgiutils import config_utils

LOG = logging.getLogger(__name__)
Expand Down
Loading

0 comments on commit 874d436

Please sign in to comment.