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

Add some type annotations, most notably to smbclient.open_file #295

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

mon
Copy link
Contributor

@mon mon commented Oct 15, 2024

I won't lie, overloads are super verbose. But I worked off the ones for the stdlib open(), so it's "known good" at least.
I tested this by looking through all the test_smbclient_os opens and making sure the correct type was inferred.

I also added some extras so you can get typed connection details from an fd. It still kinda sucks (because something like the buffer sizes are None until connect is called) but at least it has intellisense.

Unfortunate API break: I couldn't work out a way to set the file/dir/pipe arg to specific values without forcing kwargs with * or moving the arg. I chose the latter, interested to hear your thoughts.

src/smbclient/_os.py Outdated Show resolved Hide resolved
src/smbclient/_os.py Outdated Show resolved Hide resolved
@mon mon force-pushed the open_file_types branch from fc95d18 to f6c8f82 Compare October 17, 2024 00:22
Copy link

codecov bot commented Oct 17, 2024

Codecov Report

Attention: Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.

Project coverage is 99.06%. Comparing base (42804ca) to head (68e761f).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/smbclient/_os.py 95.23% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #295   +/-   ##
=======================================
  Coverage   99.06%   99.06%           
=======================================
  Files          24       24           
  Lines        5117     5146   +29     
=======================================
+ Hits         5069     5098   +29     
  Misses         48       48           
Flag Coverage Δ
macOS 68.28% <87.50%> (+0.10%) ⬆️
py3.10 99.02% <95.83%> (+<0.01%) ⬆️
py3.11 99.02% <95.83%> (+<0.01%) ⬆️
py3.12 99.02% <95.83%> (+<0.01%) ⬆️
py3.8 99.02% <95.83%> (+<0.01%) ⬆️
py3.9 99.06% <95.83%> (+<0.01%) ⬆️
ubuntu 96.85% <95.83%> (+0.01%) ⬆️
windows 98.98% <95.83%> (+<0.01%) ⬆️
x64 99.06% <95.83%> (+<0.01%) ⬆️
x86 98.98% <95.83%> (+<0.01%) ⬆️

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

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

@mon mon force-pushed the open_file_types branch from f6c8f82 to 7b33d63 Compare October 17, 2024 00:35
@mon
Copy link
Contributor Author

mon commented Oct 17, 2024

Hold up on a merge just for a moment, I'm getting a runtime error on py3.10 that the tests haven't caught, making sure I didn't break anything

@mon mon force-pushed the open_file_types branch from 7b33d63 to 1187457 Compare October 17, 2024 00:52
@mon mon force-pushed the open_file_types branch from 1187457 to 68e761f Compare October 17, 2024 00:54
@mon
Copy link
Contributor Author

mon commented Oct 17, 2024

Alright, good to go once the tests finish running. Sorry for the churn!

@jborean93
Copy link
Owner

Thanks for working on this

@jborean93 jborean93 merged commit a0b8544 into jborean93:master Oct 18, 2024
21 of 22 checks passed
@mon mon deleted the open_file_types branch October 18, 2024 00:49
@mon
Copy link
Contributor Author

mon commented Oct 18, 2024

Thanks for the fast reviews, and having the most pleasant SMB library in the ecosystem :D

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