Skip to content

Commit

Permalink
chore: remove pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaakola-aiven committed Jan 8, 2025
1 parent bdb5f5c commit 40ace39
Show file tree
Hide file tree
Showing 53 changed files with 160 additions and 246 deletions.
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ repos:
# https://github.com/hadolint/hadolint/issues/497
- --ignore=DL3042

- repo: https://github.com/PyCQA/pylint
# Note: pre-commit autoupdate changes to an alpha version. Instead, manually find the
# latest stable version here: https://github.com/pylint-dev/pylint/releases
rev: v3.2.6
hooks:
- id: pylint

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.8.6
Expand Down
43 changes: 0 additions & 43 deletions .pylintrc

This file was deleted.

3 changes: 0 additions & 3 deletions container/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,7 @@ services:
- ../tests:/opt/karapace/tests
- ../pytest.ini:/opt/karapace/pytest.ini
- ../mypy.ini:/opt/karapace/mypy.ini
- ../.flake8:/opt/karapace/.flake8
- ../.isort.cfg:/opt/karapace/.isort.cfg
- ../.pre-commit-config.yaml:/opt/karapace/.pre-commit-config.yaml
- ../.pylintrc:/opt/karapace/.pylintrc
- ../.coveragerc:/opt/karapace/.coveragerc
- ../.coverage.3.10:/opt/karapace/coverage/.coverage.3.10
- ../.coverage.3.11:/opt/karapace/coverage/.coverage.3.11
Expand Down
2 changes: 1 addition & 1 deletion src/karapace/anonymize_schemas/anonymize_avro.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def anonymize_element(m: re.Match) -> str:


def anonymize(input_schema: Schema) -> Schema:
if not input_schema: # pylint: disable=no-else-return
if not input_schema:
return input_schema
elif isinstance(input_schema, str):
if input_schema in ALL_TYPES:
Expand Down
5 changes: 2 additions & 3 deletions src/karapace/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ class AuthenticatorAndAuthorizer(AuthenticateProtocol, AuthorizeProtocol):

async def close(self) -> None: ...

async def start(self, stats: StatsClient) -> None: # pylint: disable=unused-argument
...
async def start(self, stats: StatsClient) -> None: ...


class NoAuthAndAuthz(AuthenticatorAndAuthorizer):
Expand Down Expand Up @@ -237,7 +236,7 @@ async def _refresh_authfile() -> None:
except asyncio.CancelledError:
log.info("Closing schema registry ACL refresh task")
return
except Exception as ex: # pylint: disable=broad-except
except Exception as ex:
log.exception("Schema registry auth file could not be loaded")
stats.unexpected_exception(ex=ex, where="schema_registry_authfile_reloader")
return
Expand Down
2 changes: 1 addition & 1 deletion src/karapace/avro_dataclasses/introspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _field_type_array(field: Field, origin: type, type_: object) -> AvroType:
sequence_types: Final = frozenset({tuple, list, Sequence})


def _field_type(field: Field, type_: object) -> AvroType: # pylint: disable=too-many-return-statements
def _field_type(field: Field, type_: object) -> AvroType:
# Handle primitives.
if type_ is bool:
return "boolean"
Expand Down
2 changes: 0 additions & 2 deletions src/karapace/avro_dataclasses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ def parse(value: object) -> object:


def from_avro_value(type_: object) -> Parser | None:
# pylint: disable=too-many-return-statements

if isinstance(type_, type):
if is_dataclass(type_):
return partial(from_avro_dict, type_)
Expand Down
2 changes: 1 addition & 1 deletion src/karapace/backup/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def before_sleep(it: RetryCallState) -> None:
result = f"failed ({outcome.exception()})"
else:
result = f"returned {outcome.result()!r}"
LOG.info(f"{description} {result}, retrying... (Ctrl+C to abort)") # pylint: disable=logging-fstring-interpolation
LOG.info(f"{description} {result}, retrying... (Ctrl+C to abort)")

return before_sleep

Expand Down
2 changes: 0 additions & 2 deletions src/karapace/backup/backends/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ def _noop_context(path: T) -> Iterator[T]:
class BackupWriter(Generic[B, F], abc.ABC):
"""Common interface and base class for all backup writer backends."""

# pylint: disable=unused-argument

P = TypeVar("P", bound="StdOut | Path")

def prepare_location(
Expand Down
2 changes: 1 addition & 1 deletion src/karapace/backup/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def main() -> None:
# TODO: This specific treatment of StaleConsumerError looks quite misplaced
# here, and should probably be pushed down into the (internal) API layer.
except StaleConsumerError as e:
logger.error( # pylint: disable=logging-fstring-interpolation
logger.error(
f"The Kafka consumer did not receive any records for partition {e.topic_partition.partition} of topic "
f"{e.topic_partition.topic!r} "
f"within the poll timeout ({e.poll_timeout} seconds) while trying to reach offset {e.end_offset:,} "
Expand Down
2 changes: 1 addition & 1 deletion src/karapace/compatibility/jsonschema/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ def compatibility_subschemas(
location: list[str],
) -> SchemaCompatibilityResult:
# https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.10
# pylint: disable=too-many-return-statements

reader_subschemas_and_type = maybe_get_subschemas_and_type(reader_schema)
writer_subschemas_and_type = maybe_get_subschemas_and_type(writer_schema)

Expand Down
2 changes: 1 addition & 1 deletion src/karapace/compatibility/jsonschema/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def gt(left: int | None, right: int | None) -> bool:


def lt(left: int | None, right: int | None) -> bool:
return gt(right, left) # pylint: disable=arguments-out-of-order
return gt(right, left)


def ne(writer: T | None, reader: T | None) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion src/karapace/coordinator/schema_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ async def ensure_coordinator_known(self) -> None:
async def _coordination_routine(self) -> None:
try:
await self.__coordination_routine()
except asyncio.CancelledError: # pylint: disable=try-except-raise
except asyncio.CancelledError:
raise
except Exception as exc:
LOG.error("Unexpected error in coordinator routine", exc_info=True)
Expand Down
17 changes: 7 additions & 10 deletions src/karapace/kafka/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ def translate_from_kafkaerror(error: KafkaError) -> Exception:
"""
code = error.code()
if code in (
KafkaError._NOENT, # pylint: disable=protected-access
KafkaError._UNKNOWN_PARTITION, # pylint: disable=protected-access
KafkaError._UNKNOWN_TOPIC, # pylint: disable=protected-access
KafkaError._NOENT,
KafkaError._UNKNOWN_PARTITION,
KafkaError._UNKNOWN_TOPIC,
):
return UnknownTopicOrPartitionError()
if code == KafkaError._TIMED_OUT: # pylint: disable=protected-access
if code == KafkaError._TIMED_OUT:
return KafkaTimeoutError()
if code == KafkaError._STATE: # pylint: disable=protected-access
if code == KafkaError._STATE:
return IllegalStateError()
if code == KafkaError._RESOLVE: # pylint: disable=protected-access
if code == KafkaError._RESOLVE:
return KafkaUnavailableError()

return for_code(code)
Expand Down Expand Up @@ -207,10 +207,7 @@ def _verify_connection(self) -> None:
# to the callback function defined in the `error_cb` config
self._activate_callbacks()
self.log.info("Could not establish connection due to errors: %s", self._errors)
if any(
error.code() == KafkaError._AUTHENTICATION
for error in self._errors # pylint: disable=protected-access
):
if any(error.code() == KafkaError._AUTHENTICATION for error in self._errors):
raise AuthenticationFailedError() from exc
continue
else:
Expand Down
2 changes: 1 addition & 1 deletion src/karapace/karapace_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def main(
try:
prometheus.setup_metrics(app=app)
app.run() # `close` will be called by the callback `close_by_app` set by `KarapaceBase`
except Exception as ex: # pylint: disable-broad-except
except Exception as ex:
app.stats.unexpected_exception(ex=ex, where="karapace")
raise
return 0
Expand Down
2 changes: 1 addition & 1 deletion src/karapace/protobuf/encoding_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def read_indexes(bio: BytesIO) -> list[int]:
size: int = read_varint(bio)
except EOFError:
# TODO: change exception
# pylint: disable=raise-missing-from

raise IllegalArgumentException("problem with reading binary data")
if size == 0:
return [0]
Expand Down
7 changes: 3 additions & 4 deletions src/karapace/protobuf/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def find_message_name(schema: ProtobufSchema, indexes: Iterable[int]) -> str:
try:
message = types[index]
except IndexError:
# pylint: disable=raise-missing-from
raise IllegalArgumentException(f"Invalid message indexes: {indexes}")

if message and isinstance(message, MessageElement):
Expand Down Expand Up @@ -185,7 +184,7 @@ def reader_process(
reader_queue.put(protobuf_to_dict(read_data(config, writer_schema, reader_schema, bio), True))
# Reading happens in the forked process, catch is broad so exception will get communicated
# back to calling process.
except BaseException as base_exception: # pylint: disable=broad-except
except BaseException as base_exception:
reader_queue.put(base_exception)


Expand Down Expand Up @@ -260,13 +259,13 @@ def writer_process(
writer_queue.put(result)
# Writing happens in the forked process, catch is broad so exception will get communicated
# back to calling process.
except Exception as bare_exception: # pylint: disable=broad-exception-caught
except Exception as bare_exception:
try:
raise ProtobufTypeException(writer_schema, datum) from bare_exception
except ProtobufTypeException as protobuf_exception:
writer_queue.put(protobuf_exception)
raise protobuf_exception
except BaseException as base_exception: # pylint: disable=broad-exception-caught
except BaseException as base_exception:
writer_queue.put(base_exception)


Expand Down
2 changes: 1 addition & 1 deletion src/karapace/protobuf/known_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def static_init(cls: Any) -> object:
return cls


@static_init # pylint: disable=used-before-assignment
@static_init
class KnownDependency:
index: dict = dict()
index_simple: dict = dict()
Expand Down
2 changes: 1 addition & 1 deletion src/karapace/protobuf/message_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def to_schema(self) -> str:
return "".join(result)

def compare(self, other: TypeElement, result: CompareResult, types: CompareTypes) -> None:
from karapace.protobuf.compare_type_lists import compare_type_lists # pylint: disable=cyclic-import
from karapace.protobuf.compare_type_lists import compare_type_lists

if not isinstance(other, MessageElement):
result.add_modification(Modification.TYPE_ALTER)
Expand Down
5 changes: 2 additions & 3 deletions src/karapace/protobuf/proto_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ def read_declaration(
| GroupElement
| FieldElement
) = None
# pylint no-else-return
if label == "package" and context.permits_package():
self.package_name = self.reader.read_name()
self.prefix = f"{self.package_name}."
Expand Down Expand Up @@ -504,7 +503,7 @@ def read_reserved(self, location: Location, documentation: str) -> ReservedEleme
values.append(KotlinRange(tag_start, tag_end))

ch = self.reader.read_char()
# pylint: disable=no-else-break

if ch == ";":
break
elif ch == ",":
Expand Down Expand Up @@ -543,7 +542,7 @@ def read_extensions(self, location: Location, documentation: str) -> ExtensionsE
values.append(KotlinRange(start, end))

ch = self.reader.read_char()
# pylint: disable=no-else-break

if ch == ";":
break
elif ch == ",":
Expand Down
2 changes: 1 addition & 1 deletion src/karapace/protobuf/proto_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def static_init(cls) -> object:
return cls


@static_init # pylint: disable=used-before-assignment
@static_init
class ProtoType:
@property
def simple_name(self) -> str:
Expand Down
7 changes: 1 addition & 6 deletions src/karapace/protobuf/protobuf_to_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ def timestamp_to_datetime(ts):
return dt


# pylint: enable=no-member

EXTENSION_CONTAINER = "___X"

TYPE_CALLABLE_MAP = MappingProxyType(
Expand Down Expand Up @@ -209,14 +207,12 @@ def _get_field_mapping(pb, dict_value, strict):
try:
ext_num = int(ext_num)
except ValueError:
# pylint: disable=raise-missing-from
raise ValueError("Extension keys must be integers.")
# pylint: disable=protected-access

if ext_num not in pb._extensions_by_number:
if strict:
raise KeyError(f"{pb} does not have a extension with number {key}. Perhaps you forgot to import it?")
continue
# pylint: disable=protected-access

ext_field = pb._extensions_by_number[ext_num]
# noinspection PyUnusedLocal
Expand Down Expand Up @@ -310,7 +306,6 @@ def _string_to_enum(field, input_value, strict=False):
input_value = field.enum_type.values_by_name[input_value].number
except KeyError:
if strict:
# pylint: disable=raise-missing-from
raise KeyError(f"`{input_value}` is not a valid value for field `{field.name}`")
return _string_to_enum(field, input_value.upper(), strict=True)
return input_value
Expand Down
1 change: 0 additions & 1 deletion src/karapace/protobuf/syntax_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ def read_comment(self) -> str:
buffer = []
start_of_line = True
while self.pos + 1 < len(self.data):
# pylint: disable=no-else-break
c: str = self.data[self.pos]
if c == "*" and self.data[self.pos + 1] == "/":
self.pos += 2
Expand Down
Loading

0 comments on commit 40ace39

Please sign in to comment.