Skip to content

Commit

Permalink
Change Deferred type hints to strings.
Browse files Browse the repository at this point in the history
Older versions of twisted (<21.7) don't
support generic Deferred type hinting,
this prevents crashes on those versions.
  • Loading branch information
gazpachoking committed Feb 5, 2022
1 parent 9ebbaf3 commit 49aafdf
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions deluge/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def check_new_release(self):
@export
def add_torrent_file_async(
self, filename: str, filedump: str, options: dict, save_state: bool = True
) -> defer.Deferred[Optional[str]]:
) -> 'defer.Deferred[Optional[str]]':
"""Adds a torrent file to the session asynchronously.
Args:
Expand Down Expand Up @@ -434,7 +434,7 @@ def add_torrent_file_async(
@export
def prefetch_magnet_metadata(
self, magnet: str, timeout: int = 30
) -> defer.Deferred[Tuple[str, bytes]]:
) -> 'defer.Deferred[Tuple[str, bytes]]':
"""Download magnet metadata without adding to Deluge session.
Used by UIs to get magnet files for selection before adding to session.
Expand Down Expand Up @@ -490,7 +490,7 @@ def add_torrent_file(
@export
def add_torrent_files(
self, torrent_files: List[Tuple[str, Union[str, bytes], dict]]
) -> defer.Deferred[List[AddTorrentError]]:
) -> 'defer.Deferred[List[AddTorrentError]]':
"""Adds multiple torrent files to the session asynchronously.
Args:
Expand Down Expand Up @@ -520,7 +520,7 @@ def add_torrents():
@export
def add_torrent_url(
self, url: str, options: dict, headers: dict = None
) -> defer.Deferred[Optional[str]]:
) -> 'defer.Deferred[Optional[str]]':
"""Adds a torrent from a URL. Deluge will attempt to fetch the torrent
from the URL prior to adding it to the session.
Expand Down Expand Up @@ -590,7 +590,7 @@ def remove_torrent(self, torrent_id: str, remove_data: bool) -> bool:
@export
def remove_torrents(
self, torrent_ids: List[str], remove_data: bool
) -> defer.Deferred[List[Tuple[str, str]]]:
) -> 'defer.Deferred[List[Tuple[str, str]]]':
"""Remove multiple torrents from the session.
Args:
Expand Down Expand Up @@ -873,11 +873,11 @@ def get_enabled_plugins(self) -> List[str]:
return self.pluginmanager.get_enabled_plugins()

@export
def enable_plugin(self, plugin: str) -> defer.Deferred[bool]:
def enable_plugin(self, plugin: str) -> 'defer.Deferred[bool]':
return self.pluginmanager.enable_plugin(plugin)

@export
def disable_plugin(self, plugin: str) -> defer.Deferred[bool]:
def disable_plugin(self, plugin: str) -> 'defer.Deferred[bool]':
return self.pluginmanager.disable_plugin(plugin)

@export
Expand Down Expand Up @@ -1211,7 +1211,7 @@ def glob(self, path: str) -> List[str]:
return glob.glob(path)

@export
def test_listen_port(self) -> defer.Deferred[Optional[bool]]:
def test_listen_port(self) -> 'defer.Deferred[Optional[bool]]':
"""Checks if the active port is open
Returns:
Expand Down

0 comments on commit 49aafdf

Please sign in to comment.