Skip to content

Commit 1173f32

Browse files
committed
Fixed the recommended Qodana inspections
1 parent e9f4014 commit 1173f32

File tree

8 files changed

+38
-13
lines changed

8 files changed

+38
-13
lines changed

spec/check_session_service_spec.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
)
2121

2222

23+
# noinspection DuplicatedCode
2324
@pytest.fixture(scope="module")
2425
def base_url() -> str:
2526
"""Provides the base URL for tests, skipping if unset."""

spec/check_user_service_spec.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
)
1818

1919

20+
# noinspection DuplicatedCode
2021
@pytest.fixture(scope="module")
2122
def base_url() -> str:
2223
"""Provides the base URL for tests, skipping if unset."""

spec/conftest.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
# noinspection All
12
# mypy: allow-untyped-defs
23
from __future__ import annotations
34

45
import os
56
import platform
67
import re
8+
9+
# noinspection PyPep8Naming
710
import xml.etree.ElementTree as ET
811
from collections import defaultdict
912
from collections.abc import Callable
@@ -101,24 +104,25 @@ def write_captured_output(self, report: TestReport) -> None:
101104
content_all = self._prepare_content(content_log, " Captured Log ")
102105
if self.xml.logging in ["system-out", "out-err", "all"]:
103106
content_all += self._prepare_content(content_out, " Captured Out ")
104-
self._write_content(report, content_all, "system-out")
107+
self._write_content(content_all, "system-out")
105108
content_all = ""
106109
if self.xml.logging in ["system-err", "out-err", "all"]:
107110
content_all += self._prepare_content(content_err, " Captured Err ")
108-
self._write_content(report, content_all, "system-err")
111+
self._write_content(content_all, "system-err")
109112
content_all = ""
110113
if content_all:
111-
self._write_content(report, content_all, "system-out")
114+
self._write_content(content_all, "system-out")
112115

113-
def _prepare_content(self, content: str, header: str) -> str:
116+
@staticmethod
117+
def _prepare_content(content: str, header: str) -> str:
114118
return "\n".join([header.center(80, "-"), content, ""])
115119

116-
def _write_content(self, report: TestReport, content: str, jheader: str) -> None:
120+
def _write_content(self, content: str, jheader: str) -> None:
117121
tag = ET.Element(jheader)
118122
tag.text = bin_xml_escape(content)
119123
self.append(tag)
120124

121-
def append_pass(self, report: TestReport) -> None:
125+
def append_pass(self) -> None:
122126
self.add_stats("passed")
123127

124128
def append_failure(self, report: TestReport) -> None:
@@ -194,6 +198,7 @@ def append_skipped(self, report: TestReport) -> None:
194198
self.append(skipped)
195199
self.write_captured_output(report)
196200

201+
# noinspection PyAttributeOutsideInit
197202
def finalize(self) -> None:
198203
data = self.to_xml()
199204
# Preserve key attributes
@@ -244,6 +249,7 @@ def record_xml_attribute(request: FixtureRequest) -> Callable[[str, object], Non
244249
"""
245250

246251
# Declare noop
252+
# noinspection PyUnusedLocal
247253
def add_attr_noop(name: str, value: object) -> None:
248254
pass
249255

@@ -390,6 +396,7 @@ def _opentestcase(self, report: TestReport) -> _NodeReporter:
390396
reporter.record_testreport(report)
391397
return reporter
392398

399+
# noinspection DuplicatedCode
393400
def pytest_runtest_logreport(self, report: TestReport) -> None:
394401
"""Handle a setup/call/teardown report, generating the appropriate
395402
XML tags as necessary.
@@ -413,11 +420,10 @@ def pytest_runtest_logreport(self, report: TestReport) -> None:
413420
-> teardown node2
414421
-> teardown node1
415422
"""
416-
close_report = None
417423
if report.passed:
418424
if report.when == "call": # ignore setup/teardown
419425
reporter = self._opentestcase(report)
420-
reporter.append_pass(report)
426+
reporter.append_pass()
421427
elif report.failed:
422428
if report.when == "teardown":
423429
# The following vars are needed when xdist plugin is used.
@@ -518,6 +524,7 @@ def pytest_internalerror(self, excrepr: ExceptionRepr) -> None:
518524
# Record the exception as a standard JUnit <error> element
519525
reporter._add_simple("error", "internal error", str(excrepr))
520526

527+
# noinspection PyAttributeOutsideInit
521528
def pytest_sessionstart(self) -> None:
522529
"""
523530
Called at the very start of the pytest session.

test/auth/test_client_credentials_authenticator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class ClientCredentialsAuthenticatorTest(OAuthAuthenticatorTest):
1313
Extends the base OAuthAuthenticatorTest class.
1414
"""
1515

16+
# noinspection DuplicatedCode
1617
def test_refresh_token(self) -> None:
1718
time.sleep(20)
1819

test/auth/test_web_token_authenticator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class WebTokenAuthenticatorTest(OAuthAuthenticatorTest):
1717
Test for WebTokenAuthenticator to verify JWT token refresh functionality using the builder.
1818
"""
1919

20+
# noinspection DuplicatedCode
2021
def test_refresh_token_using_builder(self) -> None:
2122
time.sleep(20)
2223

zitadel_client/api_client.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import zitadel_client.rest_response
1818
from zitadel_client import rest
1919
from zitadel_client.api_response import ApiResponse
20+
21+
# noinspection PyPep8Naming
2022
from zitadel_client.api_response import T as ApiResponseT
2123
from zitadel_client.auth.no_auth_authenticator import NoAuthAuthenticator
2224
from zitadel_client.configuration import Configuration
@@ -85,6 +87,7 @@ def set_default_header(self, header_name: str, header_value: str) -> None:
8587

8688
_default = None
8789

90+
# noinspection PyUnusedLocal
8891
@no_type_check
8992
def param_serialize(
9093
self,
@@ -102,6 +105,7 @@ def param_serialize(
102105
_request_auth=None,
103106
) -> RequestSerialized:
104107
"""Builds the HTTP request params needed by the request.
108+
:param files:
105109
:param _host:
106110
:param auth_settings:
107111
:param method: Method to call.
@@ -319,6 +323,7 @@ def deserialize(self, response_text: str, response_type: str, content_type: Opti
319323
# fetch data from response object
320324
if content_type is None:
321325
try:
326+
# noinspection PyUnusedLocal
322327
data = json.loads(response_text)
323328
except ValueError:
324329
data = response_text
@@ -331,13 +336,14 @@ def deserialize(self, response_text: str, response_type: str, content_type: Opti
331336
data = ""
332337
else:
333338
data = json.loads(response_text)
334-
elif re.match(r"^text\/[a-z.+-]+\s*(;|$)", content_type, re.IGNORECASE):
339+
elif re.match(r"^text/[a-z.+-]+\s*(;|$)", content_type, re.IGNORECASE):
335340
data = response_text
336341
else:
337342
raise ApiException(status=0, reason="Unsupported content type: {0}".format(content_type))
338343

339344
return self.__deserialize(data, response_type)
340345

346+
# noinspection PyNestedDecorators
341347
@no_type_check
342348
@staticmethod
343349
def __deserialize(data, klass): # noqa C901 too complex
@@ -355,7 +361,6 @@ def __deserialize(data, klass): # noqa C901 too complex
355361
if klass.startswith("List["):
356362
m = re.match(r"List\[(.*)]", klass)
357363
assert m is not None, "Malformed List type definition"
358-
sub_kls = m.group(1)
359364
return [ApiClient.__deserialize(sub_data) for sub_data in data]
360365

361366
if klass.startswith("Dict["):
@@ -385,6 +390,7 @@ def __deserialize(data, klass): # noqa C901 too complex
385390
else:
386391
return ApiClient.__deserialize_model(data, klass)
387392

393+
# noinspection PyNestedDecorators
388394
@no_type_check
389395
@staticmethod
390396
def parameters_to_tuples(params, collection_formats):
@@ -416,6 +422,7 @@ def parameters_to_tuples(params, collection_formats):
416422
new_params.append((k, v))
417423
return new_params
418424

425+
# noinspection PyNestedDecorators
419426
@no_type_check
420427
@staticmethod
421428
def parameters_to_url_query(params, collection_formats): # noqa C901 too complex
@@ -502,6 +509,7 @@ def select_header_accept(accepts: List[str]) -> Optional[str]:
502509

503510
return accepts[0]
504511

512+
# noinspection PyNestedDecorators
505513
@no_type_check
506514
@staticmethod
507515
def select_header_content_type(content_types):
@@ -519,6 +527,7 @@ def select_header_content_type(content_types):
519527

520528
return content_types[0]
521529

530+
# noinspection PyNestedDecorators
522531
@no_type_check
523532
@staticmethod
524533
def __deserialize_file(response):
@@ -549,6 +558,7 @@ def __deserialize_file(response):
549558

550559
return path
551560

561+
# noinspection PyNestedDecorators
552562
@no_type_check
553563
@staticmethod
554564
def __deserialize_primitive(data, klass):
@@ -566,6 +576,7 @@ def __deserialize_primitive(data, klass):
566576
except TypeError:
567577
return data
568578

579+
# noinspection PyNestedDecorators
569580
@no_type_check
570581
@staticmethod
571582
def __deserialize_object(value):
@@ -575,6 +586,7 @@ def __deserialize_object(value):
575586
"""
576587
return value
577588

589+
# noinspection PyNestedDecorators
578590
@no_type_check
579591
@staticmethod
580592
def __deserialize_date(string):
@@ -590,6 +602,7 @@ def __deserialize_date(string):
590602
except ValueError as err:
591603
raise rest.ApiException(status=0, reason="Failed to parse `{0}` as date object".format(string)) from err
592604

605+
# noinspection PyNestedDecorators
593606
@no_type_check
594607
@staticmethod
595608
def __deserialize_datetime(string):
@@ -607,6 +620,7 @@ def __deserialize_datetime(string):
607620
except ValueError as err:
608621
raise rest.ApiException(status=0, reason=("Failed to parse `{0}` as datetime object".format(string))) from err
609622

623+
# noinspection PyNestedDecorators
610624
@no_type_check
611625
@staticmethod
612626
def __deserialize_enum(data, klass):
@@ -621,6 +635,7 @@ def __deserialize_enum(data, klass):
621635
except ValueError as err:
622636
raise rest.ApiException(status=0, reason=("Failed to parse `{0}` as `{1}`".format(data, klass))) from err
623637

638+
# noinspection PyNestedDecorators
624639
@no_type_check
625640
@staticmethod
626641
def __deserialize_model(data, klass: Any):
@@ -633,6 +648,7 @@ def __deserialize_model(data, klass: Any):
633648

634649
return klass.from_dict(data)
635650

651+
# noinspection PyNestedDecorators
636652
@no_type_check
637653
@classmethod
638654
def get_default(cls):

zitadel_client/configuration.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ def logger_file(self) -> Optional[str]:
105105
If the logger_file is None, then add stream handler and remove file
106106
handler. Otherwise, add file handler and remove stream handler.
107107
108-
:param value: The logger_file path.
109108
:type: str
110109
"""
111110
return self.__logger_file
@@ -133,7 +132,6 @@ def logger_file(self, value: Optional[str]) -> None:
133132
def debug(self) -> bool:
134133
"""Debug status
135134
136-
:param value: The debug status, True or False.
137135
:type: bool
138136
"""
139137
return self.__debug
@@ -166,7 +164,6 @@ def logger_format(self) -> str:
166164
167165
The logger_formatter will be updated when sets logger_format.
168166
169-
:param value: The format string.
170167
:type: str
171168
"""
172169
return self.__logger_format

zitadel_client/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def __init__(
119119
if self.reason is None:
120120
self.reason = http_resp.reason
121121
if self.body is None and http_resp.data is not None:
122+
# noinspection PyBroadException
122123
try:
123124
self.body = http_resp.data.decode("utf-8")
124125
except Exception: # noqa: S110

0 commit comments

Comments
 (0)