diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 648beab..32e4a38 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,4 +20,3 @@ jobs: - name: Run tox run: tox - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e69de29..16fd4d1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -0,0 +1,41 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.5.2 + hooks: + - id: ruff +- repo: https://github.com/psf/black-pre-commit-mirror + rev: 24.4.2 + hooks: + - id: black +- repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.10.1 + hooks: + - id: mypy + args: [--check-untyped-defs] + additional_dependencies: + [ + # main dependencies + click, + datasets, + loguru, + numpy, + openai, + requests, + transformers, + + # dev dependencies + pytest, + + # types + types-click, + types-requests, + ] diff --git a/MANIFEST.in b/MANIFEST.in index cc0d116..1aba38f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -include LICENSE \ No newline at end of file +include LICENSE diff --git a/docs/README.md b/docs/README.md index 30404ce..e69de29 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1 +0,0 @@ -TODO \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 1333ed7..e69de29 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1 +0,0 @@ -TODO diff --git a/pyproject.toml b/pyproject.toml index 9d97c5d..0a48d13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,19 +36,19 @@ dependencies = [ [project.optional-dependencies] dev = [ - "guidellm[code_quality]", - "pre-commit", - "sphinx", -] -code_quality = [ - "black", - "isort", - "mypy", - "pytest", - "pytest-mock", - "ruff", - "tox", - "types-requests" + # general + "pre-commit~=3.5.0", + "sphinx~=7.1.2", + + # code quality + "black~=24.4.2", + "isort~=5.13.2", + "mypy~=1.10.1", + "pytest~=8.2.2", + "pytest-mock~=3.14.0", + "ruff~=0.5.2", + "tox~=4.16.0", + "types-requests~=2.32.0" ] diff --git a/src/guidellm/core/distribution.py b/src/guidellm/core/distribution.py index 6c02a46..39923a3 100644 --- a/src/guidellm/core/distribution.py +++ b/src/guidellm/core/distribution.py @@ -16,7 +16,7 @@ class Distribution: :type data: List[Union[int, float]], optional """ - def __init__(self, data: Optional[List[Union[int, float]]] = None): + def __init__(self, data: Optional[Union[List[int], List[float]]] = None): """ Initialize the Distribution with optional data. @@ -227,7 +227,7 @@ def describe(self) -> dict: logger.debug(f"Generated description: {description}") return description - def add_data(self, new_data: List[Union[int, float]]): + def add_data(self, new_data: Union[List[int], List[float]]): """ Add new data points to the distribution. @@ -237,7 +237,7 @@ def add_data(self, new_data: List[Union[int, float]]): self._data.extend(new_data) logger.debug(f"Added new data: {new_data}") - def remove_data(self, remove_data: List[Union[int, float]]): + def remove_data(self, remove_data: Union[List[int], List[float]]): """ Remove specified data points from the distribution. diff --git a/tests/conftest.py b/tests/conftest.py index c6630d3..488259f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -28,6 +28,6 @@ def inner_wrapper(*_, base_url: Optional[str] = None, **kwargs) -> OpenAIBackend defaults.update(kwargs) - return Backend.create(**defaults) + return Backend.create(**defaults) # type: ignore return inner_wrapper diff --git a/tests/dummy/data/openai.py b/tests/dummy/data/openai.py index 1e45d8a..0605e13 100644 --- a/tests/dummy/data/openai.py +++ b/tests/dummy/data/openai.py @@ -37,7 +37,7 @@ def openai_completion_factory( } payload.update(kwargs) - yield Completion(**payload) + yield Completion(**payload) # type: ignore def openai_model_factory(n: int = 3) -> Generator[Model, None, None]: diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 3f53aa4..ff78355 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -25,7 +25,7 @@ def openai_models_list_patch(mocker) -> List[openai.types.Model]: Mock available models function to avoid OpenAI API call. """ - items: list[openai.types.Model] = [ + items: List[openai.types.Model] = [ item for item in dummy.data.openai_model_factory() ] mocker.patch( diff --git a/tests/unit/request/test_base.py b/tests/unit/request/test_base.py index ae83497..16eb5da 100644 --- a/tests/unit/request/test_base.py +++ b/tests/unit/request/test_base.py @@ -74,7 +74,7 @@ def test_request_generator_repr(): @pytest.mark.regression def test_request_generator_iter_calls_create_item(): generator = TestRequestGenerator(mode="sync") - generator.create_item = Mock( + generator.create_item = Mock( # type: ignore return_value=TextGenerationRequest(prompt="Mock prompt") ) @@ -91,7 +91,7 @@ def test_request_generator_iter_calls_create_item(): @pytest.mark.regression def test_request_generator_async_iter_calls_create_item(): generator = TestRequestGenerator(mode="sync") - generator.create_item = Mock( + generator.create_item = Mock( # type: ignore return_value=TextGenerationRequest(prompt="Mock prompt") ) diff --git a/tox.ini b/tox.ini index 3f518b5..ab42ff3 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ env_list = py38,py39,py310,py311,py312 [testenv] deps = .[code_quality] -commands = +commands = python -m pytest tests/unit [testenv:lint]