Skip to content

Commit

Permalink
tools: bump ruff to 0.5.7 and fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bastimeyer committed Aug 8, 2024
1 parent db8a124 commit 1b27113
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pytest-cov
coverage[toml]

# code-linting
ruff ==0.5.5
ruff ==0.5.7

# typing
mypy ==1.10.1
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ select = [
]
ignore = [
"A003", # builtin-attribute-shadowing
"A005", # builtin-module-shadowing
"C408", # unnecessary-collection-call
"ISC003", # explicit-string-concatenation
"PLC1901", # compare-to-empty-string
Expand Down Expand Up @@ -256,6 +257,12 @@ known-first-party = ["streamlink", "streamlink_cli"]
lines-after-imports = 2
combine-as-imports = true

[tool.ruff.lint.flake8-builtins]
builtins-ignorelist = [
"BaseExceptionGroup", # compat import from exceptiongroup pkg
"ExceptionGroup", # compat import from exceptiongroup pkg
]

[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

Expand Down
13 changes: 6 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#!/usr/bin/env python
import sys
from os import path
from sys import argv, exit, version_info
from textwrap import dedent


def format_msg(text, *args, **kwargs):
return dedent(text).strip(" \n").format(*args, **kwargs)


CURRENT_PYTHON = version_info[:2]
CURRENT_PYTHON = sys.version_info[:2]
REQUIRED_PYTHON = (3, 8)

# This check and everything above must remain compatible with older Python versions
if CURRENT_PYTHON < REQUIRED_PYTHON:
exit(format_msg("""
sys.exit(format_msg("""
========================================================
Unsupported Python version
========================================================
Expand All @@ -27,15 +26,15 @@ def format_msg(text, *args, **kwargs):
""", *(REQUIRED_PYTHON + CURRENT_PYTHON)))

# Explicitly disable running tests via setuptools
if "test" in argv:
exit(format_msg("""
if "test" in sys.argv:
sys.exit(format_msg("""
Running `python setup.py test` has been deprecated since setuptools 41.5.0.
Streamlink requires pytest for collecting and running tests, via one of these commands:
`pytest` or `python -m pytest` (see the pytest docs for more infos about this)
"""))


def is_wheel_for_windows():
def is_wheel_for_windows(argv):
if "bdist_wheel" in argv:
names = ["win32", "win-amd64", "cygwin"]
length = len(argv)
Expand All @@ -51,7 +50,7 @@ def is_wheel_for_windows():
"console_scripts": ["streamlink=streamlink_cli.main:main"],
}

if is_wheel_for_windows():
if is_wheel_for_windows(sys.argv):
entry_points["gui_scripts"] = ["streamlinkw=streamlink_cli.main:main"]


Expand Down
2 changes: 1 addition & 1 deletion src/streamlink/plugin/api/validate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ruff: noqa: A001, I001
# ruff: noqa: A001, A004, I001
# order the module members logically (autodoc_member_order == "bysource")

from streamlink.plugin.api.validate._validate import (
Expand Down
2 changes: 1 addition & 1 deletion src/streamlink/stream/hls/hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from urllib.parse import urlparse

from requests import Response
from requests.exceptions import ChunkedEncodingError, ConnectionError, ContentDecodingError, InvalidSchema
from requests.exceptions import ChunkedEncodingError, ConnectionError, ContentDecodingError, InvalidSchema # noqa: A004

from streamlink.buffers import RingBuffer
from streamlink.exceptions import StreamError
Expand Down
2 changes: 1 addition & 1 deletion src/streamlink_cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from signal import SIGINT, SIGTERM, signal
from sys import exit
from sys import exit # noqa: A004


def _exit(*_):
Expand Down
10 changes: 5 additions & 5 deletions tests/stream/dash/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def test_dynamic_segment_list_continued(self, caplog: pytest.LogCaptureFixture):
("http://test/14.m4s", 14),
("http://test/15.m4s", 15),
], "Queues the init segment and the correct number of segments from the live-edge"
assert mpd.timelines[("0", "0", "0")] == 16, "Remembers the next segment number"
assert mpd.timelines["0", "0", "0"] == 16, "Remembers the next segment number"
assert [(record.name, record.levelname, record.message) for record in caplog.records] == []

# regular continuation
Expand All @@ -304,7 +304,7 @@ def test_dynamic_segment_list_continued(self, caplog: pytest.LogCaptureFixture):
("http://test/17.m4s", 17),
("http://test/18.m4s", 18),
], "All segments from the remembered segment number were queued"
assert mpd.timelines[("0", "0", "0")] == 19, "Remembers the next segment number"
assert mpd.timelines["0", "0", "0"] == 19, "Remembers the next segment number"
assert [(record.name, record.levelname, record.message) for record in caplog.records] == []

# regular continuation with a different offset
Expand All @@ -320,7 +320,7 @@ def test_dynamic_segment_list_continued(self, caplog: pytest.LogCaptureFixture):
("http://test/23.m4s", 23),
("http://test/24.m4s", 24),
], "All segments from the remembered segment number were queued"
assert mpd.timelines[("0", "0", "0")] == 25, "Remembers the next segment number"
assert mpd.timelines["0", "0", "0"] == 25, "Remembers the next segment number"
assert [(record.name, record.levelname, record.message) for record in caplog.records] == []

# skipped multiple segments
Expand All @@ -340,7 +340,7 @@ def test_dynamic_segment_list_continued(self, caplog: pytest.LogCaptureFixture):
("http://test/38.m4s", 38),
("http://test/39.m4s", 39),
], "All segments from the remembered segment number were queued"
assert mpd.timelines[("0", "0", "0")] == 40, "Remembers the next segment number"
assert mpd.timelines["0", "0", "0"] == 40, "Remembers the next segment number"
assert [(record.name, record.levelname, record.message) for record in caplog.records] == [
(
"streamlink.stream.dash.manifest",
Expand Down Expand Up @@ -368,7 +368,7 @@ def test_dynamic_segment_list_continued(self, caplog: pytest.LogCaptureFixture):
("http://test/49.m4s", 49),
("http://test/50.m4s", 50),
], "All segments from the remembered segment number were queued"
assert mpd.timelines[("0", "0", "0")] == 51, "Remembers the next segment number"
assert mpd.timelines["0", "0", "0"] == 51, "Remembers the next segment number"
assert [(record.name, record.levelname, record.message) for record in caplog.records] == [
(
"streamlink.stream.dash.manifest",
Expand Down

0 comments on commit 1b27113

Please sign in to comment.