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

Upgrade to Python 3.7+ syntax #234

Merged
merged 1 commit into from
Aug 20, 2023
Merged

Conversation

dolfinus
Copy link
Contributor

@dolfinus dolfinus commented Aug 12, 2023

  • Run pyupgrade --py37-plus ./**/*.py to upgrade Python 2.7 syntax to 3.7+
  • Replace %s and .format() syntax with f-strings
  • For logging use %s string syntax, but without explicit "msg" % (variables,) - let logging do this if logging is enabled for a specific level
  • Convert # type comments to type hints, replace List[type], Optional[type] and Union[type1, type2] with list[type], type | None and type1 | type2 (using from __future__ import annotations).
  • Use os.fspath instead of str to convert Path-like objects to string path representation
  • Update examples to use logging instead of print

@codecov
Copy link

codecov bot commented Aug 19, 2023

Codecov Report

Merging #234 (71ea74c) into master (b81d5f1) will increase coverage by 0.00%.
Report is 1 commits behind head on master.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #234   +/-   ##
=======================================
  Coverage   99.07%   99.07%           
=======================================
  Files          24       24           
  Lines        5085     5088    +3     
=======================================
+ Hits         5038     5041    +3     
  Misses         47       47           
Flag Coverage Δ
99.07% <100.00%> (+<0.01%) ⬆️
py3.10 99.03% <99.42%> (+<0.01%) ⬆️
py3.11 99.03% <99.42%> (+<0.01%) ⬆️
py3.7 99.02% <99.36%> (+<0.01%) ⬆️
py3.8 99.03% <99.42%> (+<0.01%) ⬆️
py3.9 99.07% <100.00%> (+<0.01%) ⬆️
x64 99.07% <100.00%> (+<0.01%) ⬆️
x86 98.99% <99.42%> (+<0.01%) ⬆️

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

Files Changed Coverage Δ
src/smbclient/__init__.py 100.00% <ø> (ø)
src/smbclient/path.py 90.69% <ø> (ø)
src/smbprotocol/__init__.py 100.00% <ø> (ø)
src/smbprotocol/_text.py 100.00% <ø> (ø)
src/smbprotocol/create_contexts.py 100.00% <ø> (ø)
src/smbprotocol/file_info.py 100.00% <ø> (ø)
src/smbprotocol/header.py 100.00% <ø> (ø)
src/smbprotocol/ioctl.py 100.00% <ø> (ø)
src/smbprotocol/open.py 100.00% <ø> (ø)
src/smbprotocol/query_info.py 100.00% <ø> (ø)
... and 14 more

Copy link
Owner

@jborean93 jborean93 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. While I believe the type annotations might be fine if the future annotations are used I would prefer to ensure the mypy checks for each supported Python version still work so we might have to still use some of the older typing constructs.

README.md Outdated Show resolved Hide resolved
src/smbclient/_io.py Outdated Show resolved Hide resolved
src/smbclient/_os.py Show resolved Hide resolved
src/smbclient/_pool.py Show resolved Hide resolved
src/smbclient/_pool.py Show resolved Hide resolved
src/smbprotocol/exceptions.py Show resolved Hide resolved
src/smbprotocol/exceptions.py Show resolved Hide resolved
src/smbprotocol/session.py Outdated Show resolved Hide resolved
src/smbprotocol/session.py Outdated Show resolved Hide resolved
src/smbprotocol/structure.py Outdated Show resolved Hide resolved
@dolfinus dolfinus force-pushed the pyupgrade branch 2 times, most recently from ea1f79e to cc0f3ee Compare August 19, 2023 08:32
src/smbprotocol/session.py Outdated Show resolved Hide resolved
src/smbprotocol/session.py Outdated Show resolved Hide resolved
Copy link
Owner

@jborean93 jborean93 left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes, good to be free of some of those Python 2-isms.

@jborean93 jborean93 merged commit cf94109 into jborean93:master Aug 20, 2023
@dolfinus dolfinus deleted the pyupgrade branch August 20, 2023 09:12
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