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

Simplify the sync SocketBuffer, add type hints #2543

Merged

Conversation

kristjanvalur
Copy link
Contributor

@kristjanvalur kristjanvalur commented Jan 6, 2023

Pull Request check-list

Please make sure to review and check all of these items:

  • Does $ tox pass with this change (including linting)?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

This change removes two unnecessary state management variables from SocketBuffer,
simplifying the implementation and reducing the chance of programming error. The current
read position is maintained as simply the file_position of the underlying BytesIO buffer. Similarly,
the length of buffered data can be queried simply from the buffer by performing a seek().

Additionally, type hints are added to the SocketBuffer class

@kristjanvalur kristjanvalur force-pushed the kristjan/simplify-sync-socketbuffer branch 2 times, most recently from eb95823 to c53f4e6 Compare January 6, 2023 10:15
@kristjanvalur kristjanvalur force-pushed the kristjan/simplify-sync-socketbuffer branch from c53f4e6 to 548f104 Compare January 6, 2023 10:23
@codecov-commenter
Copy link

codecov-commenter commented Jan 6, 2023

Codecov Report

Base: 92.24% // Head: 92.21% // Decreases project coverage by -0.02% ⚠️

Coverage data is based on head (518da2f) compared to base (f46d7f3).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2543      +/-   ##
==========================================
- Coverage   92.24%   92.21%   -0.03%     
==========================================
  Files         115      115              
  Lines       29554    29551       -3     
==========================================
- Hits        27262    27251      -11     
- Misses       2292     2300       +8     
Impacted Files Coverage Δ
redis/connection.py 86.55% <100.00%> (-0.05%) ⬇️
tests/test_asyncio/test_search.py 98.29% <0.00%> (-0.35%) ⬇️
tests/test_cluster.py 96.79% <0.00%> (-0.34%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@kristjanvalur kristjanvalur marked this pull request as ready for review January 6, 2023 10:41
Copy link
Contributor

@shacharPash shacharPash left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@dvora-h dvora-h added the maintenance Maintenance (CI, Releases, etc) label Jan 22, 2023
@dvora-h dvora-h merged commit e39c7ba into redis:master Jan 22, 2023
@kristjanvalur kristjanvalur deleted the kristjan/simplify-sync-socketbuffer branch January 23, 2023 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Maintenance (CI, Releases, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants