Skip to content

Commit

Permalink
now compatible with python3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreFCruz committed Jun 6, 2024
1 parent 2faf491 commit ad41631
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand Down
10 changes: 8 additions & 2 deletions folktexts/qa_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,20 @@ def get_numeric_value(self) -> float:
return self.numeric_value if self.numeric_value is not None else float(self.data_value)


@dataclass(frozen=True, eq=True, kw_only=True)
@dataclass(frozen=True, eq=True) # NOTE: kw_only=True requires Python 3.10
class MultipleChoiceQA(QAInterface):
"""Represents a multiple-choice question and its answer keys."""

num_forward_passes: int = 1 # NOTE: overrides superclass default
choices: list[Choice]
choices: list[Choice] = dataclasses.field(default_factory=list)
_answer_keys_source: list[str] = _ALPHABET

def __post_init__(self):
if not self.choices:
raise ValueError("Choices must be provided.")
if len(self.choices) > len(self._answer_keys_source):
raise ValueError("Number of choices must be less than or equal to the number of answer keys.")

@classmethod
def create_question_from_value_map(
cls,
Expand Down
13 changes: 6 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ classifiers = [
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Natural Language :: English",
"Programming Language :: Python :: 3",
# "Programming Language :: Python :: 3.8", # TODO: add compatibility with py3.8
# "Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]

version = "0.0.4"
# requires-python = ">=3.8"
requires-python = ">=3.10"
version = "0.0.5"
requires-python = ">=3.8"
dynamic = [
"readme",
"dependencies",
Expand Down Expand Up @@ -105,8 +104,8 @@ exclude = ["build", "doc"]
legacy_tox_ini = """
[tox]
env_list =
# py38
# py39
py38
py39
py310
py311
py312
Expand Down

0 comments on commit ad41631

Please sign in to comment.