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

Changing return type of __iter__ to Iterator. #99

Merged

Conversation

johanols
Copy link
Contributor

@johanols johanols commented Nov 22, 2023

The previous return type of Iterable is incorrect as can be seen in this example:
https://docs.python.org/3/library/typing.html#nominal-vs-structural-subtyping

Also this documentation mentions that __iter__ returns the iterator object itself:
https://docs.python.org/3/library/stdtypes.html#iterator.__iter__

The incorrect Iterable type causes numerous of error when analyzed by a static type checker such as mypy. The switch to Iterator solves these issues.

Checklist

  • Added a docs/changes.rst entry

@johanols johanols marked this pull request as ready for review November 22, 2023 19:40
Copy link

codecov bot commented Nov 22, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (a6d0bbe) 0.00% compared to head (104ad9f) 0.00%.
Report is 2 commits behind head on main.

Files Patch % Lines
minimalkv/decorator.py 0.00% 4 Missing ⚠️
minimalkv/_key_value_store.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main     #99   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files         32      32           
  Lines       1993    1993           
=====================================
  Misses      1993    1993           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

The previous return type of `Iterable` is incorrect as can be seen in
this example:
https://docs.python.org/3/library/typing.html#nominal-vs-structural-subtyping

Also this documentation mentions that `__iter__` returns the iterator
object itself:
https://docs.python.org/3/library/stdtypes.html#iterator.__iter__

The incorrect `Iterable` type causes numerous of error when analyzed
by a static type checker such as `mypy`. The switch to `Iterator`
solves these issues.
@johanols johanols force-pushed the changing-iterator-typing branch from 9393b24 to 104ad9f Compare November 22, 2023 20:18
@xhochy xhochy merged commit 908efad into data-engineering-collective:main Nov 22, 2023
12 checks passed
@johanols johanols deleted the changing-iterator-typing branch November 22, 2023 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants