Skip to content

Commit

Permalink
Update pre commit hooks versions (#1189)
Browse files Browse the repository at this point in the history
* update pre-commit versions

* build docs with installed package

* add missing subtitulamos items

* simple readme
  • Loading branch information
getzze authored Nov 22, 2024
1 parent f5cb721 commit 3d22d8d
Show file tree
Hide file tree
Showing 23 changed files with 277 additions and 279 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ repos:
- id: end-of-file-fixer

- repo: https://github.com/crate-ci/typos
rev: v1.27.3
rev: typos-dict-v0.11.35
hooks:
- id: typos

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.4
rev: v0.8.0
hooks:
- id: ruff
args: [--fix, --unsafe-fixes]
- id: ruff-format

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.19
rev: v0.23
hooks:
- id: validate-pyproject
name: validate-pyproject
Expand Down
1 change: 1 addition & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
# Keep in sync with CI.yaml/docs, hatch.toml and tox/docs.
python: "3.12"

python:
Expand Down
5 changes: 0 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import sphinx_rtd_theme

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('..'))
import subliminal

# -- General configuration ------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions docs/user/how_it_works.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ subtitles. Current supported providers are:
* OpenSubtitles
* OpenSubtitles.com
* Podnapisi
* Subtitulamos
* TvSubtitles

Providers all inherit the same :class:`~subliminal.providers.Provider` base class and thus share the same API.
Expand Down
15 changes: 8 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# https://peps.python.org/pep-0517/
# https://packaging.python.org/en/latest/specifications/pyproject-toml/
[build-system]
requires = ["setuptools>=64"]
build-backend = "setuptools.build_meta"
Expand All @@ -8,6 +8,7 @@ build-backend = "setuptools.build_meta"
name = "subliminal"
description = "Subtitles, faster than your thoughts"
requires-python = ">=3.9"
readme = "README.rst"
license = { text = "MIT" }
authors = [{ name = "Antoine Bertin", email = "diaoulael@gmail.com" }]
maintainers = [
Expand All @@ -31,7 +32,7 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Multimedia :: Video",
]
dynamic = ["version", "readme"]
dynamic = ["version"]
dependencies = [
"babelfish>=0.6.1",
"beautifulsoup4>=4.4.0",
Expand Down Expand Up @@ -115,6 +116,7 @@ tvdb = "subliminal.refiners.tvdb:refine"
addic7ed = "subliminal.converters.addic7ed:Addic7edConverter"
opensubtitles = "subliminal.converters.opensubtitles:OpenSubtitlesConverter"
opensubtitlescom = "subliminal.converters.opensubtitlescom:OpenSubtitlesComConverter"
subtitulamos = "subliminal.converters.subtitulamos:SubtitulamosConverter"
tvsubtitles = "subliminal.converters.tvsubtitles:TVsubtitlesConverter"

[tool.setuptools]
Expand All @@ -132,7 +134,6 @@ where = ["."]

[tool.setuptools.dynamic]
version = {attr = "subliminal.__version__"}
readme = {file = ["README.rst", "HISTORY.rst"]}


# https://docs.pytest.org/en/6.2.x/customize.html
Expand Down Expand Up @@ -166,7 +167,10 @@ omit = [
]

[tool.coverage.paths]
source = [".tox/py*/**/site-packages"]
source = [
"subliminal",
"**/site-packages/subliminal",
]

[tool.coverage.run]
source = ["subliminal"]
Expand Down Expand Up @@ -218,9 +222,6 @@ ignore = [
"D401", # First line should be in imperative mood
]

[tool.ruff.lint.flake8-pytest-style]
mark-parentheses = true

[tool.ruff.lint.per-file-ignores]
"docs/conf*.py" = ["ALL"]
"subliminal/__init__.py" = ["E402"]
Expand Down
28 changes: 14 additions & 14 deletions subliminal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,28 @@


__all__ = [
'region',
'SUBTITLE_EXTENSIONS',
'VIDEO_EXTENSIONS',
'AsyncProviderPool',
'Episode',
'Error',
'Movie',
'Provider',
'ProviderError',
'ProviderPool',
'Subtitle',
'Video',
'check_video',
'compute_score',
'download_best_subtitles',
'download_subtitles',
'get_scores',
'list_subtitles',
'provider_manager',
'refine',
'refiner_manager',
'region',
'save_subtitles',
'scan_video',
'scan_videos',
'Error',
'ProviderError',
'provider_manager',
'refiner_manager',
'Provider',
'compute_score',
'get_scores',
'SUBTITLE_EXTENSIONS',
'Subtitle',
'VIDEO_EXTENSIONS',
'Episode',
'Movie',
'Video',
]
4 changes: 2 additions & 2 deletions subliminal/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from xmlrpc.client import SafeTransport

# Do not put babelfish in a TYPE_CHECKING block for intersphinx to work properly
from babelfish import Language # type: ignore[import-untyped] # noqa: TCH002
from babelfish import Language # type: ignore[import-untyped] # noqa: TC002
from bs4 import BeautifulSoup, FeatureNotFound
from requests import adapters
from urllib3 import poolmanager # type: ignore[import-untyped]
Expand Down Expand Up @@ -51,7 +51,7 @@ def init_poolmanager(self, connections: int, maxsize: int, block: bool = False,


class TimeoutSafeTransport(SafeTransport):
"""Timeout support for :library/xmlrpc.client:class:`~xmlrpc.client.SafeTransport`."""
"""Timeout support for :class:`!xmlrpc.client.SafeTransport`."""

timeout: float | None

Expand Down
2 changes: 1 addition & 1 deletion subliminal/providers/tvsubtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def query(

# get the episode page
logger.info('Getting the page for episode %d', episode_ids[episode])
r = self.session.get(self.server_url + '/episode-%d.html' % episode_ids[episode], timeout=10)
r = self.session.get(self.server_url + f'/episode-{episode_ids[episode]:d}.html', timeout=10)
soup = ParserBeautifulSoup(r.content, ['lxml', 'html.parser'])

# loop over subtitles rows
Expand Down
4 changes: 2 additions & 2 deletions subliminal/refiners/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ def refine(video: Video, *, embedded_subtitles: bool = True, **kwargs: Any) -> V
# resolution
if video_track.height in (480, 720, 1080):
if video_track.interlaced:
video.resolution = '%di' % video_track.height
video.resolution = f'{video_track.height:d}i'
else:
video.resolution = '%dp' % video_track.height
video.resolution = f'{video_track.height:d}p'
logger.debug('Found resolution %s', video.resolution)

# video codec
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def _configure_region():
region.configure = Mock() # type: ignore[method-assign]


@pytest.fixture()
@pytest.fixture
def movies() -> dict[str, Movie]:
return {
'man_of_steel': Movie(
Expand Down Expand Up @@ -83,7 +83,7 @@ def movies() -> dict[str, Movie]:
}


@pytest.fixture()
@pytest.fixture
def episodes() -> dict[str, Episode]:
return {
'bbt_s07e05': Episode(
Expand Down
Loading

0 comments on commit 3d22d8d

Please sign in to comment.