Skip to content

Commit

Permalink
Fix pre-commit formatting checks
Browse files Browse the repository at this point in the history
  • Loading branch information
roekatz committed Feb 14, 2024
1 parent 194b9f1 commit adea0f5
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 28 deletions.
8 changes: 4 additions & 4 deletions packages/opal-client/opal_client/policy/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ async def update_policy(
bundle = None
bundle_succeeded = True
try:
bundle: Optional[PolicyBundle] = (
await self._policy_fetcher.fetch_policy_bundle(
directories, base_hash=base_hash
)
bundle: Optional[
PolicyBundle
] = await self._policy_fetcher.fetch_policy_bundle(
directories, base_hash=base_hash
)
if bundle:
if bundle.old_hash is None:
Expand Down
2 changes: 0 additions & 2 deletions packages/opal-client/opal_client/policy_store/opa_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ def __init__(
self._policy_data_cache = OpaStaticDataCache()

def _get_custom_ssl_context(self) -> Optional[ssl.SSLContext]:

if not self._tls_ca:
return None

Expand Down Expand Up @@ -629,7 +628,6 @@ async def _attempt_operations_with_postponed_failure_retry(
return

if len(failed_ops) == len(ops):

# all ops failed on this iteration, no point at retrying
for failure_msg in failure_msgs:
logger.error(failure_msg)
Expand Down
1 change: 0 additions & 1 deletion packages/opal-client/opal_client/tests/opa_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def test_constuctor_should_panic_tls_configured_without_all_parts():


def test_constructor_should_set_up_ca_certificate_even_without_tls_auth_type(tmpdir):

ca_path = os.path.join(tmpdir, "ca.pem")
with open(ca_path, "w") as ca:
ca.write(TEST_CA_CERT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ async def startup_event():


def setup_client(event):

# config to use mock OPA
policy_store = PolicyStoreClientFactory.create(store_type=PolicyStoreTypes.MOCK)
data_updater = DataUpdater(
Expand Down
1 change: 0 additions & 1 deletion packages/opal-common/opal_common/cli/docs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class MainTexts:
def __init__(self, first_line, name):

self.header = f"""\b
{first_line}
Open-Policy Administration Layer - {name}\b\f"""
Expand Down
1 change: 0 additions & 1 deletion packages/opal-common/opal_common/confi/confi.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ def get_cli_object(
help: str = None,
on_start: Callable = None,
):

if config_objects is None:
config_objects = []
config_objects.append(self)
Expand Down
5 changes: 2 additions & 3 deletions packages/opal-common/opal_common/emport.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def get_flat_list(self):
"""
res = []
for member in self._members:

# if a member is an Emport itself flatten it as well
if isinstance(member, Emport):
res += member.get_flat_list()
Expand Down Expand Up @@ -138,7 +137,7 @@ def emport_by_class(from_path, cls, import_items=None):
import_items = import_items or ["*"]
module_obj = __import__(from_path, globals(), locals(), import_items, 0)
clean_items = ObjectUtils.get_class_members_who_derive_of(module_obj, cls)
for (sub_name, sub_module) in ObjectUtils.get_members_who_are_instance_of(
for sub_name, sub_module in ObjectUtils.get_members_who_are_instance_of(
module_obj, module_obj.__class__
):
results = ObjectUtils.get_class_members_who_derive_of(sub_module, cls)
Expand Down Expand Up @@ -166,7 +165,7 @@ def emport_objects_by_class(from_path, cls, import_items=None):
clean_items = ObjectUtils.get_class_members_who_derive_of(module_obj, cls)
results.extend(clean_items)
# nested
for (sub_name, sub_module) in ObjectUtils.get_members_who_are_instance_of(
for sub_name, sub_module in ObjectUtils.get_members_who_are_instance_of(
module_obj, module_obj.__class__
):
objects = ObjectUtils.get_class_members_who_derive_of(sub_module, cls)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async def error_callback(error: Exception, event: FetchEvent):

# register the callback
engine.register_failure_handler(error_callback)

# callback for success - shouldn't eb called in this test
async def callback(result):
got_data_event.set()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ async def test_simple_rpc_fetch(server):
rpc_method_name="get_data", rpc_arguments={"suffix": SUFFIX}
),
)

# Callback for event
async def callback(result):
data = result.result
Expand Down
1 change: 0 additions & 1 deletion packages/opal-common/opal_common/logging/formatter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class Formatter:

MAX_FIELD_LEN = 25

def __init__(self, format_string: str):
Expand Down
4 changes: 2 additions & 2 deletions packages/opal-common/opal_common/monitoring/apm.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
from typing import Optional
from urllib.parse import urlparse
import os

from ddtrace import Span, patch, tracer, config
from ddtrace import Span, config, patch, tracer
from ddtrace.filters import TraceFilter
from loguru import logger

Expand Down
10 changes: 4 additions & 6 deletions packages/opal-server/opal_server/git_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ def verify_found_repo_matches_remote(
f"found target repo url is referred by remote: {remote.name}, url={remote.url}"
)
return
error: str = (
f"Repo mismatch! No remote matches target url: {expected_remote_url}, found urls: {[remote.url for remote in repo.remotes]}"
)
error: str = f"Repo mismatch! No remote matches target url: {expected_remote_url}, found urls: {[remote.url for remote in repo.remotes]}"
logger.error(error)
raise ValueError(error)

Expand Down Expand Up @@ -196,9 +194,9 @@ async def fetch_and_notify_on_changes(
logger.debug(
f"Fetching remote (force_fetch={force_fetch}): {self._remote} ({self._source.url})"
)
GitPolicyFetcher.repos_last_fetched[self.source_id] = (
datetime.datetime.now()
)
GitPolicyFetcher.repos_last_fetched[
self.source_id
] = datetime.datetime.now()
await run_sync(
repo.remotes[self._remote].fetch,
callbacks=self._auth_callbacks,
Expand Down
1 change: 0 additions & 1 deletion packages/opal-server/opal_server/policy/webhook/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def get_webhook_router(
dependencies=route_dependencies,
)
async def trigger_webhook(request: Request, git_changes: GitChanges = git_changes):

# TODO: breaking change: change "repo_url" to "remote_url" in next major
if source_type == PolicySourceTypes.Git:
# look at values extracted from request
Expand Down
2 changes: 1 addition & 1 deletion packages/opal-server/opal_server/scopes/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from fastapi.responses import RedirectResponse
from fastapi_websocket_pubsub import PubSubEndpoint
from git import InvalidGitRepositoryError
from opal_common.monitoring import metrics
from opal_common.async_utils import run_sync
from opal_common.authentication.authz import (
require_peer_type,
Expand All @@ -26,6 +25,7 @@
from opal_common.authentication.types import EncryptionKeyFormat, JWTClaims
from opal_common.authentication.verifier import Unauthorized
from opal_common.logger import logger
from opal_common.monitoring import metrics
from opal_common.schemas.data import (
DataSourceConfig,
DataUpdate,
Expand Down
8 changes: 4 additions & 4 deletions packages/opal-server/opal_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

from fastapi import Depends, FastAPI
from fastapi_websocket_pubsub.event_broadcaster import EventBroadcasterContextManager
from opal_common.monitoring import apm, metrics
from opal_common.authentication.deps import JWTAuthenticator, StaticBearerAuthenticator
from opal_common.authentication.signer import JWTSigner
from opal_common.confi.confi import load_conf_if_none
from opal_common.config import opal_common_config
from opal_common.logger import configure_logs, logger
from opal_common.middleware import configure_middleware
from opal_common.monitoring import apm, metrics
from opal_common.schemas.data import ServerDataSourceConfig
from opal_common.synchronization.named_lock import NamedLock
from opal_common.topics.publisher import (
Expand Down Expand Up @@ -168,9 +168,9 @@ def __init__(
# if stats are enabled, the server workers must be listening on the broadcast
# channel for their own synchronization, not just for their clients. therefore
# we need a "global" listening context
self.broadcast_listening_context: Optional[EventBroadcasterContextManager] = (
None
)
self.broadcast_listening_context: Optional[
EventBroadcasterContextManager
] = None
if self.broadcaster_uri is not None and opal_common_config.STATISTICS_ENABLED:
self.broadcast_listening_context = (
self.pubsub.endpoint.broadcaster.get_listening_context()
Expand Down

0 comments on commit adea0f5

Please sign in to comment.