From c85201ba95f35c56e856eab33080771ddaa28c90 Mon Sep 17 00:00:00 2001 From: Hussain Jafari Date: Fri, 10 Jan 2025 10:27:31 -0800 Subject: [PATCH] randomness conftest typing (#569) randomness conftest typing --- CHANGELOG.rst | 3 ++- pyproject.toml | 1 - tests/framework/randomness/conftest.py | 18 +++++++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 526cc17fd..63822ba75 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,6 @@ -**3.2.14 - TBD/TBD/25** +**3.2.14 - 01/10/25** + - Type-hinting: Fix mypy errors in tests/framework/randomness/conftest.py - Type-hinting: Fix mypy errors in tests/conftest.py **3.2.13 - 12/27/24** diff --git a/pyproject.toml b/pyproject.toml index df1c58863..cbc20c0c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,6 @@ exclude = [ 'tests/framework/lookup/test_lookup.py', 'tests/framework/population/test_manager.py', 'tests/framework/population/test_population_view.py', - 'tests/framework/randomness/conftest.py', 'tests/framework/randomness/test_crn.py', 'tests/framework/randomness/test_index_map.py', 'tests/framework/randomness/test_manager.py', diff --git a/tests/framework/randomness/conftest.py b/tests/framework/randomness/conftest.py index 010ccc6df..4a6f89708 100644 --- a/tests/framework/randomness/conftest.py +++ b/tests/framework/randomness/conftest.py @@ -1,3 +1,7 @@ +from __future__ import annotations + +from typing import Any + import pandas as pd import pytest @@ -5,19 +9,19 @@ @pytest.fixture(params=[10**4, 10**5]) -def index(request): +def index(request: pytest.FixtureRequest) -> pd.Index[int] | None: return pd.Index(range(request.param)) if request.param else None @pytest.fixture(params=[["a", "small", "bird"]]) -def choices(request): - return request.param +def choices(request: pytest.FixtureRequest) -> list[str]: + return request.param # type: ignore [no-any-return] # TODO: Add 2-d weights to the tests. @pytest.fixture(params=[None, [10, 10, 10], [0.5, 0.1, 0.4]]) -def weights(request): - return request.param +def weights(request: pytest.FixtureRequest) -> None | list[int | float]: + return request.param # type: ignore [no-any-return] @pytest.fixture( @@ -27,5 +31,5 @@ def weights(request): (0.1, RESIDUAL_CHOICE, RESIDUAL_CHOICE), ] ) -def weights_with_residuals(request): - return request.param +def weights_with_residuals(request: pytest.FixtureRequest) -> tuple[Any]: + return request.param # type: ignore [no-any-return]