Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .github/workflows/dependabotautomerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
github.rest.pulls.merge({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
pull_number: context.payload.pull_request.number
pull_number: context.payload.pull_request.number,
merge_method: 'squash',
})
github-token: ${{github.token}}
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ repos:
- id: detect-private-key

- repo: https://github.com/astral-sh/uv-pre-commit
rev: '0.8.23'
rev: '0.9.3'
hooks:
- id: uv-lock
- id: uv-sync

# Run the Ruff linter.
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.13.3
rev: v0.14.1
hooks:
# Linter
- id: ruff
Expand Down
16 changes: 15 additions & 1 deletion pymkv/Timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def __init__( # noqa: PLR0913
self._ss = 0 if ss is None else ss
self._nn = 0 if nn is None else nn

def __hash__(self) -> int:
"""Returns a hash value for the Timestamp object."""
return self.time

def __eq__(self, other: object) -> bool:
"""
Compares the Timestamp object with another Timestamp object for equality.
Expand Down Expand Up @@ -225,7 +229,7 @@ def ts(self) -> str:
return timestamp_string

@ts.setter
def ts(self, timestamp: Timestamp) -> None:
def ts(self, timestamp: Timestamp | int | str) -> None:
"""
Set a new timestamp.

Expand Down Expand Up @@ -322,6 +326,16 @@ def nn(self, value: int) -> None:
"""
self._nn = value if value < 1000000000 else 0 # noqa: PLR2004

@property
def time(self) -> int:
"""
Get the total time in seconds represented by the timestamp.

Returns:
int: The total time in seconds.
"""
return self.hh * 3600 + self.mm * 60 + self.ss + self.nn // 1000000000

@property
def form(self) -> str:
"""
Expand Down
10 changes: 2 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dev = [
"pytest-ruff<1.0.0,>=0.4.1",
"pytest-mypy>=0.10.3,<2.0.0",
"mypy<2.0.0,>=1.14.1",
"ruff<1.0.0,>=0.9.0",
"ruff<1.0.0,>=0.14.0",
"sphinx-immaterial<0.14.0,>=0.12.4; python_version == \"3.13\"",
"pyinstrument>=5.1.1",
]
Expand Down Expand Up @@ -149,10 +149,6 @@ ignore = [
"S101", # Use of assert detected https://docs.astral.sh/ruff/rules/assert/
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"SIM102", # sometimes it's better to nest
"UP038", # Checks for uses of isinstance/issubclass that take a tuple
# of types for comparison.
# Deactivated because it can make the code slow:
# https://github.com/astral-sh/ruff/issues/7871
"TC003", # Ignore moving imports into a type-checking block.
"C901" # too complex
]
Expand All @@ -161,9 +157,7 @@ fixable = ["ALL"]
unfixable = []
# The fixes in extend-unsafe-fixes will require
# provide the `--unsafe-fixes` flag when fixing.
extend-unsafe-fixes = [
"UP038"
]
extend-unsafe-fixes = []
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

Expand Down
2 changes: 1 addition & 1 deletion tests/test_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def track_id(self) -> int | None:
return self._track_id

@track_id.setter
@ensure_info(
@ensure_info( # type: ignore[arg-type]
"_info_json",
lambda *args, **kwargs: {"tracks": [{"id": 0}, {"id": 1}]},
["file_path", "mkvmerge_path"],
Expand Down
14 changes: 14 additions & 0 deletions tests/test_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,19 @@ def test_ts_property() -> None:
ts.ts = "02:30:00"
assert ts.ts == "02:30:00"

ts.ts = ts.time
assert ts.ts == "02:30:00"

with pytest.raises(TypeError):
ts.ts = cast("str", [])


def test_ts_equals() -> None:
ts1 = Timestamp("01:23:45.678")
ts2 = Timestamp("01:23:45.678")
ts3 = Timestamp("02:30:00")

assert ts1 == ts2
assert ts1 != ts3
assert hash(ts1) == hash(ts2)
assert hash(ts1) != hash(ts3)
Loading
Loading