Skip to content

Commit 3a1b8e4

Browse files
authored
fix: add ruff check to CI and fix all lint errors (#360)
- 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 f3e5d71 commit 3a1b8e4

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ jobs:
3636
run: |
3737
ruff format --check .
3838
39+
- name: Lint with ruff
40+
run: |
41+
ruff check .
42+
3943
- name: Check types with mypy
4044
run: |
4145
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
@@ -18,8 +18,15 @@
1818
DEFAULT_CODE_VARIABLES_IGNORE_PATTERNS,
1919
DEFAULT_CODE_VARIABLES_MASK_PATTERNS,
2020
)
21-
from posthog.feature_flags import InconclusiveMatchError, RequiresServerEvaluation
22-
from posthog.types import FeatureFlag, FlagsAndPayloads, FeatureFlagResult
21+
from posthog.feature_flags import (
22+
InconclusiveMatchError as InconclusiveMatchError,
23+
RequiresServerEvaluation as RequiresServerEvaluation,
24+
)
25+
from posthog.types import (
26+
FeatureFlag,
27+
FlagsAndPayloads,
28+
FeatureFlagResult as FeatureFlagResult,
29+
)
2330
from posthog.version import VERSION
2431

2532
__version__ = VERSION

posthog/exception_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ def _compile_patterns(patterns):
929929
for pattern in patterns:
930930
try:
931931
compiled.append(re.compile(pattern))
932-
except:
932+
except Exception:
933933
pass
934934
return compiled
935935

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
@@ -315,7 +315,9 @@ def test_sync_middleware_with_filter(self):
315315
get_response = Mock(return_value=mock_response)
316316

317317
# Create middleware with request filter that filters all requests
318-
request_filter = lambda req: False
318+
def request_filter(req):
319+
return False
320+
319321
middleware = PosthogContextMiddleware.__new__(PosthogContextMiddleware)
320322
middleware.get_response = get_response
321323
middleware._is_coroutine = False

0 commit comments

Comments
 (0)