Skip to content
Open
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
__pycache__/
.coverage
/build
/dist
poetry.lock

4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:

- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.13.2
hooks:
- id: isort
additional_dependencies: [toml]
Expand All @@ -14,7 +14,7 @@ repos:
hooks:
- id: mypy
- repo: https://github.com/pycqa/pylint
rev: v2.13.7
rev: v2.17.7
hooks:
- id: pylint
additional_dependencies: [toml]
2 changes: 2 additions & 0 deletions ass_tag_parser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from .ass_composer import compose_ass
from .ass_parser import ass_to_plaintext, parse_ass
from .ass_struct import *
Expand Down
2 changes: 2 additions & 0 deletions ass_tag_parser/ass_composer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from dataclasses import dataclass

from ass_tag_parser.ass_struct import (
Expand Down
16 changes: 15 additions & 1 deletion ass_tag_parser/ass_parser.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
from __future__ import annotations

import re
from dataclasses import dataclass
from functools import cache
from typing import Any, Iterable, Optional, Union

try:
from functools import cache as _cache # type: ignore

def cache(user_function: Any) -> Any:
return _cache(user_function)

except ImportError:

# skip cahcing on Python < 3.9
def cache(user_function: Any) -> Any:
return user_function


from ass_tag_parser.ass_struct import (
AssItem,
AssTag,
Expand Down
2 changes: 2 additions & 0 deletions ass_tag_parser/ass_struct.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from dataclasses import dataclass, field
from typing import Optional

Expand Down
2 changes: 2 additions & 0 deletions ass_tag_parser/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from dataclasses import dataclass
from typing import Union

Expand Down
2 changes: 2 additions & 0 deletions ass_tag_parser/draw_composer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Any

from ass_tag_parser.common import smart_float
Expand Down
16 changes: 11 additions & 5 deletions ass_tag_parser/draw_parser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from dataclasses import dataclass
from typing import Iterable, Optional, Union, cast

Expand Down Expand Up @@ -81,12 +83,16 @@ def _parse_draw_commands(ctx: _ParseContext) -> Iterable[AssDrawCmd]:
elif cmd == "l":
ret = AssDrawCmdLine(list(_read_points(ctx.io, min_count=1)))
elif cmd == "b":
ret = AssDrawCmdBezier(
cast(
tuple[AssDrawPoint, AssDrawPoint, AssDrawPoint],
tuple(_read_points(ctx.io, min_count=3, max_count=3)),
points = tuple(_read_points(ctx.io, min_count=3, max_count=3))
try:
ret = AssDrawCmdBezier(
cast(
tuple[AssDrawPoint, AssDrawPoint, AssDrawPoint], points
)
)
)
except TypeError:
# This is a workaround for Python 3.8
ret = AssDrawCmdBezier(points) # type: ignore
elif cmd == "s":
ret = AssDrawCmdSpline(
list(_read_points(ctx.io, min_count=3, max_count=None))
Expand Down
2 changes: 2 additions & 0 deletions ass_tag_parser/draw_struct.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from dataclasses import dataclass
from typing import Optional

Expand Down
2 changes: 2 additions & 0 deletions ass_tag_parser/errors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Optional


Expand Down
2 changes: 2 additions & 0 deletions ass_tag_parser/io.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import io
from typing import Optional

Expand Down
2 changes: 2 additions & 0 deletions ass_tag_parser/tests/test_ass_composing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import pytest

from ass_tag_parser import (
Expand Down
2 changes: 2 additions & 0 deletions ass_tag_parser/tests/test_draw_composing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import pytest

from ass_tag_parser import (
Expand Down
2 changes: 2 additions & 0 deletions ass_tag_parser/tests/test_draw_parsing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import pytest

from ass_tag_parser import (
Expand Down
2 changes: 2 additions & 0 deletions ass_tag_parser/tests/test_module_exports.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import re
from itertools import chain
from pathlib import Path
Expand Down
Loading