Skip to content

Commit

Permalink
Fix missing stubs for sympy (#1153)
Browse files Browse the repository at this point in the history
* fix missing stubs for sympy

* ignore import-untyped

* add news fragment
  • Loading branch information
getzze authored Jul 8, 2024
1 parent 5ff3994 commit cf06887
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.d/1153.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix missing stubs for sympy
13 changes: 5 additions & 8 deletions subliminal/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,12 @@

from __future__ import annotations

import contextlib
import logging
from importlib.util import find_spec
from typing import TYPE_CHECKING, Any

from .video import Episode, Movie

WITH_SYMPY = False
with contextlib.suppress(ImportError):
import sympy # noqa: F401

WITH_SYMPY = True

if TYPE_CHECKING:
from typing import Protocol

Expand All @@ -57,6 +51,9 @@ class ComputeScore(Protocol):
def __call__(self, subtitle: Subtitle, video: Video, *, hearing_impaired: bool | None) -> int: ... # noqa: D102


# Check if sympy is installed (for tests)
WITH_SYMPY = find_spec('sympy') is not None

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -233,7 +230,7 @@ def compute_score(subtitle: Subtitle, video: Video, *, hearing_impaired: bool |


if WITH_SYMPY:
from sympy import Eq, Symbol, solve, symbols
from sympy import Eq, Symbol, solve, symbols # type: ignore[import-untyped]

def solve_episode_equations() -> dict[Symbol, int]:
"""Solve the score equation for Episodes.
Expand Down

0 comments on commit cf06887

Please sign in to comment.