Skip to content

Commit

Permalink
chore: Remove pylint comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rumpelsepp committed Feb 22, 2023
1 parent ec694d6 commit 3ab09fa
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 47 deletions.
4 changes: 1 addition & 3 deletions src/cursed_hr/cursed_hr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
# SPDX-License-Identifier: Apache-2.0

# pylint: disable=too-many-lines,eval-used

from __future__ import annotations

import curses
Expand Down Expand Up @@ -261,7 +259,7 @@ def uncompressed_file(self) -> BinaryIO:
)
self.window.refresh()

file = tempfile.TemporaryFile() # pylint: disable=consider-using-with
file = tempfile.TemporaryFile()

match self.in_file.suffix:
case ".zst":
Expand Down
14 changes: 5 additions & 9 deletions src/gallia/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ def _get_cli_defaults(parser: argparse.ArgumentParser, out: dict[str, Any]) -> N
if isinstance(
action,
(
argparse._StoreAction, # pylint: disable=protected-access
argparse._StoreTrueAction, # pylint: disable=protected-access
argparse._StoreFalseAction, # pylint: disable=protected-access
argparse._StoreAction,
argparse._StoreTrueAction,
argparse._StoreFalseAction,
argparse.BooleanOptionalAction,
),
):
Expand Down Expand Up @@ -241,9 +241,7 @@ def _get_cli_defaults(parser: argparse.ArgumentParser, out: dict[str, Any]) -> N
d[keys[-1]] = value
break

if isinstance(
action, argparse._SubParsersAction # pylint: disable=protected-access
):
if isinstance(action, argparse._SubParsersAction):
for subparser in action.__dict__["choices"].values():
_get_cli_defaults(subparser, out)

Expand All @@ -256,9 +254,7 @@ def get_cli_defaults(parser: argparse.ArgumentParser) -> dict[str, Any]:

def _get_command_tree(parser: argparse.ArgumentParser, out: dict[str, Any]) -> None:
for action in parser.__dict__["_actions"]:
if isinstance(
action, argparse._SubParsersAction # pylint: disable=protected-access
):
if isinstance(action, argparse._SubParsersAction):
for cmd, subparser in action.__dict__["choices"].items():
out[cmd] = {}
d = out[cmd]
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/commands/scan/uds/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def main(self, args: Namespace) -> None:
# TODO: Unified shortened output necessary here
self.logger.info(f"skipping identifiers {reprlib.repr(args.skip)}")

for session in sessions: # pylint: disable=too-many-nested-blocks
for session in sessions:
self.logger.notice(f"Switching to session {g_repr(session)}")
resp: UDSResponse = await self.ecu.set_session(session)
if isinstance(resp, NegativeResponse):
Expand Down
1 change: 0 additions & 1 deletion src/gallia/commands/scan/uds/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ async def main(self, args: Namespace) -> None:
sessions = list(range(1, 0x80))
depth = 0

# pylint: disable=too-many-nested-blocks
while (args.depth is None or depth < args.depth) and len(found[depth]) > 0:
depth += 1

Expand Down
2 changes: 0 additions & 2 deletions src/gallia/commands/script/vecu.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
# SPDX-License-Identifier: Apache-2.0

# pylint: disable=eval-used

import json
import random
import sys
Expand Down
10 changes: 5 additions & 5 deletions src/gallia/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def set_color_mode(mode: ColorMode, stream: TextIO = sys.stderr) -> None:
:param mode: The available options are described in :class:`ColorMode`.
:param stream: Used as a reference for :attr:`ColorMode.AUTO`.
"""
global _COLORS_ENABLED # pylint: disable=global-statement
global _COLORS_ENABLED
match mode:
case ColorMode.ALWAYS:
_COLORS_ENABLED = True
Expand Down Expand Up @@ -87,7 +87,7 @@ def _add_logging_level(level_name: str, level_num: int) -> None:
# http://stackoverflow.com/a/13638084/2988730
def for_level(self, message, *args, **kwargs): # type: ignore
if self.isEnabledFor(level_num):
self._log( # pylint: disable=protected-access
self._log(
level_num,
message,
args,
Expand Down Expand Up @@ -489,9 +489,9 @@ def parse_json(cls, data: bytes) -> PenlogRecord:
tags=record.tags,
line=record.line,
stacktrace=record.stacktrace,
_python_level_no=record._python_level_no, # pylint: disable=protected-access
_python_level_name=record._python_level_name, # pylint: disable=protected-access
_python_func_name=record._python_func_name, # pylint: disable=protected-access
_python_level_no=record._python_level_no,
_python_level_name=record._python_level_name,
_python_func_name=record._python_func_name,
)
raise ValueError("unknown record version")

Expand Down
14 changes: 2 additions & 12 deletions src/gallia/services/uds/core/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
# SPDX-License-Identifier: Apache-2.0

# pylint: disable=too-many-lines, useless-super-delegation

from __future__ import annotations

import inspect
Expand Down Expand Up @@ -125,7 +123,6 @@ def parse_dynamic(pdu: bytes) -> UDSRequest:
try:
logger.trace("Dynamically parsing request")
logger.trace(f" - Got PDU {pdu.hex()}")
# pylint: disable=protected-access
request_service = UDSService._SERVICES[UDSIsoServices(pdu[0])]

logger.trace(f" - Inferred service {request_service.__name__}")
Expand All @@ -135,7 +132,6 @@ def parse_dynamic(pdu: bytes) -> UDSRequest:
return request_type.from_pdu(pdu)
if issubclass(request_service, SpecializedSubFunctionService):
logger.trace(" - Trying to infer subFunction")
# pylint: disable=protected-access
request_sub_function = request_service._sub_function_type(pdu)
logger.trace(f" - Inferred subFunction {request_sub_function.__name__}")
assert (request_type := request_sub_function.Request) is not None
Expand Down Expand Up @@ -227,7 +223,6 @@ def parse_dynamic(pdu: bytes) -> UDSResponse:
logger.trace(f" - Got PDU {pdu.hex()}")

try:
# pylint: disable=protected-access
response_service = UDSService._SERVICES[UDSIsoServices(pdu[0] - 0x40)]
except Exception:
logger.trace(
Expand All @@ -247,7 +242,6 @@ def parse_dynamic(pdu: bytes) -> UDSResponse:

logger.trace(" - Trying to infer subfunction")
try:
# pylint: disable=protected-access
response_sub_function = response_service._sub_function_type(pdu)
except ValueError as e:
logger.trace(f" - Falling back to raw response because {str(e)}")
Expand Down Expand Up @@ -506,9 +500,7 @@ class SpecializedSubFunctionResponse(
):
SUB_FUNCTION_ID: int

def __init_subclass__(
cls, /, sub_function_id: int, **kwargs: Any # pylint: disable=arguments-differ
) -> None:
def __init_subclass__(cls, /, sub_function_id: int, **kwargs: Any) -> None:
super().__init_subclass__(**kwargs)

cls.SUB_FUNCTION_ID = sub_function_id
Expand Down Expand Up @@ -541,9 +533,7 @@ class SpecializedSubFunctionRequest(
):
SUB_FUNCTION_ID: int

def __init_subclass__(
cls, /, sub_function_id: int, **kwargs: Any # pylint: disable=arguments-differ
) -> None:
def __init_subclass__(cls, /, sub_function_id: int, **kwargs: Any) -> None:
super().__init_subclass__(**kwargs)

cls.SUB_FUNCTION_ID = sub_function_id
Expand Down
12 changes: 2 additions & 10 deletions src/gallia/services/uds/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ def default_response_if_service_not_supported(

def _is_sub_function_service(self, service_id: int) -> bool:
try:
service_class = (
service.UDSService._SERVICES[ # pylint: disable=protected-access
UDSIsoServices(service_id)
]
)
service_class = service.UDSService._SERVICES[UDSIsoServices(service_id)]

return (
issubclass(service_class, service.SpecializedSubFunctionService)
Expand Down Expand Up @@ -233,7 +229,6 @@ async def setup(self) -> None:
async def teardown(self) -> None:
pass

# pylint: disable=too-many-return-statements
async def respond_without_state_change(
self, request: service.UDSRequest
) -> service.UDSResponse | None:
Expand Down Expand Up @@ -510,7 +505,6 @@ def stateful_rng(self, *args: Any) -> RNG:
+ "|".join(str(arg) for arg in args)
)

# pylint: disable=too-many-return-statements
async def respond_after_default(
self, request: service.UDSRequest
) -> service.UDSResponse | None:
Expand All @@ -519,9 +513,7 @@ async def respond_after_default(
# Furthermore, it is assumed that the request is a valid request for that particular service and sub-function
if isinstance(request, service.ECUResetRequest):
return self.ecu_reset(request)
if isinstance(
request, service._SecurityAccessRequest # pylint: disable=protected-access
):
if isinstance(request, service._SecurityAccessRequest):
return self.security_access(request)
if isinstance(request, service.RoutineControlRequest):
return self.routine_control(request)
Expand Down
2 changes: 1 addition & 1 deletion src/opennetzteil/devices/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class HTTPNetzteil(BaseNetzteil):
URL_PREFIX = "/_netzteil/api/"
PRODUCT_ID = "opennetzteil"

def __init__( # pylint: disable=super-init-not-called
def __init__(
self,
session: aiohttp.ClientSession,
host: str,
Expand Down
3 changes: 0 additions & 3 deletions tests/test_transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#
# SPDX-License-Identifier: Apache-2.0

# pylint: disable=redefined-outer-name
# pylint: disable=attribute-defined-outside-init

import asyncio
import binascii
from collections.abc import AsyncIterator, Callable
Expand Down

0 comments on commit 3ab09fa

Please sign in to comment.