Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Use Any and temp ignore unknown types in subclasses of SearchCore #186

Merged
merged 2 commits into from Jun 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 25 additions & 23 deletions youtubesearchpython/__future__/search.py
@@ -1,6 +1,8 @@
from typing import Any, Dict, Optional

from youtubesearchpython.core.channelsearch import ChannelSearchCore
from youtubesearchpython.core.constants import *
from youtubesearchpython.core.search import SearchCore
from youtubesearchpython.core.channelsearch import ChannelSearchCore


class Search(SearchCore):
Expand Down Expand Up @@ -69,12 +71,12 @@ class Search(SearchCore):
]
}
'''
def __init__(self, query: str, limit: int = 20, language: str = 'en', region: str = 'US', timeout: int = None):
def __init__(self, query: str, limit: int = 20, language: str = 'en', region: str = 'US', timeout: Optional[int] = None):
self.searchMode = (True, True, True)
super().__init__(query, limit, language, region, None, timeout)
super().__init__(query, limit, language, region, None, timeout) # type: ignore

async def next(self):
return await self._nextAsync()
async def next(self) -> Dict[str, Any]:
return await self._nextAsync() # type: ignore


class VideosSearch(SearchCore):
Expand Down Expand Up @@ -143,12 +145,12 @@ class VideosSearch(SearchCore):
]
}
'''
def __init__(self, query: str, limit: int = 20, language: str = 'en', region: str = 'US', timeout: int = None):
def __init__(self, query: str, limit: int = 20, language: str = 'en', region: str = 'US', timeout: Optional[int] = None):
self.searchMode = (True, False, False)
super().__init__(query, limit, language, region, SearchMode.videos, timeout)
super().__init__(query, limit, language, region, SearchMode.videos, timeout) # type: ignore

async def next(self):
return await self._nextAsync()
async def next(self) -> Dict[str, Any]:
return await self._nextAsync() # type: ignore


class ChannelsSearch(SearchCore):
Expand Down Expand Up @@ -192,12 +194,12 @@ class ChannelsSearch(SearchCore):
]
}
'''
def __init__(self, query: str, limit: int = 20, language: str = 'en', region: str = 'US', timeout: int = None):
def __init__(self, query: str, limit: int = 20, language: str = 'en', region: str = 'US', timeout: Optional[int] = None):
self.searchMode = (False, True, False)
super().__init__(query, limit, language, region, SearchMode.channels, timeout)
super().__init__(query, limit, language, region, SearchMode.channels, timeout) # type: ignore

async def next(self):
return await self._nextAsync()
async def next(self) -> Dict[str, Any]:
return await self._nextAsync() # type: ignore


class PlaylistsSearch(SearchCore):
Expand Down Expand Up @@ -254,12 +256,12 @@ class PlaylistsSearch(SearchCore):
]
}
'''
def __init__(self, query: str, limit: int = 20, language: str = 'en', region: str = 'US', timeout: int = None):
def __init__(self, query: str, limit: int = 20, language: str = 'en', region: str = 'US', timeout: Optional[int] = None):
self.searchMode = (False, False, True)
super().__init__(query, limit, language, region, SearchMode.playlists, timeout)
super().__init__(query, limit, language, region, SearchMode.playlists, timeout) # type: ignore

async def next(self):
return await self._nextAsync()
async def next(self) -> Dict[str, Any]:
return await self._nextAsync() # type: ignore

class CustomSearch(SearchCore):
'''Performs custom search in YouTube with search filters or sorting orders.
Expand Down Expand Up @@ -338,12 +340,12 @@ class CustomSearch(SearchCore):
]
}
'''
def __init__(self, query: str, searchPreferences: str, limit: int = 20, language: str = 'en', region: str = 'US', timeout: int = None):
def __init__(self, query: str, searchPreferences: str, limit: int = 20, language: str = 'en', region: str = 'US', timeout: Optional[int] = None):
self.searchMode = (True, True, True)
super().__init__(query, limit, language, region, searchPreferences, timeout)
super().__init__(query, limit, language, region, searchPreferences, timeout) # type: ignore

async def next(self):
return await self._nextAsync()
async def next(self) -> Dict[str, Any]:
return await self._nextAsync() # type: ignore

class ChannelSearch(ChannelSearchCore):
'''Searches for videos in specific channel in YouTube.
Expand Down Expand Up @@ -418,5 +420,5 @@ class ChannelSearch(ChannelSearchCore):
}
'''

def __init__(self, query: str, browseId: str, language: str = 'en', region: str = 'US', searchPreferences: str = "EgZzZWFyY2g%3D", timeout: int = None):
super().__init__(query, language, region, searchPreferences, browseId, timeout)
def __init__(self, query: str, browseId: str, language: str = 'en', region: str = 'US', searchPreferences: str = "EgZzZWFyY2g%3D", timeout: Optional[int] = None):
super().__init__(query, language, region, searchPreferences, browseId, timeout) # type: ignore