Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More types #881

Closed
wants to merge 2 commits into from
Closed

Conversation

vladimir-kotikov
Copy link

Changes

Adds typings for helpers and errors modules

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> (e.g. 588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the PR
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: Fix issue with non-ascii contents in doctest text files.

Replace all mypy options with single strict = True which feels like a most reasonable level of typechecking to have (https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options) to make a baseplate for further typisation of the library.

Also rather than exclude kafka-python modules from mypy checks, add basic type stubs (generated with stubgen) for kafka-python's errors and structs modules.
Comment on lines +15 to +20
cafile: str = None,
capath: str = None,
cadata: str = None,
certfile: str = None,
keyfile: str = None,
password: str = None,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typing of these should look like cafile: Optional[str] = None


[mypy-aiokafka.util]
ignore_missing_imports = False
python_version = 3.7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python 3.7 has already been deprecated in the latest version

Comment on lines +18 to +19
replicas: list[int]
isr: list[int]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This form of typing is not available in Python 3.8 which is still supported.
It should be:

from typing import List, NamedTuple

...

    replicas: List[int]
    isr: List[int]

Comment on lines +86 to +88
# class FailedPayloadsError(KafkaError):
# payload: Incomplete
# def __init__(self, payload, *args) -> None: ...
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cant this just be deleted if it is commented out?

@ods
Copy link
Collaborator

ods commented Mar 16, 2024

Superseded by #932, #988, #989

@ods ods closed this Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants