Skip to content

Commit c08b414

Browse files
gruebelbeeme1mr
andauthored
chore: align unleash pyproject.toml to others (#341)
align unleash pyproject.toml to others Signed-off-by: gruebel <anton.gruebel@gmail.com> Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
1 parent 8239b83 commit c08b414

File tree

5 files changed

+44
-104
lines changed

5 files changed

+44
-104
lines changed

providers/openfeature-provider-unleash/pyproject.toml

Lines changed: 5 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ version = "0.1.1"
88
description = "OpenFeature provider for Unleash"
99
readme = "README.md"
1010
authors = [{ name = "OpenFeature", email = "openfeature-core@groups.io" }]
11-
license = { file = "LICENSE" }
11+
license = "Apache-2.0"
12+
license-files = ["LICENSE"]
1213
classifiers = [
13-
"License :: OSI Approved :: Apache Software License",
1414
"Programming Language :: Python",
1515
"Programming Language :: Python :: 3",
1616
]
@@ -24,7 +24,6 @@ requires-python = ">=3.9"
2424
[project.urls]
2525
Homepage = "https://github.com/open-feature/python-sdk-contrib"
2626

27-
2827
[dependency-groups]
2928
dev = [
3029
"coverage[toml]>=7.10.0,<8.0.0",
@@ -41,11 +40,6 @@ dev = [
4140
module-name = "openfeature"
4241
module-root = "src"
4342
namespace = true
44-
source-exclude = [
45-
# `openfeature-sdk` already includes the `py.typed` file,
46-
# but it is necessary for local type checking
47-
"openfeature/py.typed"
48-
]
4943

5044
[tool.coverage.run]
5145
omit = [
@@ -59,7 +53,9 @@ files = "src"
5953
python_version = "3.9" # should be identical to the minimum supported version
6054
namespace_packages = true
6155
explicit_package_bases = true
62-
local_partial_types = true
56+
local_partial_types = true # will become the new default from version 2
57+
allow_redefinition_new = true # will become the new default from version 2
58+
fixed_format_cache = true # new caching mechanism
6359
pretty = true
6460

6561
strict = true
@@ -70,68 +66,6 @@ markers = [
7066
"integration: marks tests as integration tests (deselect with '-m \"not integration\"')",
7167
]
7268

73-
[tool.ruff]
74-
target-version = "py39"
75-
exclude = [
76-
".git",
77-
".venv",
78-
"__pycache__",
79-
"venv",
80-
]
81-
82-
[tool.ruff.lint]
83-
select = [
84-
"A",
85-
"B",
86-
"C4",
87-
"C90",
88-
"E",
89-
"F",
90-
"FLY",
91-
"FURB",
92-
"I",
93-
"LOG",
94-
"N",
95-
"PERF",
96-
"PGH",
97-
"PLC",
98-
"PLR0913",
99-
"PLR0915",
100-
"RUF",
101-
"S",
102-
"SIM",
103-
"T10",
104-
"T20",
105-
"UP",
106-
"W",
107-
"YTT",
108-
]
109-
ignore = [
110-
"E501", # the formatter will handle any too long line
111-
]
112-
113-
[tool.ruff.lint.per-file-ignores]
114-
"**/tests/**/*" = [
115-
"S101", # Use of assert detected
116-
"S105", # Possible hardcoded password
117-
"S106", # Possible hardcoded password assigned to argument
118-
"S104", # Possible binding to all interfaces
119-
"T201", # print found
120-
"PERF203", # try-except within a loop incurs performance overhead
121-
"PLR0915", # Too many statements
122-
]
123-
124-
[tool.ruff.lint.isort]
125-
known-first-party = ["openfeature"]
126-
127-
[tool.ruff.lint.pylint]
128-
max-args = 6
129-
max-statements = 30
130-
131-
[tool.ruff.lint.pyupgrade]
132-
# Preserve types, even if a file imports `from __future__ import annotations`.
133-
keep-runtime-typing = true
134-
13569
[tool.poe.tasks]
13670
test = "pytest tests"
13771
test-cov = "coverage run -m pytest tests"

providers/openfeature-provider-unleash/tests/test_events.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""Tests for events functionality."""
2-
1+
# ruff: noqa: S106
32
import uuid
43
from unittest.mock import Mock, patch
54

@@ -16,7 +15,7 @@
1615
from openfeature.provider import ProviderStatus
1716

1817

19-
def test_events():
18+
def test_events(): # noqa: PLR0915
2019
"""Test that UnleashProvider supports event handling."""
2120
mock_client = Mock()
2221
mock_client.initialize_client.return_value = None

providers/openfeature-provider-unleash/tests/test_flag_evaluation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""Tests for flag evaluation functionality."""
2-
1+
# ruff: noqa: S106
32
from unittest.mock import ANY, Mock, patch
43

54
import pytest

providers/openfeature-provider-unleash/tests/test_integration.py

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Integration tests for Unleash provider using testcontainers."""
22

3+
import logging
34
import time
45
from datetime import datetime, timezone
56

@@ -15,8 +16,10 @@
1516

1617
# Configuration for the running Unleash instance (will be set by fixtures)
1718
UNLEASH_URL = None
18-
API_TOKEN = "default:development.unleash-insecure-api-token"
19-
ADMIN_TOKEN = "user:76672ac99726f8e48a1bbba16b7094a50d1eee3583d1e8457e12187a"
19+
API_TOKEN = "default:development.unleash-insecure-api-token" # noqa: S105
20+
ADMIN_TOKEN = "user:76672ac99726f8e48a1bbba16b7094a50d1eee3583d1e8457e12187a" # noqa: S105
21+
22+
logger = logging.getLogger("openfeature.contrib.tests")
2023

2124

2225
class UnleashContainer(DockerContainer):
@@ -33,7 +36,7 @@ def _configure(self):
3336
self.with_env("DATABASE_SSL_REJECT_UNAUTHORIZED", "false")
3437
self.with_env("LOG_LEVEL", "info")
3538
self.with_env("PORT", "4242")
36-
self.with_env("HOST", "0.0.0.0")
39+
self.with_env("HOST", "0.0.0.0") # noqa: S104
3740
self.with_env("ADMIN_AUTHENTICATION", "none")
3841
self.with_env("AUTH_ENABLE", "false")
3942
self.with_env("INIT_CLIENT_API_TOKENS", API_TOKEN)
@@ -66,9 +69,9 @@ def insert_admin_token(postgres_container):
6669
),
6770
)
6871
conn.commit()
69-
print("Admin token inserted successfully")
72+
logger.info("Admin token inserted successfully")
7073
except Exception as e:
71-
print(f"Error inserting admin token: {e}")
74+
logger.error(f"Error inserting admin token: {e}")
7275
conn.rollback()
7376
finally:
7477
conn.close()
@@ -126,13 +129,15 @@ def create_test_flags():
126129
timeout=10,
127130
)
128131
if response.status_code in [200, 201, 409]:
129-
print(f"Flag '{flag['name']}' created")
132+
logger.info(f"Flag '{flag['name']}' created")
130133
add_strategy_with_variants(flag["name"], headers)
131134
enable_flag(flag["name"], headers)
132135
else:
133-
print(f"Failed to create flag '{flag['name']}': {response.status_code}")
134-
except Exception as e:
135-
print(f"Error creating flag '{flag['name']}': {e}")
136+
logger.error(
137+
f"Failed to create flag '{flag['name']}': {response.status_code}"
138+
)
139+
except Exception as e: # noqa: PERF203
140+
logger.error(f"Error creating flag '{flag['name']}': {e}")
136141

137142

138143
def add_strategy_with_variants(flag_name: str, headers: dict):
@@ -225,9 +230,9 @@ def add_strategy_with_variants(flag_name: str, headers: dict):
225230
timeout=10,
226231
)
227232
if strategy_response.status_code in [200, 201]:
228-
print(f"Strategy with variants added to '{flag_name}'")
233+
logger.info(f"Strategy with variants added to '{flag_name}'")
229234
else:
230-
print(
235+
logger.error(
231236
f"Failed to add strategy to '{flag_name}': {strategy_response.status_code}"
232237
)
233238

@@ -241,11 +246,13 @@ def enable_flag(flag_name: str, headers: dict):
241246
timeout=10,
242247
)
243248
if enable_response.status_code in [200, 201]:
244-
print(f"Flag '{flag_name}' enabled in development environment")
249+
logger.info(f"Flag '{flag_name}' enabled in development environment")
245250
else:
246-
print(f"Failed to enable flag '{flag_name}': {enable_response.status_code}")
251+
logger.error(
252+
f"Failed to enable flag '{flag_name}': {enable_response.status_code}"
253+
)
247254
except Exception as e:
248-
print(f"Error enabling flag '{flag_name}': {e}")
255+
logger.error(f"Error enabling flag '{flag_name}': {e}")
249256

250257

251258
@pytest.fixture(scope="session")
@@ -254,13 +261,13 @@ def postgres_container():
254261
with PostgresContainer("postgres:15", driver=None) as postgres:
255262
postgres.start()
256263
postgres_url = postgres.get_connection_url()
257-
print(f"PostgreSQL started at: {postgres_url}")
264+
logger.info(f"PostgreSQL started at: {postgres_url}")
258265

259266
yield postgres
260267

261268

262269
@pytest.fixture(scope="session")
263-
def unleash_container(postgres_container):
270+
def unleash_container(postgres_container): # noqa: PLR0915
264271
"""Create and start Unleash container with PostgreSQL dependency."""
265272
global UNLEASH_URL
266273

@@ -278,12 +285,12 @@ def unleash_container(postgres_container):
278285
unleash = UnleashContainer(internal_url)
279286

280287
with unleash as container:
281-
print("Starting Unleash container...")
288+
logger.info("Starting Unleash container...")
282289
container.start()
283-
print("Unleash container started")
290+
logger.info("Unleash container started")
284291

285292
# Wait for health check to pass
286-
print("Waiting for Unleash container to be healthy...")
293+
logger.info("Waiting for Unleash container to be healthy...")
287294
max_wait_time = 60 # 1 minute max wait
288295
start_time = time.time()
289296

@@ -292,42 +299,42 @@ def unleash_container(postgres_container):
292299
try:
293300
exposed_port = container.get_exposed_port(4242)
294301
unleash_url = f"http://localhost:{exposed_port}"
295-
print(f"Trying health check at: {unleash_url}")
302+
logger.info(f"Trying health check at: {unleash_url}")
296303
except Exception as port_error:
297-
print(f"Port not ready yet: {port_error}")
304+
logger.error(f"Port not ready yet: {port_error}")
298305
time.sleep(2)
299306
continue
300307

301308
response = requests.get(f"{unleash_url}/health", timeout=5)
302309
if response.status_code == 200:
303-
print("Unleash container is healthy!")
310+
logger.info("Unleash container is healthy!")
304311
break
305312

306-
print(f"Health check failed, status: {response.status_code}")
313+
logger.error(f"Health check failed, status: {response.status_code}")
307314
time.sleep(2)
308315

309316
except Exception as e:
310-
print(f"Health check error: {e}")
317+
logger.error(f"Health check error: {e}")
311318
time.sleep(2)
312319
else:
313320
raise Exception("Unleash container did not become healthy within timeout")
314321

315322
# Get the exposed port and set global URL
316323
UNLEASH_URL = f"http://localhost:{container.get_exposed_port(4242)}"
317-
print(f"Unleash started at: {unleash_url}")
324+
logger.info(f"Unleash started at: {unleash_url}")
318325

319326
insert_admin_token(postgres_container)
320-
print("Admin token inserted into database")
327+
logger.info("Admin token inserted into database")
321328

322329
yield container, unleash_url
323330

324331

325332
@pytest.fixture(scope="session", autouse=True)
326333
def setup_test_flags(unleash_container):
327334
"""Setup test flags before running any tests."""
328-
print("Creating test flags in Unleash...")
335+
logger.info("Creating test flags in Unleash...")
329336
create_test_flags()
330-
print("Test flags setup completed")
337+
logger.info("Test flags setup completed")
331338

332339

333340
@pytest.fixture(scope="session")

providers/openfeature-provider-unleash/tests/test_provider.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# ruff: noqa: S106
12
import uuid
23
from unittest.mock import Mock, patch
34

0 commit comments

Comments
 (0)