Skip to content

Conversation

@CoolCat467
Copy link
Contributor

@CoolCat467 CoolCat467 commented Mar 28, 2022

Rebase of #225.
Closes #210

This PR introduces a complete rewrite of the protocol classes and fixes a bug, in which asynchronous connections were sometimes using synchronous functions when asynchronous ones were expected.

It adds doc strings to all of the methods, introduces some memory optimizations with the use of __slots__ in the connection classes, and separates Connection into several abstract classes, both synchronous and asynchronous, which then together compose the sync and asynchronous Connection classes. These abstract classes prevent a lot of previously duplicate code.

TODO:

  • Comply with linters, formatters and type checkers (black, isort, flake8, pyright)
  • Fix unit tests for the protocol classes to work with this rewrite
  • Adjust the rest of the code base to work with this rewritten code No changes should be required, but improvements could be made

@ItsDrike ItsDrike changed the title Rebase #225. Closes #210 Rework connection classes with proper async support Apr 2, 2022
@ItsDrike ItsDrike marked this pull request as draft April 2, 2022 16:28
@ItsDrike
Copy link
Member

ItsDrike commented Apr 2, 2022

Hi @CoolCat467, thanks for the rebase (btw, you don't need to make a new PR when rebasing, we do allow force pushing). I've edited your PR description to include some more detailed things about what this is doing (mostly based on the previous PR description), but most importantly, I've added some TODO check boxes there which needs to be done before this can be reviewed and then merged.

I've quickly glanced over the changes this introduces and it looks pretty interesting, but until it meets these TODOs and is compliant with our code quality standards, it can't be merged. Because of that, I've marked your PR as draft to avoid cluterring other PRs which are actually ready to be merged already. Once you feel like the PR is ready to be reviewed and you fulfilled these points and are passing the automated workflow checks, you can mark it as Ready for review (this button):

image

If you need more info on how to fulfill some of these, or how to pass the automated workflows, feel free to ask on discord, or here as a comment (though discord will probably be better for longer discussions).

@ItsDrike ItsDrike added t: bug Something isn't working t: enhancement Improvement to an existing feature a: api Related to exposed core API of the project state: WIP s: waiting for author Waiting for author to address a review or respond to a comment labels Apr 2, 2022
@CoolCat467
Copy link
Contributor Author

Ok, thank you for the information.

@ItsDrike
Copy link
Member

ItsDrike commented May 5, 2022

@CoolCat467, do you plan on going through with this and implementing it fully or can someone take over this PR?

@CoolCat467
Copy link
Contributor Author

I've never written unit tests before, so that would probably be for the best.

@ItsDrike ItsDrike added s: stalled Something is blocking further progress and removed s: waiting for author Waiting for author to address a review or respond to a comment state: WIP labels May 5, 2022
@ItsDrike
Copy link
Member

ItsDrike commented May 5, 2022

I've never written unit tests before, so that would probably be for the best.

Alright, no problem, I don't mind finishing this up, although it may take me a while since I've been a bit busy lately, so if someone else would want to, feel free to take over, otherwise I'll implement this hopefully within a few weeks time.

Copy link
Contributor

@kevinkjt2000 kevinkjt2000 left a comment

Choose a reason for hiding this comment

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

There are a handful of type checking errors when running tox -e lint. See CONTRIBUTING.md for the commands to set up your terminal. Once those type checks are fixed, I'd start running tox -e py310 to execute tests for a specific version. When I get a single version working, I like to use both the oldest and newest tox -e py37,py310. To run the whole suite of format check, linting, and tests: tox.

If you ping me on the Discord server, I could schedule some time to teach you some unit test stuff if you're interested. Unit tests are basically a collection of a bunch of miniature Python scripts that have assertions sprinkled into them.

I'll wait until things are passing again to do a more thorough review of the new connection classes, but I'm on board with this idea. Thanks for taking the time on this PR! My apologies for taking a while to get around to this.

@kevinkjt2000 kevinkjt2000 added s: waiting for author Waiting for author to address a review or respond to a comment and removed s: stalled Something is blocking further progress labels May 7, 2022
@CoolCat467 CoolCat467 marked this pull request as ready for review July 15, 2022 20:36
@CoolCat467 CoolCat467 requested a review from kevinkjt2000 July 15, 2022 20:37
Copy link
Member

@ItsDrike ItsDrike left a comment

Choose a reason for hiding this comment

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

Just a quick review purely addressing the formatting/typing issues, I'll make another review on the actual logic after these changes are addressed. Thanks for the contribution though, the connection classes really needed an update for a while now!

CoolCat467 and others added 2 commits July 15, 2022 16:40
@CoolCat467 CoolCat467 requested a review from ItsDrike July 15, 2022 22:20
Copy link
Member

@ItsDrike ItsDrike left a comment

Choose a reason for hiding this comment

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

Great job! The code does still need a lot of minor formatting changes, but logic-wise I don't see any significant issues to point out (other than some that were already there before this PR, which should be fixed elsewhere anyway).

CoolCat467 and others added 3 commits July 17, 2022 18:46
Fix formatting issues in doc strings, default values to initialize to, a few small type annotation things.

Co-authored-by: ItsDrike <itsdrike@protonmail.com>
@ItsDrike ItsDrike requested review from kevinkjt2000 and removed request for kevinkjt2000 August 4, 2022 16:41
@kevinkjt2000 kevinkjt2000 merged commit d3b4e44 into py-mine:master Aug 6, 2022
@CoolCat467 CoolCat467 deleted the patch-2 branch August 7, 2022 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: api Related to exposed core API of the project s: waiting for author Waiting for author to address a review or respond to a comment t: bug Something isn't working t: enhancement Improvement to an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Synchronous operations inside async functions

4 participants