Skip to content

Commit fa97a77

Browse files
authored
Enable check_untyped_defs for mypy (stanford-crfm#1851)
1 parent ae0b179 commit fa97a77

36 files changed

+37
-4
lines changed

scripts/data_overlap/test/test_compute_data_overlap_metrics.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
from typing import List, DefaultDict, Set
23

34
from collections import defaultdict

scripts/fact_completion/create_benchmark.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
"""
23
This script samples triples to use and constructs sentences from templates.
34

setup.cfg

+1-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ ignore = E203,E231,E731,W503,W605
174174
# Settings for Mypy: static type checker for Python 3
175175
[mypy]
176176
ignore_missing_imports = True
177-
# TODO(#1831): Change this to True
178-
check_untyped_defs = False
177+
check_untyped_defs = True
179178
# TODO(#1831): Change this to True
180179
disallow_untyped_defs = False
181180

src/helm/benchmark/adaptation/adapters/test_generation_adapter.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
from typing import List
23

34
from helm.benchmark.scenarios.scenario import CORRECT_TAG, create_scenario, Instance, Reference, Input, Output

src/helm/benchmark/adaptation/adapters/test_language_modeling_adapter.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
from typing import List
23

34
from helm.common.tokenization_request import TokenizationToken

src/helm/benchmark/adaptation/adapters/test_multiple_choice_joint_adapter.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
from helm.benchmark.scenarios.scenario import Instance, Input, Output, Reference, CORRECT_TAG
23
from helm.benchmark.adaptation.adapter_spec import AdapterSpec
34
from .adapter_factory import AdapterFactory, ADAPT_MULTIPLE_CHOICE_JOINT

src/helm/benchmark/augmentations/contraction_expansion_perturbation.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
from typing import Dict
23
import re
34

src/helm/benchmark/augmentations/test_perturbation.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
from typing import List
23

34
from helm.benchmark.scenarios.scenario import Input, Instance, Output, Reference

src/helm/benchmark/metrics/disinformation_metrics.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
"""Diversity metrics for the disinformation scenario."""
23

34
import json

src/helm/benchmark/metrics/summac/model_summac.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
###############################################
23
# Source: https://github.com/tingofurro/summac
34
###############################################

src/helm/benchmark/metrics/test_bias_metrics.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
from dataclasses import dataclass
23
from typing import Callable, List, Optional
34

src/helm/benchmark/metrics/tokens/test_openai_token_cost_estimator.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
from unittest.mock import MagicMock
23

34
from transformers import GPT2TokenizerFast

src/helm/benchmark/presentation/create_plots.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
import argparse
23
from collections import defaultdict
34
from dataclasses import dataclass

src/helm/benchmark/presentation/summarize.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
"""Reads the output of the benchmark runs and produces:
23
- JSON files for the frontend
34
- Tables for the paper
@@ -827,7 +828,7 @@ def create_group_table(
827828
header_name += " (" + perturbation_field.get_short_display_name() + ")"
828829
description += (
829830
"\n- Perturbation "
830-
+ perturbation_field.display_name
831+
+ (perturbation_field.display_name or perturbation_field.name)
831832
+ ": "
832833
+ (perturbation_field.description or "???")
833834
)

src/helm/benchmark/presentation/test_create_plots.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
from helm.common.general import asdict_without_nones
23
from helm.benchmark.presentation.table import Table, Cell, HeaderCell
34
from helm.benchmark.presentation.create_plots import parse_table

src/helm/benchmark/run_expander.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
from abc import ABC, abstractmethod
23
from dataclasses import replace
34
from typing import Any, List, Dict, Optional, Tuple, Type

src/helm/benchmark/scenarios/code_scenario_helper.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
"""Code formatting helper functions for the code scenario.
23
34
Sourced from https://github.com/hendrycks/apps

src/helm/benchmark/scenarios/legal_summarization_scenario.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
from pathlib import Path
23

34
from typing import List, Optional, Any

src/helm/benchmark/scenarios/lsat_qa_scenario.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
import os
23
import json
34
from typing import List

src/helm/benchmark/scenarios/msmarco_scenario.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
import csv
23
import os
34
import random

src/helm/benchmark/scenarios/numeracy_scenario.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
# flake8: noqa
23
from collections import defaultdict
34
from dataclasses import dataclass, field

src/helm/benchmark/scenarios/the_pile_scenario.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
import os
23
import json
34
import csv

src/helm/benchmark/server.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
"""
23
Starts a local HTTP server to display benchmarking assets.
34
"""

src/helm/benchmark/test_data_preprocessor.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
from typing import List
23

34
from helm.benchmark.augmentations.data_augmenter import DataAugmenterSpec

src/helm/benchmark/window_services/test_cohere_window_service.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
import os
23
import shutil
34
import tempfile

src/helm/common/cache.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
from abc import abstractmethod
23
import contextlib
34
from dataclasses import dataclass

src/helm/proxy/clients/openai_client.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
from dataclasses import replace, asdict
23
from typing import Any, Dict, List, Optional, cast
34

src/helm/proxy/clients/palmyra_client.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
import json
23
import requests
34
from typing import Any, Dict, List

src/helm/proxy/clients/perspective_api_client.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
import threading
23
from dataclasses import asdict
34
from typing import List, Dict, Optional

src/helm/proxy/clients/test_anthropic_client.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
import os
23
import tempfile
34
from typing import List

src/helm/proxy/clients/test_huggingface_client.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
import os
23
import pytest
34
import tempfile

src/helm/proxy/clients/test_ice_tokenizer_client.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
import os
23
import tempfile
34
from typing import List

src/helm/proxy/clients/test_yalm_tokenizer_client.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
import os
23
import tempfile
34
from typing import List

src/helm/proxy/clients/yalm_tokenizer/yalm_tokenizer.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
import importlib_resources as resources
23
import torch
34
import sentencepiece as spm

src/helm/proxy/server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
# mypy: check_untyped_defs = False
22

33
"""
44
Starts a REST server for the frontend to interact with.

src/helm/proxy/services/test_remote_service.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: check_untyped_defs = False
12
import os
23
import random
34
import shutil

0 commit comments

Comments
 (0)