Skip to content

Commit 25c4e99

Browse files
authored
Conform to the newer Ruff rules, and use the LocalStack defaults (#163)
1 parent 9f20206 commit 25c4e99

20 files changed

Lines changed: 99 additions & 70 deletions

File tree

‎.github/workflows/wiremock.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
docker pull "$IMAGE_NAME"
5252
docker pull wiremock/wiremock
5353
docker pull public.ecr.aws/lambda/python:3.12
54-
pip install localstack terraform-local awscli-local[ver1]
54+
pip install localstack terraform-local awscli-local
5555
5656
make install
5757
make lint

‎keycloak/localstack_keycloak/extension.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
from localstack_extensions.utils.docker import ProxiedDockerContainerExtension
1010

1111
from .utils import (
12+
DEFAULT_AUDIENCE,
1213
DEFAULT_CLIENT_SECRET,
14+
DEFAULT_REALM,
15+
DEFAULT_VERSION,
1316
ENV_KEYCLOAK_DEFAULT_PASSWORD,
1417
ENV_KEYCLOAK_DEFAULT_USER,
1518
ENV_KEYCLOAK_FLAGS,
@@ -19,9 +22,6 @@
1922
ENV_KEYCLOAK_VERSION,
2023
KEYCLOAK_HTTP_PORT,
2124
KEYCLOAK_MGMT_PORT,
22-
DEFAULT_AUDIENCE,
23-
DEFAULT_REALM,
24-
DEFAULT_VERSION,
2525
get_default_client_config,
2626
get_default_realm_config,
2727
get_env,

‎keycloak/sample-app/cdk/stacks/api_stack.py‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1+
import os
2+
13
from aws_cdk import (
2-
Stack,
34
Duration,
4-
aws_lambda as lambda_,
5+
RemovalPolicy,
6+
Stack,
7+
)
8+
from aws_cdk import (
59
aws_apigateway as apigw,
10+
)
11+
from aws_cdk import (
612
aws_dynamodb as dynamodb,
7-
aws_iam as iam,
8-
RemovalPolicy,
13+
)
14+
from aws_cdk import (
15+
aws_lambda as lambda_,
916
)
1017
from constructs import Construct
11-
import os
1218

1319

1420
class KeycloakSampleApiStack(Stack):

‎keycloak/sample-app/lambda/authorizer/handler.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
"""
1111

1212
import base64
13-
import hashlib
14-
import hmac
1513
import json
1614
import os
1715
import urllib.request

‎keycloak/tests/test_extension.py‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import json
21
import base64
2+
import json
33
import time
4+
5+
import boto3
46
import pytest
57
import requests
6-
import boto3
78
from botocore.config import Config
89

9-
1010
LOCALSTACK_URL = "http://localhost:4566"
1111
KEYCLOAK_URL = "http://keycloak.localhost.localstack.cloud:4566"
1212
KEYCLOAK_DIRECT_URL = "http://localhost:8080" # Direct access to Keycloak HTTP port
@@ -189,7 +189,7 @@ class TestUserManagement:
189189

190190
def test_create_user_with_required_profile_fields(self, admin_token):
191191
"""Verify user creation works with required Keycloak 26+ profile fields.
192-
192+
193193
Keycloak 26+ requires email, firstName, lastName for users to be "fully set up".
194194
Password must be set separately via reset-password endpoint.
195195
"""
@@ -302,7 +302,10 @@ def test_incomplete_user_fails_password_grant(self, admin_token):
302302
timeout=30,
303303
)
304304
assert token_response.status_code != 200
305-
assert "not fully set up" in token_response.json().get("error_description", "").lower()
305+
assert (
306+
"not fully set up"
307+
in token_response.json().get("error_description", "").lower()
308+
)
306309

307310
# Cleanup
308311
requests.delete(f"{users_url}/{user_id}", headers=headers, timeout=10)

‎paradedb/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ conn = psycopg2.connect(
3131
port=5432,
3232
database="mydatabase",
3333
user="myuser",
34-
password="mypassword"
34+
password="mypassword",
3535
)
3636
```
3737

‎paradedb/localstack_paradedb/extension.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import os
22
import socket
33

4-
from localstack_extensions.utils.docker import ProxiedDockerContainerExtension
54
from localstack import config
5+
from localstack_extensions.utils.docker import ProxiedDockerContainerExtension
66

77
# Environment variables for configuration
88
ENV_POSTGRES_USER = "PARADEDB_POSTGRES_USER"
@@ -88,7 +88,7 @@ def _check_tcp_port(self, host: str, port: int, timeout: float = 2.0) -> None:
8888
try:
8989
sock.connect((host, port))
9090
sock.close()
91-
except (socket.timeout, socket.error) as e:
91+
except (TimeoutError, OSError) as e:
9292
raise AssertionError(f"Port {port} not ready: {e}")
9393

9494
def get_connection_info(self) -> dict:

‎paradedb/tests/test_extension.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from localstack.utils.strings import short_uid
44
from localstack.utils.sync import retry
55

6-
76
# Connection details for ParadeDB
87
# Connect through LocalStack gateway with TCP proxying
98
HOST = "paradedb.localhost.localstack.cloud"
@@ -15,6 +14,7 @@
1514

1615
def get_connection():
1716
"""Create a connection to ParadeDB, retrying until the server is ready."""
17+
1818
def _connect():
1919
return psycopg2.connect(
2020
host=HOST,
@@ -23,6 +23,7 @@ def _connect():
2323
password=PASSWORD,
2424
database=DATABASE,
2525
)
26+
2627
return retry(_connect, retries=15, sleep=2.0)
2728

2829

‎ruff.toml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[lint]
2+
ignore = [
3+
"B006", # TODO Do not use mutable data structures for argument defaults
4+
"B007", # TODO Loop control variable x not used within loop body
5+
"B017", # TODO `pytest.raises(Exception)` should be considered evil
6+
"B019", # TODO Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
7+
"B023", # TODO Function definition does not bind loop variable `server`
8+
"B024", # TODO x is an abstract base class, but it has no abstract methods
9+
"B026", # TODO Star-arg unpacking after a keyword argument is strongly discouraged
10+
"B027", # TODO `Server.do_shutdown` is an empty method in an abstract base class, but has no abstract decorator
11+
"B904", # TODO Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
12+
"C901", # TODO function is too complex
13+
"E402", # TODO Module level import not at top of file
14+
"E501", # E501 Line too long - handled by black, see https://docs.astral.sh/ruff/faq/#is-ruff-compatible-with-black
15+
"E741", # TODO Ambiguous variable name: `l`
16+
"T201", # TODO `print` found
17+
]
18+
select = ["B", "C", "E", "F", "I", "W", "T", "B9", "G", "UP", "TID251"]

‎typedb/tests/test_extension.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
import requests
21
import httpx
2+
import requests
33
from localstack.utils.strings import short_uid
4-
from typedb.driver import TypeDB, Credentials, DriverOptions, TransactionType, DriverTlsConfig
4+
from typedb.driver import (
5+
Credentials,
6+
DriverOptions,
7+
DriverTlsConfig,
8+
TransactionType,
9+
TypeDB,
10+
)
511

612

713
def test_connect_to_db_via_http_api():

0 commit comments

Comments
 (0)