Skip to content

Commit

Permalink
Format/lint with ruff, check types with mypy, add py.typed
Browse files Browse the repository at this point in the history
  • Loading branch information
7x11x13 committed Jul 3, 2024
1 parent 18162f9 commit 86c5f61
Show file tree
Hide file tree
Showing 13 changed files with 339 additions and 152 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/black.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: ci

on:
push:
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install poetry
uses: abatilo/actions-poetry@v2
- name: Install dependencies
run: |
poetry install --with dev
- name: Lint
run: poetry run ruff check
- name: Format check
run: poetry run ruff format --check
- name: Type check
run: poetry run mypy

publish:
runs-on: ubuntu-latest
needs: check
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Build and publish to pypi
uses: JRubics/poetry-publish@v1.16
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
16 changes: 0 additions & 16 deletions .github/workflows/publish.yml

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ notes
todo
.python-version
__pycache__
geckodriver.log
geckodriver.log
.mypy_cache
.ruff_cache
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[mypy]
packages = youtube_up
incremental = false
230 changes: 180 additions & 50 deletions poetry.lock

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "youtube-up"
version = "0.5.2"
version = "0.5.3"
description = "Upload videos to YouTube using the internal YouTube API. Does not require an API key."
authors = ["7x11x13 <x7x11x13@gmail.com>"]
readme = "README.md"
Expand All @@ -11,7 +11,7 @@ keywords = ["YouTube", "upload"]
[tool.poetry.dependencies]
python = "^3.10"
selenium = "^4.11.2"
selenium-wire-2 = "^0.1.0"
selenium-wire-2 = "^0.2.1"
requests = "^2.32.3"
dataclasses-json = "^0.6.2"
tqdm = "^4.66.1"
Expand All @@ -25,6 +25,15 @@ optional = true
[tool.poetry.group.docs.dependencies]
pdoc = { version = "^14.1.0", python = "^3.8" }

[tool.poetry.group.dev]
optional = true

[tool.poetry.group.dev.dependencies]
ruff = "^0.5.0"
mypy = "^1.10.1"
types-tqdm = "^4.66.0.20240417"
types-requests = "^2.32.0.20240622"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
5 changes: 4 additions & 1 deletion youtube_up/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa
"""
# Installation
Expand Down Expand Up @@ -127,6 +128,8 @@
"""

from .metadata import *
from .metadata import __all__ as m_all
from .uploader import *
from .uploader import __all__ as u_all

__all__ = uploader.__all__ + metadata.__all__
__all__ = u_all + m_all
25 changes: 19 additions & 6 deletions youtube_up/__main__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import argparse
import json
from argparse import BooleanOptionalAction

import tqdm

from .metadata import *
from .uploader import YTUploaderSession
from youtube_up.metadata import (
AllowCommentsEnum,
CaptionsFile,
CategoryEnum,
CommentsSortOrderEnum,
LicenseEnum,
Metadata,
PremiereDurationEnum,
PremiereThemeEnum,
PrivacyEnum,
)

try:
from argparse import BooleanOptionalAction
except ImportError:
from .polyfills import BooleanOptionalAction
from .uploader import YTUploaderSession


def main():
Expand Down Expand Up @@ -200,3 +207,9 @@ def callback(step: str, prog: int):

if __name__ == "__main__":
main()
main()


if __name__ == "__main__":
main()
main()
10 changes: 5 additions & 5 deletions youtube_up/metadata.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
from dataclasses import dataclass, field
from enum import Enum
from typing import List, Optional
from typing import Optional

import marshmallow.fields as mm_field
from dataclasses_json import config, dataclass_json
Expand Down Expand Up @@ -396,7 +396,7 @@ class Metadata:
made_for_kids: bool = False
"""Made for kids. If true comments will be disabled"""

tags: List[str] = ()
tags: tuple[str, ...] = ()
"""List of tags"""

# optional metadata for update_metadata
Expand Down Expand Up @@ -425,10 +425,10 @@ class Metadata:
CINEMATIC, CONTEMPORARY, DRAMATIC, FUNKY, GENTLE, HAPPY, INSPIRATIONAL, KIDS, SCI_FI, SPORTS
"""

playlist_ids: Optional[List[str]] = None
playlist_ids: Optional[list[str]] = None
"""List of existing playlist IDs to add video to"""

playlists: Optional[List[Playlist]] = None
playlists: Optional[list[Playlist]] = None
"""List of playlists to create and/or add video to"""

thumbnail: Optional[str] = None
Expand Down Expand Up @@ -473,7 +473,7 @@ class Metadata:
audio_language: Optional[LanguageEnum] = None
"""Language of audio"""

captions_files: Optional[List[CaptionsFile]] = None
captions_files: Optional[list[CaptionsFile]] = None
"""Path to captions files (.srt)"""

license: Optional[LicenseEnum] = None
Expand Down
Empty file added youtube_up/py.typed
Empty file.
Loading

0 comments on commit 86c5f61

Please sign in to comment.