]> kaliko git repositories - python-musicpd.git/commitdiff
Some more type hints mypy
authorKaliko Jack <kaliko@azylum.org>
Sat, 1 Apr 2023 16:08:12 +0000 (18:08 +0200)
committerKaliko Jack <kaliko@azylum.org>
Sat, 1 Apr 2023 16:08:12 +0000 (18:08 +0200)
musicpd.py

index e779355ae24bf9fa00a49729e055e2ba0dee2f3f..c083206b6e018f709da97e5507f969c520302cc9 100644 (file)
@@ -13,7 +13,7 @@ import os
 from functools import wraps
 # Type hint for python <= 3.8
 from typing import Any, Dict, List, Tuple
-from typing import Optional, Union
+from typing import Iterator, Optional, Union
 
 HELLO_PREFIX = "OK MPD "
 ERROR_PREFIX = "ACK "
@@ -394,7 +394,7 @@ class MPDClient:
         self._wfile.write(f"{line!s}\n")
         self._wfile.flush()
 
-    def _write_command(self, command, args=None):
+    def _write_command(self, command, args: Optional[list[str]] = None):
         if args is None:
             args = []
         parts = [command]
@@ -407,7 +407,7 @@ class MPDClient:
             raise CommandError('new line found in the command!')
         self._write_line(" ".join(parts))
 
-    def _read_binary(self, amount):
+    def _read_binary(self, amount: int):
         chunk = bytearray()
         while amount > 0:
             result = self._rbfile.read(amount)
@@ -448,7 +448,7 @@ class MPDClient:
             raise ProtocolError(f"Could not parse pair: '{line}'")
         return pair
 
-    def _read_pairs(self, separator=": ", binary: bool =False):
+    def _read_pairs(self, separator: str =": ", binary: bool =False):
         pair = self._read_pair(separator, binary=binary)
         while pair:
             yield pair
@@ -467,7 +467,7 @@ class MPDClient:
         for _, value in self._read_pairs(":"):
             yield value
 
-    def _read_objects(self, delimiters: Optional[List[str]] = None):
+    def _read_objects(self, delimiters: Optional[List[str]] = None) -> Iterator[Dict]:
         obj: Dict[str,Any] = {}
         if delimiters is None:
             delimiters = []
@@ -514,14 +514,14 @@ class MPDClient:
     def _fetch_playlist(self):
         return self._read_playlist()
 
-    def _fetch_object(self):
+    def _fetch_object(self) -> Dict:
         objs = list(self._read_objects())
         if not objs:
             return {}
         return objs[0]
 
     @iterator_wrapper
-    def _fetch_objects(self, delimiters):
+    def _fetch_objects(self, delimiters: List[str]):
         return self._read_objects(delimiters)
 
     def _fetch_changes(self):