jborean93 / smbprotocol

Python SMBv2 and v3 Client
MIT License
316 stars 73 forks source link

Python3 style updates #212

Closed tik-stbuehler closed 1 year ago

tik-stbuehler commented 1 year ago

Given "Python 3.7+" is listed as requirement, there are a few things that could be updated. Also cleanup a previous "black" run that removed linebreaks between string literals but didn't merge them.

Regarding the super(...) cleanup: there was one non-trivial use in _SMBErrorRegistry.__call__ which I replaced with type.__call__. Perhaps this method should start with if cls != SMBResponseException: return super().__call__(header) anyway - or ensure the status code of a passed header matches the cls._STATUS_CODE for subclasses (or even forbid passing a header to subclasses).

(The git history looks a little bit like you squash PRs to merge them? I'd appreciate it if you don't do that with mine - I split my changes into commits on purpose, and I'm happy to rebase/edit them :) )

tik-stbuehler commented 1 year ago

I didn't run black/isort on . (because it went crazy on my venv directory), only on src - now also added tests.

codecov[bot] commented 1 year ago

Codecov Report

Merging #212 (868eb28) into master (5c1af5f) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #212   +/-   ##
=======================================
  Coverage   99.07%   99.07%           
=======================================
  Files          24       24           
  Lines        5082     5082           
=======================================
  Hits         5035     5035           
  Misses         47       47           
Flag Coverage Δ
99.07% <100.00%> (ø)
py3.10 99.03% <100.00%> (ø)
py3.11 99.03% <100.00%> (ø)
py3.7 99.03% <100.00%> (ø)
py3.8 99.03% <100.00%> (ø)
py3.9 99.07% <100.00%> (ø)
x64 99.07% <100.00%> (ø)
x86 98.99% <100.00%> (ø)

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

Impacted Files Coverage Δ
src/smbprotocol/__init__.py 100.00% <ø> (ø)
src/smbclient/_io.py 99.02% <100.00%> (ø)
src/smbclient/_os.py 98.49% <100.00%> (ø)
src/smbclient/_pool.py 95.54% <100.00%> (ø)
src/smbprotocol/change_notify.py 100.00% <100.00%> (ø)
src/smbprotocol/connection.py 99.84% <100.00%> (ø)
src/smbprotocol/create_contexts.py 100.00% <100.00%> (ø)
src/smbprotocol/dfs.py 100.00% <100.00%> (ø)
src/smbprotocol/exceptions.py 100.00% <100.00%> (ø)
src/smbprotocol/file_info.py 100.00% <100.00%> (ø)
... and 9 more

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