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

Added more specific type hints. Added send_text and send_bytes methods. #953

Merged
merged 2 commits into from
Dec 3, 2023

Conversation

StrajnarFilip
Copy link
Contributor

I've added py.typed file so that type hints are properly used by linters.
WebSocketApp callback functions previously had more general type hints. They are now more specific.
WebSocketApp and WebSocket classes now have send_text and send_bytes methods for convenience.
I've used Black formatter to format the code in _app.py. If the authors of this project agree, we can format the entire codebase with some formatter (Black, YAPF, etc.) for more readable code.

@codecov
Copy link

codecov bot commented Oct 15, 2023

Codecov Report

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

Comparison is base (39a6876) 83.56% compared to head (a1a15d7) 83.08%.

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #953      +/-   ##
==========================================
- Coverage   83.56%   83.08%   -0.49%     
==========================================
  Files          13       13              
  Lines        1381     1389       +8     
  Branches      258      260       +2     
==========================================
  Hits         1154     1154              
- Misses        151      158       +7     
- Partials       76       77       +1     
Files Coverage Δ
websocket/_core.py 80.93% <50.00%> (-0.59%) ⬇️
websocket/_app.py 78.67% <70.58%> (-1.93%) ⬇️

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

@engn33r
Copy link
Collaborator

engn33r commented Oct 15, 2023

Thanks for the type hint upgrades.

As for formatting the code, it's all a matter of taste. I'm happy with the way the code is currently unless you wish to elaborate on specific benefits black could bring in the context of this project. Otherwise it would be preferred to remove the newlines that were introduced by black in this PR.

@StrajnarFilip
Copy link
Contributor Author

Thanks for the type hint upgrades.

As for formatting the code, it's all a matter of taste. I'm happy with the way the code is currently unless you wish to elaborate on specific benefits black could bring in the context of this project. Otherwise it would be preferred to remove the newlines that were introduced by black in this PR.

I have nothing against flake8, I just didn't know that's the style project adopted. I've noticed flake8 has built in formatter so I'll jus run that. Thanks for feedback.

…s to the WebSocketApp and WebSocket classes. Formatted code.
@StrajnarFilip
Copy link
Contributor Author

Thanks for the type hint upgrades.

As for formatting the code, it's all a matter of taste. I'm happy with the way the code is currently unless you wish to elaborate on specific benefits black could bring in the context of this project. Otherwise it would be preferred to remove the newlines that were introduced by black in this PR.

I hope that the changes I've made are fine. The command I've used to format is python -m black -l 79 ./websocket/_app.py. The only errors I've got locally from flake8 are E501 line too long, but those are attributed to long strings.

If there is something else I should do please let me know.

@StrajnarFilip
Copy link
Contributor Author

In my opinion, it'd be easier to maintain this project if a formatter was chosen. Any formatter with any style choice, whatever the authors find acceptable. It'd make the code look more consistent throughout the project, and it'd remove one burden from developers.

@engn33r
Copy link
Collaborator

engn33r commented Dec 3, 2023

I forgot that this PR wasn't merged yet. My comments:

  • Thanks for adding py.typed, this should help linters
  • The typing improvements, mostly to init in _app.py, are appreciated. Typehints are one of the newer additions to websocket-client code and still need some improvements
  • I considered your idea and compared the outputs of YAPF and black. I agree the consistency in newlines could improve readability and I have a slight preference towards the output provided by black. After merging this PR, I will format the codebase with black and add a black formatting check to CI
  • Since many of the changes in this PR are from adding newlines, some edits get overwritten or changed in the black formatting process

@engn33r engn33r merged commit 2092dfa into websocket-client:master Dec 3, 2023
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.

None yet

2 participants