From 8fc178276e8dbdd913ef9ee14d721516b422e853 Mon Sep 17 00:00:00 2001 From: bastimeyer Date: Mon, 23 May 2022 17:22:29 +0200 Subject: [PATCH] chore: fix import typing issues --- src/streamlink/plugin/api/websocket.py | 2 +- src/streamlink/plugins/pluzz.py | 2 +- src/streamlink/stream/dash_manifest.py | 2 +- src/streamlink/stream/hls_playlist.py | 3 +-- src/streamlink/utils/l10n.py | 2 +- src/streamlink_cli/main.py | 4 ++-- src/streamlink_cli/utils/http_server.py | 6 +----- tests/plugin/__init__.py | 0 tests/stream/test_hls_playlist.py | 3 +-- tests/test_api_websocket.py | 2 +- 10 files changed, 10 insertions(+), 16 deletions(-) create mode 100644 tests/plugin/__init__.py diff --git a/src/streamlink/plugin/api/websocket.py b/src/streamlink/plugin/api/websocket.py index 3a43324f..767366cf 100644 --- a/src/streamlink/plugin/api/websocket.py +++ b/src/streamlink/plugin/api/websocket.py @@ -4,7 +4,7 @@ from threading import RLock, Thread from typing import Any, Dict, List, Optional, Tuple, Union from urllib.parse import unquote_plus, urlparse -from websocket import ABNF, STATUS_NORMAL, WebSocketApp, enableTrace +from websocket import ABNF, STATUS_NORMAL, WebSocketApp, enableTrace # type: ignore[import] from streamlink.logger import TRACE, root as rootlogger from streamlink.session import Streamlink diff --git a/src/streamlink/plugins/pluzz.py b/src/streamlink/plugins/pluzz.py index a3d11e31..bf36c378 100644 --- a/src/streamlink/plugins/pluzz.py +++ b/src/streamlink/plugins/pluzz.py @@ -11,7 +11,7 @@ import re from datetime import datetime from urllib.parse import urlparse -from isodate import LOCAL as LOCALTIMEZONE +from isodate import LOCAL as LOCALTIMEZONE # type: ignore[import] from streamlink.plugin import Plugin, PluginError, pluginmatcher from streamlink.plugin.api import useragents, validate diff --git a/src/streamlink/stream/dash_manifest.py b/src/streamlink/stream/dash_manifest.py index afc82cd0..9a806ded 100644 --- a/src/streamlink/stream/dash_manifest.py +++ b/src/streamlink/stream/dash_manifest.py @@ -10,7 +10,7 @@ from itertools import count, repeat from typing import Optional from urllib.parse import urljoin, urlparse, urlsplit, urlunparse, urlunsplit -from isodate import Duration, UTC as utc, parse_datetime, parse_duration +from isodate import Duration, UTC as utc, parse_datetime, parse_duration # type: ignore[import] log = logging.getLogger(__name__) diff --git a/src/streamlink/stream/hls_playlist.py b/src/streamlink/stream/hls_playlist.py index d24c1b38..daf32a6c 100644 --- a/src/streamlink/stream/hls_playlist.py +++ b/src/streamlink/stream/hls_playlist.py @@ -8,8 +8,7 @@ from itertools import starmap from typing import Any, Callable, ClassVar, Dict, List, Mapping, NamedTuple, Optional, Tuple, Type, Union from urllib.parse import urljoin, urlparse -# noinspection PyPackageRequirements -from isodate import ISO8601Error, parse_datetime +from isodate import ISO8601Error, parse_datetime # type: ignore[import] log = logging.getLogger(__name__) diff --git a/src/streamlink/utils/l10n.py b/src/streamlink/utils/l10n.py index 0258cada..a1e6e3e7 100644 --- a/src/streamlink/utils/l10n.py +++ b/src/streamlink/utils/l10n.py @@ -2,7 +2,7 @@ import locale import logging from typing import Optional -from pycountry import countries, languages +from pycountry import countries, languages # type: ignore[import] DEFAULT_LANGUAGE = "en" DEFAULT_COUNTRY = "US" diff --git a/src/streamlink_cli/main.py b/src/streamlink_cli/main.py index 1ff8ce45..8b24e7b7 100644 --- a/src/streamlink_cli/main.py +++ b/src/streamlink_cli/main.py @@ -15,8 +15,8 @@ from time import sleep from typing import Any, Dict, List, Optional, Type, Union import requests -from socks import __version__ as socks_version -from websocket import __version__ as websocket_version +from socks import __version__ as socks_version # type: ignore[import] +from websocket import __version__ as websocket_version # type: ignore[import] import streamlink.logger as logger from streamlink import NoPluginError, PluginError, StreamError, Streamlink, __version__ as streamlink_version diff --git a/src/streamlink_cli/utils/http_server.py b/src/streamlink_cli/utils/http_server.py index 6661abd6..94e1a856 100644 --- a/src/streamlink_cli/utils/http_server.py +++ b/src/streamlink_cli/utils/http_server.py @@ -1,11 +1,7 @@ import socket +from http.server import BaseHTTPRequestHandler from io import BytesIO -try: - from BaseHTTPServer import BaseHTTPRequestHandler -except ImportError: - from http.server import BaseHTTPRequestHandler - class HTTPRequest(BaseHTTPRequestHandler): def __init__(self, request_text): diff --git a/tests/plugin/__init__.py b/tests/plugin/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/stream/test_hls_playlist.py b/tests/stream/test_hls_playlist.py index e0aafc73..a44e55ff 100644 --- a/tests/stream/test_hls_playlist.py +++ b/tests/stream/test_hls_playlist.py @@ -1,8 +1,7 @@ import unittest from datetime import datetime, timedelta -# noinspection PyPackageRequirements -from isodate import tzinfo +from isodate import tzinfo # type: ignore[import] from streamlink.stream.hls_playlist import DateRange, M3U8Parser, Media, Resolution, Segment, StreamInfo, load from tests.resources import text diff --git a/tests/test_api_websocket.py b/tests/test_api_websocket.py index fcf2a341..a9dbf7a9 100644 --- a/tests/test_api_websocket.py +++ b/tests/test_api_websocket.py @@ -2,7 +2,7 @@ import unittest from threading import Event from unittest.mock import Mock, call, patch -from websocket import ABNF, STATUS_NORMAL +from websocket import ABNF, STATUS_NORMAL # type: ignore[import] from streamlink.logger import DEBUG, TRACE from streamlink.plugin.api.websocket import WebsocketClient