Typing
This commit is contained in:
@@ -20,19 +20,19 @@
|
||||
import sys
|
||||
from abc import abstractmethod
|
||||
from collections.abc import Iterable
|
||||
from typing import Any, Collection, Generator
|
||||
from typing import Any, Collection, Generator, Optional
|
||||
|
||||
from src.game import Game
|
||||
from src.importer.sources.location import Location
|
||||
|
||||
# Type of the data returned by iterating on a Source
|
||||
SourceIterationResult = None | Game | tuple[Game, tuple[Any]]
|
||||
SourceIterationResult = Optional[Game | tuple[Game, tuple[Any]]]
|
||||
|
||||
|
||||
class SourceIterable(Iterable):
|
||||
"""Data producer for a source of games"""
|
||||
|
||||
source: "Source" = None
|
||||
source: "Source"
|
||||
|
||||
def __init__(self, source: "Source") -> None:
|
||||
self.source = source
|
||||
@@ -53,7 +53,7 @@ class Source(Iterable):
|
||||
|
||||
source_id: str
|
||||
name: str
|
||||
variant: str = None
|
||||
variant: Optional[str] = None
|
||||
available_on: set[str] = set()
|
||||
iterable_class: type[SourceIterable]
|
||||
|
||||
@@ -65,7 +65,7 @@ class Source(Iterable):
|
||||
def full_name(self) -> str:
|
||||
"""The source's full name"""
|
||||
full_name_ = self.name
|
||||
if self.variant is not None:
|
||||
if self.variant:
|
||||
full_name_ += f" ({self.variant})"
|
||||
return full_name_
|
||||
|
||||
@@ -75,7 +75,7 @@ class Source(Iterable):
|
||||
return self.source_id + "_{game_id}"
|
||||
|
||||
@property
|
||||
def is_available(self):
|
||||
def is_available(self) -> bool:
|
||||
return sys.platform in self.available_on
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user