-
Notifications
You must be signed in to change notification settings - Fork 233
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
add typing to aiokafka/record/* #1001
Conversation
Many differences between python and cython implementations.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
aiokafka/record/_protocols.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you describe the idea with protocols? I'd rather try to avoid them, as they break code navigation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What alternatives? I did attempt to use Union instead of Protocol (last commit) - it's hard for mypy:
tests/record/test_records.py:70: error: "object" has no attribute "value" [attr-defined]
tests/record/test_records.py:71: error: "object" has no attribute "key" [attr-defined]
tests/record/test_records.py:72: error: "object" has no attribute "timestamp" [attr-defined]
tests/record/test_records.py:73: error: "object" has no attribute "timestamp_type" [attr-defined]
tests/record/test_records.py:74: error: "object" has no attribute "checksum" [attr-defined]
tests/record/test_records.py:75: error: "object" has no attribute "headers" [attr-defined]
tests/record/test_records.py:96: error: "object" has no attribute "value" [attr-defined]
tests/record/test_records.py:97: error: "object" has no attribute "key" [attr-defined]
tests/record/test_records.py:98: error: "object" has no attribute "timestamp" [attr-defined]
tests/record/test_records.py:99: error: "object" has no attribute "timestamp_type" [attr-defined]
tests/record/test_records.py:100: error: "object" has no attribute "checksum" [attr-defined]
tests/record/test_records.py:124: error: "object" has no attribute "value" [attr-defined]
tests/record/test_records.py:125: error: "object" has no attribute "key" [attr-defined]
tests/record/test_records.py:126: error: "object" has no attribute "timestamp" [attr-defined]
tests/record/test_records.py:127: error: "object" has no attribute "timestamp_type" [attr-defined]
tests/record/test_records.py:128: error: "object" has no attribute "checksum" [attr-defined]
tests/record/test_legacy.py:48: error: "object" has no attribute "offset" [attr-defined]
tests/record/test_legacy.py:49: error: "object" has no attribute "timestamp" [attr-defined]
tests/record/test_legacy.py:50: error: "object" has no attribute "timestamp_type" [attr-defined]
tests/record/test_legacy.py:51: error: "object" has no attribute "key" [attr-defined]
tests/record/test_legacy.py:52: error: "object" has no attribute "value" [attr-defined]
tests/record/test_legacy.py:53: error: "object" has no attribute "checksum" [attr-defined]
tests/record/test_legacy.py:91: error: "object" has no attribute "offset" [attr-defined]
tests/record/test_legacy.py:92: error: "object" has no attribute "timestamp" [attr-defined]
tests/record/test_legacy.py:93: error: "object" has no attribute "timestamp_type" [attr-defined]
tests/record/test_legacy.py:94: error: "object" has no attribute "key" [attr-defined]
tests/record/test_legacy.py:95: error: "object" has no attribute "value" [attr-defined]
tests/record/test_legacy.py:96: error: "object" has no attribute "checksum" [attr-defined]
tests/record/test_legacy.py:293: error: "object" has no attribute "offset" [attr-defined]
tests/record/test_legacy.py:294: error: "object" has no attribute "timestamp" [attr-defined]
tests/record/test_legacy.py:295: error: "object" has no attribute "timestamp_type" [attr-defined]
tests/record/test_legacy.py:314: error: "object" has no attribute "offset" [attr-defined]
tests/record/test_legacy.py:315: error: "object" has no attribute "timestamp" [attr-defined]
tests/record/test_legacy.py:316: error: "object" has no attribute "timestamp_type" [attr-defined]
tests/record/test_legacy.py:317: error: "object" has no attribute "key" [attr-defined]
tests/record/test_legacy.py:318: error: "object" has no attribute "value" [attr-defined]
tests/record/test_legacy.py:319: error: "object" has no attribute "checksum" [attr-defined]
tests/record/test_default_records.py:67: error: "object" has no attribute "offset" [attr-defined]
tests/record/test_default_records.py:68: error: "object" has no attribute "timestamp" [attr-defined]
tests/record/test_default_records.py:69: error: "object" has no attribute "key" [attr-defined]
tests/record/test_default_records.py:70: error: "object" has no attribute "value" [attr-defined]
tests/record/test_default_records.py:71: error: "object" has no attribute "headers" [attr-defined]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checked for the first set of errors. Looks like mypy fails to infer type in such a complicated chain. But changing recs = tuple(batch)
(which doesn't make sense anyway) to a simple unpack [rec] = batch
solves the problem. Not sure this a right way though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok for this case but we should use cast in a loop over union type, see python/mypy#8586
This reverts commit 7fa1efa.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1001 +/- ##
==========================================
- Coverage 95.36% 95.04% -0.32%
==========================================
Files 112 114 +2
Lines 16751 16917 +166
Branches 2694 2757 +63
==========================================
+ Hits 15974 16079 +105
- Misses 489 493 +4
- Partials 288 345 +57
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Changes
Fixes #
Checklist
CHANGES
folder<issue_id>.<type>
(e.g.588.bugfix
)issue_id
change it to the pr id after creating the PR.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.Fix issue with non-ascii contents in doctest text files.