Skip to content

Commit 8ab6bb7

Browse files
serhiyeccles
authored andcommitted
Remove misleading None on error type hint
Problem: The function wait_for_confirmation() has an unreachable "return None". Pylance cannot prove that the return is unreachable and provides an erroneous type hint error Solution: Use PEP 484 annotation to ignore the returned type and fix previous type hints. Signed off: Serhiy: Serhiy1@live.co.uk
1 parent 9f6ace4 commit 8ab6bb7

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

archivist/assets.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def __init__(self, archivist: "type_helper.Archivist"):
109109

110110
def create(
111111
self, behaviours: List, attrs: Dict, *, confirm: bool = False
112-
) -> NoneOnError[Asset]:
112+
) -> Asset:
113113
"""Create asset
114114
115115
Creates asset with defined behaviours and attributes.
@@ -134,7 +134,7 @@ def create(
134134

135135
def create_from_data(
136136
self, data: Dict, *, confirm: bool = False
137-
) -> NoneOnError[Asset]:
137+
) -> Asset:
138138
"""Create asset
139139
140140
Creates asset with request body from data stream.
@@ -157,7 +157,7 @@ def create_from_data(
157157
if not confirm:
158158
return asset
159159

160-
return wait_for_confirmation(self, asset["identity"])
160+
return wait_for_confirmation(self, asset["identity"]) # type: ignore The None return is unreachable
161161

162162
def read(self, identity: str) -> Asset:
163163
"""Read asset

archivist/events.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import logging
2626
from typing import Dict, Optional
2727
from copy import deepcopy
28-
from archivist.type_aliases import NoneOnError
2928

3029
# pylint:disable=unused-import # To prevent cyclical import errors forward referencing is used
3130
# pylint:disable=cyclic-import # but pylint doesn't understand this feature
@@ -125,7 +124,7 @@ def create(
125124
*,
126125
asset_attrs: Optional[Dict] = None,
127126
confirm: bool = False,
128-
) -> NoneOnError[Event]:
127+
) -> Event:
129128
"""Create event
130129
131130
Creates event for given asset.
@@ -151,7 +150,7 @@ def create(
151150

152151
def create_from_data(
153152
self, asset_id: str, data: Dict, *, confirm=False
154-
) -> NoneOnError[Event]:
153+
) -> Event:
155154
"""Create event
156155
157156
Creates event for given asset from data.
@@ -175,7 +174,7 @@ def create_from_data(
175174
if not confirm:
176175
return event
177176

178-
return wait_for_confirmation(self, event["identity"])
177+
return wait_for_confirmation(self, event["identity"]) # type: ignore The None return is unreachable
179178

180179
def read(self, identity: str) -> Event:
181180
"""Read event

0 commit comments

Comments
 (0)