Skip to content

Commit 6d66ec6

Browse files
committed
fix some pylint errors/warnings
1 parent e532513 commit 6d66ec6

File tree

7 files changed

+19
-24
lines changed

7 files changed

+19
-24
lines changed

openeo/rest/auth/cli.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ def _interactive_choice(title: str, options: List[Tuple[str, str]], attempts=10)
193193
return options[int(entered) - 1][0]
194194
except Exception:
195195
pass
196-
else:
197-
raise CliToolException("Failed to pick valid option.")
196+
raise CliToolException("Failed to pick valid option.")
198197

199198

200199
def show_warning(message: str):

openeo/rest/auth/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def get(self, *keys, default=None) -> Union[dict, str, int]:
8888
"""Load JSON file and do deep get with given keys."""
8989
result = deep_get(self.load(), *keys, default=default)
9090
if isinstance(result, Exception) or (isinstance(result, type) and issubclass(result, Exception)):
91+
# pylint: disable=raising-bad-type
9192
raise result
9293
return result
9394

openeo/rest/auth/oidc.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def _decode(data: str) -> dict:
197197

198198
class OidcProviderInfo:
199199
"""OpenID Connect Provider information, as provided by an openEO back-end (endpoint `/credentials/oidc`)"""
200+
200201
def __init__(self, issuer: str = None, discovery_url: str = None, scopes: List[str] = None):
201202
if issuer is None and discovery_url is None:
202203
raise ValueError("At least `issuer` or `discovery_url` should be specified")
@@ -242,13 +243,17 @@ def __init__(self, client_info: OidcClientInfo):
242243
# TODO: check provider config (e.g. if grant type is supported)
243244

244245
@property
245-
def client_id(self):
246+
def client_id(self) -> str:
246247
return self._client_info.client_id
247248

248249
@property
249-
def client_secret(self):
250+
def client_secret(self) -> str:
250251
return self._client_info.client_secret
251252

253+
@property
254+
def provider_info(self) -> OidcProviderInfo:
255+
return self._client_info.provider
256+
252257
def get_tokens(self) -> AccessTokenResult:
253258
"""Get access_token and possibly id_token+refresh_token."""
254259
result = self._do_token_post_request(post_data=self._get_token_endpoint_post_data())
@@ -602,4 +607,3 @@ def get_tokens(self) -> AccessTokenResult:
602607
raise OidcException("Timeout exceeded {m:.1f}s while polling for access token at {u!r}".format(
603608
u=token_endpoint, m=self._max_poll_time
604609
))
605-

openeo/rest/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def _authenticate_oidc(
350350
_log.info("Obtained tokens: {t}".format(t=[k for k, v in tokens._asdict().items() if v]))
351351
if tokens.refresh_token and store_refresh_token:
352352
self._refresh_token_store.set_refresh_token(
353-
issuer=authenticator._client_info.provider.issuer,
353+
issuer=authenticator.provider_info.issuer,
354354
client_id=authenticator.client_id,
355355
refresh_token=tokens.refresh_token
356356
)

openeo/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def normalize(self, x: Any, *args) -> Union[str, None]:
114114
return None
115115
raise ValueError(x)
116116

117-
def parse_datetime(self, x: Union[str, None]) -> datetime:
117+
def parse_datetime(self, x: Union[str, None]) -> dt.datetime:
118118
if isinstance(x, str):
119119
return dt.datetime.strptime(x, '%Y-%m-%dT%H:%M:%SZ')
120120
elif x is None and self._propagate_none:

openeo/vectorcube.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,6 @@ def process(self, process_id: str, args: dict = None, metadata: CollectionMetada
5656
arguments=args, **kwargs
5757
), metadata=metadata)
5858

59-
def process(self,pg:PGNode) -> 'VectorCube':
60-
"""
61-
Generic helper to create a new DataCube by applying a process.
62-
63-
:param pg: A process graph node, constructed using other helpers.
64-
:return: new DataCube instance
65-
"""
66-
return self.process_with_node(pg)
67-
68-
6959
def process_with_node(self, pg: PGNode, metadata: CollectionMetadata = None) -> 'VectorCube':
7060
"""
7161
Generic helper to create a new DataCube by applying a process (given as process graph node)

tests/rest/datacube/test_vectorcube.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
from openeo.rest.connection import Connection
44
import openeo
55

6+
67
def test_raster_to_vector(con100):
78
img = con100.load_collection("S2")
89
vector_cube = img.raster_to_vector()
9-
vector_cube_tranformed = vector_cube.process(openeo.UDF("python source code","Python"))
10+
vector_cube_tranformed = vector_cube.process_with_node(openeo.UDF("python source code", "Python"))
1011

1112
assert vector_cube_tranformed.graph == {
1213
'loadcollection1': {
@@ -26,9 +27,9 @@ def test_raster_to_vector(con100):
2627
'runudf1': {
2728
'arguments': {
2829
'data': {'from_node': 'rastertovector1'},
29-
'runtime': 'Python',
30-
'udf': 'python source code'
31-
},
32-
'process_id': 'run_udf',
33-
'result': True}
34-
}
30+
'runtime': 'Python',
31+
'udf': 'python source code'
32+
},
33+
'process_id': 'run_udf',
34+
'result': True}
35+
}

0 commit comments

Comments
 (0)