-
Notifications
You must be signed in to change notification settings - Fork 205
SG-38306 Python2 Removal - Part 7 - various #404
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
base: ticket/SG-38306-python2-removal-httplib2
Are you sure you want to change the base?
SG-38306 Python2 Removal - Part 7 - various #404
Conversation
346dc35
to
6124681
Compare
8ac9c8d
to
5d8b18d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR continues the Python 2 removal effort by cleaning up legacy Python 2/3 compatibility code, updating error handling, and modernizing imports.
- Removed
six.PY2
/six.PY3
branches and outdated workarounds - Replaced
sgsix.file_types
withio.IOBase
andShotgunSSLError
withssl.SSLError
- Simplified tests and CI configuration to target Python 3 only
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/test_client.py | Removed Python 2/3 guard around json.dumps ; always call without encoding |
tests/test_api.py | Dropped ShotgunSSLError import, switched exception handling to ssl.SSLError |
tests/base.py | Removed Python 2-specific json.dumps(..., encoding="utf-8") branch |
shotgun_api3/shotgun.py | Updated imports (removed sgsix ), added XML parsing in error handler, replaced sgsix.file_types with io.IOBase |
azure-pipelines-templates/run-tests.yml | Updated comments to reflect Python 3 versions only |
README.md | Cleaned up documentation by removing outdated Python 2/3 notes |
Comments suppressed due to low confidence (2)
shotgun_api3/shotgun.py:2926
- [nitpick] The new XML parsing branch in
download_attachment
error handling isn’t covered by existing tests. Consider adding a unit test that simulates an S3 XML error response to verify that the<Message>
extraction works as intended.
root = xml.etree.ElementTree.fromstring("".join(body))
tests/test_api.py:2259
- The code now references
ssl.SSLError
butssl
is not imported in this file. Please addimport ssl
at the top oftests/test_api.py
.
mock_request.side_effect = ssl.SSLError(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a couple of nitpicky suggestions.
root = xml.etree.ElementTree.fromstring("".join(body)) | ||
message_elem = root.find(".//Message") | ||
if message_elem is not None and message_elem.text: | ||
err += f" - {message_elem.text}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err += f" - {message_elem.text}" | |
err = f"{err} - {message_elem.text}" |
if message_elem is not None and message_elem.text: | ||
err += f" - {message_elem.text}" | ||
except xml.etree.ElementTree.ParseError: | ||
err += "\n%s\n" % "".join(body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err += "\n%s\n" % "".join(body) | |
err = "{err}\n%s\n" % "".join(body) |
PR orders
WIP