Skip to content

Commit

Permalink
Add 3.9+ compatibility
Browse files Browse the repository at this point in the history
* Update test.yaml to include Python version matrix

* Add python 3.9 compatibility and tox tests

* Update PyPi workflow to use latest versions of actions
  • Loading branch information
ReinderVosDeWael authored Dec 13, 2023
1 parent a94270e commit 38317df
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 13 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ jobs:
name: "PyPi Release"
runs-on: "ubuntu-latest"

steps:
- uses: actions/checkout@v3
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}

- name: Set up Python 3.8.
uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: 3.8
python-version-file: pyproject.toml

- name: Skip if version did not change.
run: |
Expand All @@ -38,7 +36,7 @@ jobs:

- name: Build package.
run: |
python -m pip install poetry
pipx install poetry
poetry install --only main
poetry build
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ on:
jobs:
unit:
runs-on: ubuntu-latest
strategy:
matrix:
python_version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml
python-version: ${{ matrix.python_version }}
cache: poetry
- name: Install dependencies
run: |
Expand Down
101 changes: 99 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ readme = "README.md"
packages = [{include = "oai", from = "src"}]

[tool.poetry.dependencies]
python = ">3.9"
python = ">3.9, <4.0"
pydantic-settings = "^2.1.0"
pydantic = "^2.5.2"
ffmpeg-python = "^0.2.0"
Expand All @@ -24,6 +24,8 @@ ruff = "^0.1.7"
pytest-mock = "^3.12.0"
pytest-asyncio = "^0.23.2"
types-requests = "^2.31.0.10"
tox = "^4.11.4"
tox-poetry-installer = "1.0.0b1"

[tool.poetry.group.docs.dependencies]
pdoc = "^14.1.0"
Expand All @@ -39,6 +41,19 @@ pythonpath = [
[tool.poetry.scripts]
oai = 'oai.__main__:main'

[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py39, py310, py311, py312
[testenv]
allowlist_externals = poetry
deps = tox-poetry-installer
commands =
poetry install -v
pytest
"""

[tool.mypy]
ignore_missing_imports = true

Expand Down
2 changes: 2 additions & 0 deletions src/oai/cli/commands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Contains the core business logic of the OpenAI CLI."""
from __future__ import annotations

import asyncio
import logging
import pathlib
Expand Down
2 changes: 2 additions & 0 deletions src/oai/cli/parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Command line interface for the OpenAI API."""
from __future__ import annotations

import argparse
import pathlib
import sys
Expand Down
7 changes: 6 additions & 1 deletion src/oai/cli/utils.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
"""Contains the core business logic of the OpenAI CLI."""
from __future__ import annotations

import math
import pathlib
import uuid
from collections.abc import Generator
from typing import TYPE_CHECKING

import ffmpeg
import requests

from oai.core import config

if TYPE_CHECKING:
from collections.abc import Generator

logger = config.get_logger()


Expand Down
2 changes: 2 additions & 0 deletions src/oai/openai_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""This module contains interactions with OpenAI models."""
from __future__ import annotations

import abc
import logging
import pathlib
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
"""Tests for the parser module."""
from __future__ import annotations

import argparse
import pathlib
import sys
from typing import TYPE_CHECKING

import pytest
import pytest_mock

from oai.cli import parser
from oai.core import exceptions

if TYPE_CHECKING:
import pytest_mock


@pytest.mark.parametrize(
("value", "will_raise"),
Expand Down

0 comments on commit 38317df

Please sign in to comment.