Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Lint

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
lint:
name: Lint and format check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.14"

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Run ruff linter
run: uvx ruff check .

- name: Run ruff formatter check
run: uvx ruff format --check .

- name: Validate pyproject.toml
run: |
uv tool install validate-pyproject
uvx validate-pyproject pyproject.toml

- name: Validate changelog fragments
run: |
set -euo pipefail
if ! uv run --group dev scriv print; then
status=$?
if [ "$status" -eq 2 ]; then
echo "::notice::No changelog fragments to collect"
exit 0
fi
exit "$status"
fi
33 changes: 33 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Tests

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
tests:
name: Run tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install dependencies
run: uv sync --group dev

- name: Run pytest
run: uv run --group dev pytest -m "not real"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
README_tools_template.md

*.swp
worktrees/
27 changes: 27 additions & 0 deletions changelog.d/templates/fragment.md.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# A new scriv changelog fragment.
#
# Uncomment the section that is right for this fragment:
#
# Added
# -----
# * New feature or functionality
#
# Changed
# -------
# * Changes to existing functionality
#
# Deprecated
# ----------
# * Features that will be removed in future releases
#
# Removed
# -------
# * Features that have been removed
#
# Fixed
# -----
# * Bug fixes
#
# Security
# --------
# * Security-related changes
92 changes: 92 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
[build-system]
requires = ["uv_build>=0.9.18,<0.10.0"]
build-backend = "uv_build"

[project]
name = "LMtoolbox"
version = "0.5.19"
description = "A collection of CLI tools leveraging language models"
readme = "README.md"
requires-python = ">=3.10"
license = "Apache-2.0"
authors = [{ name = "Sébastien De Revière" }]
dependencies = [
"PyYAML",
"click",
"lmterminal==0.0.43",
"openai<1.0",
"requests",
"rich",
"shellgenius==0.1.16",
"strip-tags",
"tiktoken",
"validators",
"vocabmaster==0.2.0",
"youtube-transcript-api==0.6.2",
]

[project.urls]
Documentation = "https://github.com/sderev/lmtoolbox"
Issues = "http://github.com/sderev/lmtoolbox/issues"
Changelog = "https://github.com/sderev/lmtoolbox/releases"

[project.scripts]
cheermeup = "lmtoolbox.cli:cheermeup"
codereview = "lmtoolbox.cli:codereview"
commitgen = "lmtoolbox.cli:commitgen"
critique = "lmtoolbox.cli:critique"
define = "lmtoolbox.cli:define"
explain = "lmtoolbox.cli:explain"
lessonize = "lmtoolbox.cli:lessonize"
life = "lmtoolbox.cli:life"
lmtoolbox = "lmtoolbox.cli:cli"
lmt = "lmterminal.cli:lmt"
pathlearner = "lmtoolbox.cli:pathlearner"
proofread = "lmtoolbox.cli:proofread"
shellgenius = "shellgenius.cli:shellgenius"
study = "lmtoolbox.cli:study"
summarize = "lmtoolbox.cli:summarize"
teachlib = "lmtoolbox.cli:teachlib"
thesaurus = "lmtoolbox.cli:thesaurus"
translate = "lmtoolbox.cli:translate"
vocabmaster = "vocabmaster.cli:vocabmaster"

[dependency-groups]
dev = [
"pytest",
"pytest-cov",
"scriv[toml]>=1.5.0",
]

[tool.ruff]
line-length = 100
lint.extend-select = ["I001"]

[tool.pytest.ini_options]
addopts = "-ra"
testpaths = ["tests"]
markers = [
"real: marks tests that use real API calls",
"mock: marks tests that use mocked API calls",
]

[tool.scriv]
version = "literal: pyproject.toml: project.version"
format = "md"
md_header_level = 2
output_file = "CHANGELOG.md"
fragment_directory = "changelog.d"
new_fragment_template = "file: changelog.d/templates/fragment.md.j2"
categories = [
"Added",
"Changed",
"Deprecated",
"Removed",
"Fixed",
"Security",
]
entry_title_template = "{{ version }} - {{ date.strftime('%Y-%m-%d') }}"

[tool.uv.build-backend]
module-root = ""
module-name = "lmtoolbox"
4 changes: 0 additions & 4 deletions pytest.ini

This file was deleted.

10 changes: 0 additions & 10 deletions requirements-dev.txt

This file was deleted.

11 changes: 0 additions & 11 deletions requirements.txt

This file was deleted.

65 changes: 0 additions & 65 deletions setup.py

This file was deleted.

12 changes: 3 additions & 9 deletions tests/video_summarization_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ def assert_transcript_disabled(capsys, excinfo):


@pytest.mark.real
def test_youtube_transcript_disabled_real(
youtube_video_url_with_transcripts_disabled, capsys
):
def test_youtube_transcript_disabled_real(youtube_video_url_with_transcripts_disabled, capsys):
"""
Test the `get_transcript()` function when the YouTube video has transcripts disabled.

Expand Down Expand Up @@ -182,9 +180,7 @@ def test_youtube_transcript_for_requested_language_not_found_real(
This test uses the real `youtube_transcript_api` package.
Therefore, this test takes more time to run.
"""
transcript = get_transcript(
youtube_video_url_with_no_transcripts_for_english, languages=["en"]
)
transcript = get_transcript(youtube_video_url_with_no_transcripts_for_english, languages=["en"])
assert_transcript_for_requested_language_not_found(transcript, capsys)


Expand Down Expand Up @@ -225,9 +221,7 @@ def __iter__(self):
mock_list_transcripts,
)

transcript = get_transcript(
youtube_video_url_with_no_transcripts_for_english, languages=["en"]
)
transcript = get_transcript(youtube_video_url_with_no_transcripts_for_english, languages=["en"])
assert_transcript_for_requested_language_not_found(transcript, capsys)


Expand Down
13 changes: 10 additions & 3 deletions update_requirements.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/python3

import json
import sys
import urllib.error
import urllib.request
from pathlib import Path


def get_latest_version(package_name):
Expand All @@ -17,9 +19,7 @@ def get_latest_version(package_name):
decoded_data = data.decode("utf-8")
return json.loads(decoded_data)["info"]["version"]
else:
print(
f"Error fetching version for {package_name}: HTTP {response.status}"
)
print(f"Error fetching version for {package_name}: HTTP {response.status}")
return None
except urllib.error.HTTPError as error:
print(f"Error fetching version for {package_name}: {error}")
Expand All @@ -36,6 +36,13 @@ def update_requirements(packages_to_update, requirements_path="requirements.txt"
"""
Updates the requirements.txt with the latest versions of the specified packages.
"""
if not Path(requirements_path).exists():
print(
"requirements.txt has been removed. Use `uv add -U <package>` to update "
"dependencies in pyproject.toml.",
file=sys.stderr,
)
sys.exit(1)
with open(requirements_path, "r", encoding="UTF-8") as file:
lines = file.readlines()

Expand Down
Loading