Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3.12 #1

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
15 changes: 9 additions & 6 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
name: Python Lints / Checks

on:
pull_request:
push:
branches:
- main

jobs:
mypy_lint:
name: Lint with Mypy
name: Lint with Mypy and Ruff
runs-on: ubuntu-latest
container:
image: python:3.11-bookworm
image: python:3.12-bookworm
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: prepare environment
run: |
apt-get update
apt-get install cmake -y
pip install pipenv -U --quiet
pipenv install --dev

Expand All @@ -29,17 +32,17 @@ jobs:
name: Test with pytest
runs-on: ubuntu-latest
container:
image: python:3.11-bookworm
image: python:3.12-bookworm
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: prepare environment
run: |
apt-get update
apt-get install ffmpeg cmake -y
pip install pipenv -U --quiet
pipenv install --dev
apt-get update
apt-get install ffmpeg -y

- name: run tests
run: |
Expand All @@ -58,7 +61,7 @@ jobs:
- name: prepare environment
run: |
sudo apt-get update
sudo apt-get install python3.11 --install-recommends ffmpeg -y
sudo apt-get install python3.12 --install-recommends ffmpeg -y
pip install pipenv -U --quiet
pipenv install --dev
- name: run coverage report
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
__pycache__
.mypy_cache
Pipfile.lock
model/
/src/tmp/
/data/
Expand All @@ -9,3 +8,4 @@ model/
/.coverage
/coverage.xml
/config.ini
/config.yaml
5 changes: 2 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ stages: # List of stages for jobs, and their order of execution
python-lint-job:
stage: python_checks
allow_failure: false
image: python:3.11-bookworm
image: python:3.12-bookworm
script:
- pip install pipenv -U --quiet
- pipenv install --dev
Expand All @@ -16,7 +16,7 @@ python-lint-job:
python-test-job:
stage: python_checks
allow_failure: false
image: python:3.11-bookworm
image: python:3.12-bookworm
script:
- pip install pipenv -U --quiet
- pipenv install --dev
Expand All @@ -42,7 +42,6 @@ sonarqube-check:
script:
- pip install pipenv -U --quiet
- pipenv install --dev
# TODO:check if this is even debian / ubuntu or alpine and install ffprobe
- sudo apt-get update
- sudo apt-get install ffmpeg -y
- pipenv run coverage
Expand Down
11 changes: 7 additions & 4 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"


[packages]
python-ffmpeg = "*"
torchaudio = "*"
speechbrain = "*"
torchvision = "*"
torch = "*"
speechbrain = "*"
python-ffmpeg = "*"
pynvml = "*"
humanize = "*"
enlighten = "*"
Expand All @@ -32,7 +35,7 @@ chardet = "*"
[scripts]
check = "python src/entry.py"
lint = "bash -c 'pipenv run mypy && pipenv run ruff'"
mypy = "mypy src/ tests/ ffmpeg/ --strict --ignore-missing-imports --enable-incomplete-feature=Unpack "
mypy = "mypy src/ tests/ ffmpeg/ --strict --ignore-missing-imports"
ruff = "ruff check src/ tests/ ffmpeg/"
ruff-ci = "ruff check src/ tests/ ffmpeg/ --format=github"
ruff-fix = "ruff check src/ tests/ ffmpeg/ --fix"
Expand All @@ -43,4 +46,4 @@ extract_translation = "pygettext3 -d video_language_detect -o locales/video_lang
generate_translation = "bash -c 'for PO_FILE in locales/*/LC_MESSAGES/*.po; do MO_FILE=\"${PO_FILE/.po/.mo}\"; msgfmt -o \"$MO_FILE\" \"$PO_FILE\"; done'"

[requires]
python_version = "3.11"
python_version = "3.12"
1,478 changes: 1,478 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ ignore = [
"UP007", # UP007 => non-pep604-annotation (Union[a,b] => a|b is fine, but i like Optional[a] better then a|None)
"ANN401", # ANN401 => any-type
"D", # pydocstyle => I don't use doc strings atm.
"C90", # mccabe => complexity isn't of concern tam.
"C90", # mccabe => complexity isn't of concern atm.
"FIX", # todo activate
"TD", # todo activate,
]

# 88 (standard) is to small
line-length = 100

# Target Python version is 3.11.
target-version = "py311"
# Target Python version is 3.12.
target-version = "py312"

per-file-ignores = { "__init__.py" = [
"E402", # Ignore `E402` (import violations) in all `__init__.py` files
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sonar.projectKey=Video-Language-Detection
sonar.qualitygate.wait=true
sonar.python.version=3.11
sonar.python.version=3.12
sonar.sources=src/
sonar.dependencyCheck.jsonReportPath=/github/workspace/reports/dependency-check-report.json
sonar.dependencyCheck.htmlReportPath=/github/workspace/reports/dependency-check-report.html
Expand Down
14 changes: 2 additions & 12 deletions src/content/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
from pathlib import Path
from typing import (
Any,
Generic,
Optional,
Self,
TypedDict,
TypeVar,
cast,
)

Expand Down Expand Up @@ -432,12 +430,7 @@ def parse_series_name(self: Self, _name: str) -> Optional[tuple[str, int]]:
raise MissingOverrideError


C = TypeVar("C")
CT = TypeVar("CT")
RT = TypeVar("RT")


class Callback(Generic[C, CT, RT]):
class Callback[C, CT, RT]:
def __init__(self: Self) -> None:
pass

Expand Down Expand Up @@ -491,10 +484,7 @@ def get_saved(self: Self) -> RT:
raise MissingOverrideError


SF = TypeVar("SF")


def safe_index(ls: list[SF], item: SF) -> Optional[int]:
def safe_index[SF](ls: list[SF], item: SF) -> Optional[int]:
try:
return ls.index(item)
except ValueError:
Expand Down
Loading