fixed type hinting
This commit is contained in:
		@@ -1,19 +1,19 @@
 | 
				
			|||||||
from typing import Tuple
 | 
					from typing import Tuple, Type
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from ..abstract import Page
 | 
					from ..abstract import Page
 | 
				
			||||||
from ..encyclopaedia_metallum import EncyclopaediaMetallum
 | 
					from ..encyclopaedia_metallum import EncyclopaediaMetallum
 | 
				
			||||||
from ..musify import Musify
 | 
					from ..musify import Musify
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ALL_PAGES: Tuple[Page] = (
 | 
					ALL_PAGES: Tuple[Type[Page]] = (
 | 
				
			||||||
    EncyclopaediaMetallum,
 | 
					    EncyclopaediaMetallum,
 | 
				
			||||||
    Musify
 | 
					    Musify
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AUDIO_PAGES: Tuple[Page] = (
 | 
					AUDIO_PAGES: Tuple[Type[Page]] = (
 | 
				
			||||||
    Musify,
 | 
					    Musify,
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SHADY_PAGES: Tuple[Page] = (
 | 
					SHADY_PAGES: Tuple[Type[Page]] = (
 | 
				
			||||||
    Musify,
 | 
					    Musify,
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,10 +18,10 @@ class MultiPageOptions:
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        self._current_option_dict: Dict[Type[Page], Options] = defaultdict(lambda: Options())
 | 
					        self._current_option_dict: Dict[Type[Page], Options] = defaultdict(lambda: Options())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __getitem__(self, key: Page):
 | 
					    def __getitem__(self, key: Type[Page]):
 | 
				
			||||||
        return self._current_option_dict[key]
 | 
					        return self._current_option_dict[key]
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def __setitem__(self, key: Page, value: Options):
 | 
					    def __setitem__(self, key: Type[Page], value: Options):
 | 
				
			||||||
        self._current_option_dict[key] = value
 | 
					        self._current_option_dict[key] = value
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
    def string_from_all_pages(self) -> str:
 | 
					    def string_from_all_pages(self) -> str:
 | 
				
			||||||
@@ -60,7 +60,7 @@ class MultiPageOptions:
 | 
				
			|||||||
            
 | 
					            
 | 
				
			||||||
        raise KeyError("index is out of range")
 | 
					        raise KeyError("index is out of range")
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def string_from_single_page(self, page: Page) -> str:
 | 
					    def string_from_single_page(self, page: Type[Page]) -> str:
 | 
				
			||||||
        lines: List[str] = []
 | 
					        lines: List[str] = []
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        page_name_fill = "-"
 | 
					        page_name_fill = "-"
 | 
				
			||||||
@@ -74,7 +74,7 @@ class MultiPageOptions:
 | 
				
			|||||||
            
 | 
					            
 | 
				
			||||||
        return "\n".join(lines)
 | 
					        return "\n".join(lines)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def choose_from_single_page(self, page: Page, index: int) -> DatabaseObject:
 | 
					    def choose_from_single_page(self, page: Type[Page], index: int) -> DatabaseObject:
 | 
				
			||||||
        return self._current_option_dict[page][index]
 | 
					        return self._current_option_dict[page][index]
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
    def __repr__(self) -> str:
 | 
					    def __repr__(self) -> str:
 | 
				
			||||||
@@ -85,14 +85,14 @@ class Search:
 | 
				
			|||||||
    def __init__(
 | 
					    def __init__(
 | 
				
			||||||
        self,
 | 
					        self,
 | 
				
			||||||
        query: str,
 | 
					        query: str,
 | 
				
			||||||
        pages: Tuple[Page] = page_attributes.ALL_PAGES,
 | 
					        pages: Tuple[Type[Page]] = page_attributes.ALL_PAGES,
 | 
				
			||||||
        exclude_pages: Set[Page] = set(),
 | 
					        exclude_pages: Set[Type[Page]] = set(),
 | 
				
			||||||
        exclude_shady: bool = False,
 | 
					        exclude_shady: bool = False,
 | 
				
			||||||
        max_displayed_options: int = 10,
 | 
					        max_displayed_options: int = 10,
 | 
				
			||||||
        option_digits: int = 3
 | 
					        option_digits: int = 3
 | 
				
			||||||
    ) -> None:
 | 
					    ) -> None:
 | 
				
			||||||
        _page_list: List[Page] = []
 | 
					        _page_list: List[Type[Page]] = []
 | 
				
			||||||
        _audio_page_list: List[Page] = []
 | 
					        _audio_page_list: List[Type[Page]] = []
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        for page in pages:
 | 
					        for page in pages:
 | 
				
			||||||
            if exclude_shady and page in page_attributes.SHADY_PAGES:
 | 
					            if exclude_shady and page in page_attributes.SHADY_PAGES:
 | 
				
			||||||
@@ -105,8 +105,8 @@ class Search:
 | 
				
			|||||||
            if page in page_attributes.AUDIO_PAGES:
 | 
					            if page in page_attributes.AUDIO_PAGES:
 | 
				
			||||||
                _audio_page_list.append(page)
 | 
					                _audio_page_list.append(page)
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
        self.pages: Tuple[Page] = tuple(_page_list)
 | 
					        self.pages: Tuple[Type[Page]] = tuple(_page_list)
 | 
				
			||||||
        self.audio_pages: Tuple[Page] = tuple(_audio_page_list)
 | 
					        self.audio_pages: Tuple[Type[Page]] = tuple(_audio_page_list)
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        self.max_displayed_options = max_displayed_options
 | 
					        self.max_displayed_options = max_displayed_options
 | 
				
			||||||
        self.option_digits: int = option_digits
 | 
					        self.option_digits: int = option_digits
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user