Skip to content

Commit

Permalink
Satisfy mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed Oct 16, 2023
1 parent 6bbfbb6 commit 23c4dc7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions posthog/test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import uuid
from contextlib import contextmanager
from functools import wraps
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
from typing import Any, Dict, List, Optional, Tuple, Union
from unittest.mock import patch

import freezegun
Expand Down Expand Up @@ -134,7 +134,7 @@ def validation_error_response(
return {"type": "validation_error", "code": code, "detail": message, "attr": attr}


class TestMixin(TestCase if TYPE_CHECKING else object):
class TestMixin:
CONFIG_ORGANIZATION_NAME: str = "Test"
CONFIG_EMAIL: Optional[str] = "[email protected]"
CONFIG_PASSWORD: Optional[str] = "testpassword12345"
Expand Down Expand Up @@ -195,7 +195,7 @@ def validate_basic_html(self, html_message, site_url, preheader=None):
self.assertIn(preheader, html_message) # type: ignore


class MemoryLeakTestMixin(TestCase if TYPE_CHECKING else object):
class MemoryLeakTestMixin:
MEMORY_INCREASE_PER_PARSE_LIMIT_B: int
"""Parsing more than once can never increase memory by this much (on average)"""
MEMORY_INCREASE_INCREMENTAL_FACTOR_LIMIT: float
Expand All @@ -218,12 +218,12 @@ def _callTestMethod(self, method):
avg_memory_increase_factor = (
avg_memory_test_increase_b / avg_memory_priming_increase_b if avg_memory_priming_increase_b else 0
)
self.assertLessEqual(
self.assertLessEqual( # type: ignore
avg_memory_test_increase_b,
self.MEMORY_INCREASE_PER_PARSE_LIMIT_B,
f"Possible memory leak - exceeded {self.MEMORY_INCREASE_PER_PARSE_LIMIT_B}-byte limit of incremental memory per parse",
)
self.assertLessEqual(
self.assertLessEqual( # type: ignore
avg_memory_increase_factor,
self.MEMORY_INCREASE_INCREMENTAL_FACTOR_LIMIT,
f"Possible memory leak - exceeded {self.MEMORY_INCREASE_INCREMENTAL_FACTOR_LIMIT*100:.2f}% limit of incremental memory per parse",
Expand Down

0 comments on commit 23c4dc7

Please sign in to comment.