Skip to content

Commit d3951bd

Browse files
committed
fix: add ruff check to CI and fix all lint errors
- Add 'Lint with ruff' step to CI workflow (was only running format check) - Fix F401: Add explicit re-exports for public API types in __init__.py - Fix F811: Rename duplicate test_openai_reasoning_tokens to test_openai_reasoning_tokens_o4_mini - Fix E731: Convert lambda to def function in test_middleware.py - Fix unused imports in client.py and test files (auto-fixed) Without ruff check in CI, lint errors were accumulating on master undetected.
1 parent f719c3d commit d3951bd

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ jobs:
3333
run: |
3434
ruff format --check .
3535
36+
- name: Lint with ruff
37+
run: |
38+
ruff check .
39+
3640
- name: Check types with mypy
3741
run: |
3842
mypy --no-site-packages --config-file mypy.ini . | mypy-baseline filter

posthog/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@
1111
set_context_session as inner_set_context_session,
1212
identify_context as inner_identify_context,
1313
)
14-
from posthog.feature_flags import InconclusiveMatchError, RequiresServerEvaluation
15-
from posthog.types import FeatureFlag, FlagsAndPayloads, FeatureFlagResult
14+
from posthog.feature_flags import (
15+
InconclusiveMatchError as InconclusiveMatchError,
16+
RequiresServerEvaluation as RequiresServerEvaluation,
17+
)
18+
from posthog.types import (
19+
FeatureFlag,
20+
FlagsAndPayloads,
21+
FeatureFlagResult as FeatureFlagResult,
22+
)
1623
from posthog.version import VERSION
1724

1825
__version__ = VERSION

posthog/client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import sys
55
from datetime import datetime, timedelta
6-
from typing import Any, Callable, Dict, Optional, Union
6+
from typing import Any, Dict, Optional, Union
77
from typing_extensions import Unpack
88
from uuid import uuid4
99

@@ -60,7 +60,6 @@
6060
SizeLimitedDict,
6161
clean,
6262
guess_timezone,
63-
remove_trailing_slash,
6463
system_context,
6564
)
6665
from posthog.version import VERSION

posthog/test/ai/anthropic/test_anthropic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
from unittest.mock import patch
32

43
import pytest

posthog/test/ai/langchain/test_callbacks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,7 @@ def test_combined_reasoning_and_cache_tokens(mock_client):
17161716

17171717

17181718
@pytest.mark.skipif(not OPENAI_API_KEY, reason="OPENAI_API_KEY is not set")
1719-
def test_openai_reasoning_tokens(mock_client):
1719+
def test_openai_reasoning_tokens_o4_mini(mock_client):
17201720
model = ChatOpenAI(
17211721
api_key=OPENAI_API_KEY, model="o4-mini", max_completion_tokens=10
17221722
)

posthog/test/integrations/test_middleware.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ def test_sync_middleware_with_filter(self):
235235
get_response = Mock(return_value=mock_response)
236236

237237
# Create middleware with request filter that filters all requests
238-
request_filter = lambda req: False
238+
def request_filter(req):
239+
return False
240+
239241
middleware = PosthogContextMiddleware.__new__(PosthogContextMiddleware)
240242
middleware.get_response = get_response
241243
middleware._is_coroutine = False

0 commit comments

Comments
 (0)