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

♻️ Delete size arg from StreamReader.feed_data #7265

Closed
wants to merge 31 commits into from
Closed

♻️ Delete size arg from StreamReader.feed_data #7265

wants to merge 31 commits into from

Conversation

DavidRomanovizc
Copy link
Contributor

@DavidRomanovizc DavidRomanovizc commented Apr 29, 2023

What do these changes do?

Removed the unused size parameter from the feed_data method to simplify the code and usage of the method.

Are there changes in behavior for the user?

If the user is using the feed_data method without the size parameter, there should be no changes in the behavior of the method for them. However, if the size parameter was used, there may be changes in the behavior of the method.

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (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."

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Apr 29, 2023
CHANGES/7265.feature Outdated Show resolved Hide resolved
aiohttp/streams.py Outdated Show resolved Hide resolved
aiohttp/http_parser.py Outdated Show resolved Hide resolved
aiohttp/http_parser.py Outdated Show resolved Hide resolved
@Dreamsorcerer Dreamsorcerer added the backport:skip Skip backport bot label Apr 29, 2023
DavidRomanovizc and others added 2 commits April 29, 2023 21:11
Co-authored-by: Sam Bull <aa6bs0@sambull.org>
@webknjaz
Copy link
Member

It wouldn't hurt to write actual full commit messages and PR titles. When I get a notification about "something happened with todo" or "some improvement", those don't look important enough to compell me not to skip the notifications. I have hundreds of those and will choose things that look meaningful and related to what I care about.

@DavidRomanovizc DavidRomanovizc changed the title Executed TODO, deleted the size parameter Executed TODO in StreamReader. Deleted the size parameter in feed_data method Apr 29, 2023
@webknjaz webknjaz changed the title Executed TODO in StreamReader. Deleted the size parameter in feed_data method Delete the size parameter from StreamReader.feed_data Apr 30, 2023
@webknjaz webknjaz changed the title Delete the size parameter from StreamReader.feed_data Delete size arg from StreamReader.feed_data Apr 30, 2023
@DavidRomanovizc
Copy link
Contributor Author

CI also crashes due to the missing of the size arg and for some other reasons, however I do not know how to fix that. And I would really appreciate it if you could take care of it. Thanks!

@Dreamsorcerer
Copy link
Member

Error seems pretty clear:
aiohttp/http_parser.py:729: error: Missing positional argument "size" in call to "feed_data" of "DeflateBuffer" [call-arg]

Method is defined at: https://github.com/DavidRomanovizc/aiohttp/blob/master/aiohttp/http_parser.py#L854

@Dreamsorcerer
Copy link
Member

Presumably, the same changes can be made, using len() instead of the size parameter.

tests/test_streams.py Outdated Show resolved Hide resolved
@DavidRomanovizc DavidRomanovizc changed the title Delete size arg from StreamReader.feed_data ♻️ Delete size arg from StreamReader.feed_data May 7, 2023
@codecov
Copy link

codecov bot commented May 7, 2023

Codecov Report

Merging #7265 (d6157da) into master (fde452d) will decrease coverage by 0.02%.
The diff coverage is 96.93%.

❗ Current head d6157da differs from pull request most recent head ba50f98. Consider uploading reports for the commit ba50f98 to get more accurate results

@@            Coverage Diff             @@
##           master    #7265      +/-   ##
==========================================
- Coverage   97.30%   97.29%   -0.02%     
==========================================
  Files         106      107       +1     
  Lines       31456    31481      +25     
  Branches     3940     3928      -12     
==========================================
+ Hits        30608    30629      +21     
- Misses        644      647       +3     
- Partials      204      205       +1     
Flag Coverage Δ
CI-GHA 97.20% <96.93%> (-0.02%) ⬇️
OS-Linux 96.85% <96.93%> (-0.02%) ⬇️
OS-Windows 95.32% <96.90%> (-0.02%) ⬇️
OS-macOS 96.45% <96.93%> (-0.02%) ⬇️
Py-3.10.11 96.97% <96.93%> (-0.02%) ⬇️
Py-3.11.0 96.40% <96.93%> (-0.02%) ⬇️
Py-3.7.16 96.68% <96.93%> (-0.02%) ⬇️
Py-3.7.9 95.19% <96.90%> (-0.02%) ⬇️
Py-3.8.10 95.11% <96.90%> (-0.02%) ⬇️
Py-3.8.16 96.59% <96.93%> (-0.02%) ⬇️
Py-3.9.13 95.11% <96.90%> (-0.02%) ⬇️
Py-3.9.16 96.62% <96.93%> (-0.02%) ⬇️
Py-pypy7.3.11 94.11% <96.93%> (+<0.01%) ⬆️
VM-macos 96.45% <96.93%> (-0.02%) ⬇️
VM-ubuntu 96.85% <96.93%> (-0.02%) ⬇️
VM-windows 95.32% <96.90%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
tests/test_client_ws.py 100.00% <ø> (ø)
aiohttp/streams.py 96.97% <83.33%> (-0.49%) ⬇️
aiohttp/http_parser.py 98.24% <93.33%> (-0.04%) ⬇️
aiohttp/client_proto.py 96.73% <100.00%> (ø)
aiohttp/http_websocket.py 99.20% <100.00%> (ø)
aiohttp/web_ws.py 93.10% <100.00%> (ø)
tests/test_client_ws_functional.py 97.43% <100.00%> (-0.17%) ⬇️
tests/test_flowcontrol_streams.py 100.00% <100.00%> (ø)
tests/test_http_parser.py 99.08% <100.00%> (ø)
tests/test_streams.py 100.00% <100.00%> (ø)
... and 2 more

... and 15 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

aiohttp/streams.py Outdated Show resolved Hide resolved
@@ -580,9 +579,8 @@ def set_exception(self, exc: BaseException) -> None:
self._waiter = None
set_exception(waiter, exc)

def feed_data(self, data: _T, size: int = 0) -> None:
self._size += size
Copy link
Member

Choose a reason for hiding this comment

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

Why is this removed? This will surely break the limit functionality. Just use len(data) to calculate the actual size?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And if we don't delete this line, the TestFlowControlDataQueue.test_resume_on_read test will fall

@@ -608,8 +606,7 @@ async def read(self) -> _T:
raise

if self._buffer:
data, size = self._buffer.popleft()
self._size -= size
Copy link
Member

Choose a reason for hiding this comment

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

^

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because if we don't delete it we get error in almost all tests the TypeError error: unsupported operand type(s) for -=: 'int' and 'StreamReader'. In tests/test_client_functional.py and he refers to this block of code

Copy link
Member

Choose a reason for hiding this comment

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

len(data)? Obviously you can't subtract a StreamReader from an int...

Though if it's possible for data to be something other than bytes, then maybe this won't work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, but we will still have tests falling in TestDataQueue. With TypeError error: object of type 'object' has no len(). Now it seems that we need to use b"something" instead of object() or handle error, but I'm not sure about that.

Copy link
Member

Choose a reason for hiding this comment

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

Well, object() is probably unreasonable, so we could maybe update that test... I'll have a look through later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added types checking to feed_data and now those tests don't crash, but I doubt the correctness of such a solution

@DavidRomanovizc DavidRomanovizc closed this by deleting the head repository Dec 3, 2023
Dreamsorcerer added a commit that referenced this pull request Apr 21, 2024
Co-authored-by: dromanov <dtdzhalaev@gmail.com>
Co-authored-by: David Dzhalaev <72649244+DavidRomanovizc@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip Skip backport bot bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants