Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix typechecking
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson committed Oct 28, 2022
1 parent 66157a4 commit e592162
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ exclude = (?x)
|tests/rest/media/v1/test_media_storage.py
|tests/server.py
|tests/server_notices/test_resource_limits_server_notices.py
|tests/test_metrics.py
|tests/test_state.py
|tests/test_terms_auth.py
|tests/util/caches/test_cached_call.py
Expand Down Expand Up @@ -106,6 +105,9 @@ disallow_untyped_defs = False
[mypy-tests.handlers.test_user_directory]
disallow_untyped_defs = True

[mypy-tests.metrics.test_background_process_metrics]
disallow_untyped_defs = True

[mypy-tests.push.test_bulk_push_rule_evaluator]
disallow_untyped_defs = True

Expand Down
10 changes: 8 additions & 2 deletions tests/metrics/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Protocol

try:
from importlib import metadata
except ImportError:
Expand Down Expand Up @@ -52,7 +54,11 @@ def get_sample_labels_value(sample):

class TestMauLimit(unittest.TestCase):
def test_basic(self):
gauge = InFlightGauge(
class MetricEntry(Protocol):
foo: int
bar: int

gauge: InFlightGauge[MetricEntry] = InFlightGauge(
"test1", "", labels=["test_label"], sub_metrics=["foo", "bar"]
)

Expand Down Expand Up @@ -146,7 +152,7 @@ def test_cache_metric(self):
Caches produce metrics reflecting their state when scraped.
"""
CACHE_NAME = "cache_metrics_test_fgjkbdfg"
cache = DeferredCache(CACHE_NAME, max_entries=777)
cache: DeferredCache[str, str] = DeferredCache(CACHE_NAME, max_entries=777)

items = {
x.split(b"{")[0].decode("ascii"): x.split(b" ")[1].decode("ascii")
Expand Down

0 comments on commit e592162

Please sign in to comment.