Skip to content

SG-38307 Remove Python 2 compatibility - Part 6 - Everything else #1030

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

Merged
merged 38 commits into from
Jul 31, 2025

Conversation

eduardoChaucaGallegos
Copy link
Contributor

@eduardoChaucaGallegos eduardoChaucaGallegos commented Jun 17, 2025

Description

  • Remove imports to the six module and replace six.string_types/six.text_type by str
  • Revert SG-32830 Fixup Python 2 compatibility #922 now we can use a mandatory named parameter
  • Remove code handling support of Python 2
  • Remove copy of the six module
    • We decided to keep the module for now for retro compatibility purpose
  • Replace custom sgtk.util.json by Python's default json module
  • Remove imports to sgutils and calls to ensure_binary/ensure_string/ensure_text
  • sys.version_info sys.version_info and code related with Python 2 removed.
  • Replaced inspect.getargspec with inspect.getfullargspec.

Remove Python 2 PR orders

@eduardoChaucaGallegos eduardoChaucaGallegos changed the title Removed python 2 code SG-38307 Removed python 2 code Jun 17, 2025
Copy link

codecov bot commented Jun 20, 2025

Codecov Report

❌ Patch coverage is 94.57831% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.78%. Comparing base (b419572) to head (c17b85f).

Files with missing lines Patch % Lines
python/tank/commands/setup_project.py 0.00% 3 Missing ⚠️
python/tank/authentication/user_impl.py 75.00% 1 Missing ⚠️
python/tank/descriptor/io_descriptor/appstore.py 88.88% 1 Missing ⚠️
python/tank/descriptor/io_descriptor/factory.py 66.66% 1 Missing ⚠️
python/tank/descriptor/io_descriptor/git_tag.py 83.33% 1 Missing ⚠️
python/tank/path_cache.py 50.00% 1 Missing ⚠️
python/tank/util/pickle.py 93.33% 1 Missing ⚠️
Additional details and impacted files
@@                            Coverage Diff                             @@
##           ticket/SG-38307-python2-removal-pyyaml    #1030      +/-   ##
==========================================================================
+ Coverage                                   79.75%   79.78%   +0.02%     
==========================================================================
  Files                                         198      197       -1     
  Lines                                       20732    20594     -138     
==========================================================================
- Hits                                        16535    16430     -105     
+ Misses                                       4197     4164      -33     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eduardoChaucaGallegos eduardoChaucaGallegos marked this pull request as ready for review June 20, 2025 14:37
@eduardoChaucaGallegos eduardoChaucaGallegos requested a review from a team June 20, 2025 14:57
Copy link
Contributor

@carlos-villavicencio-adsk carlos-villavicencio-adsk left a comment

Choose a reason for hiding this comment

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

I'm halfway through reviewing this. It's too long, but it's a great update.

Note: I don't think we should touch tank_vendor files. Maybe the ruamel_yaml, or consider updating that external library to a later version. python-api will be updated in a different ticket, let's revert these changes.

Copy link
Contributor

@julien-lang julien-lang left a comment

Choose a reason for hiding this comment

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

First review. I did the first 90 files ;)

I'll do the rest next week.

if params.get_project_path(primary_storage_name, "linux2"):
location["linux2"] = "%s/tank" % params.get_project_path(
primary_storage_name, "linux2"
if params.get_project_path(primary_storage_name, "linux"):
Copy link
Contributor

Choose a reason for hiding this comment

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

@eduardoChaucaGallegos what about this finding?
Is this a bug we were not aware of?

Copy link
Contributor

@carlos-villavicencio-adsk carlos-villavicencio-adsk left a comment

Choose a reason for hiding this comment

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

Great start! Let's review all the feedback to do a second pass.

Copy link
Contributor

@julien-lang julien-lang left a comment

Choose a reason for hiding this comment

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

I reviewed the first 180 files. 60 more to go.

Copy link
Contributor

@carlos-villavicencio-adsk carlos-villavicencio-adsk left a comment

Choose a reason for hiding this comment

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

LGTM

@julien-lang julien-lang changed the title SG-38307 Removed python 2 code SG-38307 Remove Python 2 compatibility - Part 5 - Everything else Jul 8, 2025
@julien-lang julien-lang changed the title SG-38307 Remove Python 2 compatibility - Part 5 - Everything else SG-38307 Remove Python 2 compatibility - Part 6 - Everything else Jul 8, 2025
Copy link
Contributor

@julien-lang julien-lang left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@carlos-villavicencio-adsk carlos-villavicencio-adsk left a comment

Choose a reason for hiding this comment

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

LGTM

Base automatically changed from ticket/SG-38307-python2-removal-pyyaml to master July 31, 2025 19:52
@julien-lang julien-lang merged commit d605832 into master Jul 31, 2025
24 checks passed
@julien-lang julien-lang deleted the ticket/SG-38307-python2-removal-code branch July 31, 2025 20:40
carlos-villavicencio-adsk pushed a commit that referenced this pull request Jul 31, 2025
)

* Remove Python 2 Compatibility

* Apply suggestion from @julien-lang

* Remove useless Python 2 support code

* Remove six

* fixup! Remove useless Python 2 support code

* Revert wrong change

* Update tk-shell version used by CI tests to a version that does use six

* fixup! Update tk-shell version used by CI tests to a version that does use six

* Revert "Remove six"

This reverts commit b01dc45.

* custom dumps pickle func fixed

* keep six

* Restore json.py copy for long term deprecation process

---------

Co-authored-by: Julien Langlois <julien.langlois@autodesk.com>
Co-authored-by: Julien Langlois <16244608+julien-lang@users.noreply.github.com>
carlos-villavicencio-adsk added a commit that referenced this pull request Jul 31, 2025
* Replace `imp`

Format

Fix syntax

Add module to `sys.modules`

Fix test

Replace `utcnow()` for Python 3.12 (#1025)

Bump python-api to v3.8.4 (#1028)

* Bump python-api to v3.8.4

* Fix `test_default_configuration_location_without_suggestions` (#1029)

Update the import system hook to use `importlib`

Format to make hound 🐕‍🦺 happy

Some feedback applied

Use `argparse`

Replace `utcnow()` for Python 3.12 (#1025)

Bump python-api to v3.8.4 (#1028)

* Bump python-api to v3.8.4

* Fix `test_default_configuration_location_without_suggestions` (#1029)

* Update python/tank/util/pyside6_patcher.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* add support for QtWebEngineWidgets (#1043)

* [SG-9141] pip installed core can't use the ToolkitManager to bootstrap (#1033)

* move the bootstrap hook to the bootstrap folder in order to be able to bootstrap the engine when sgtk is installed using pip
* add test file to cover engine bootstrap when sgtk has been installed using pip
* remove blank line
* do not return unused value
* move and rename hook to his previous name to keep consistancy with existing workflows
* update setup.py file to make sure the new hook folder will be included with the packages
* improve documentation
* run black manually to make hound happy as tests are not included in pre-commit actions
* improve code comments
* Apply suggestions from code review
---------
Co-authored-by: Martin Chesnay <104032692+mchesnay@users.noreply.github.com>

* SG-38307 Remove Python 2 compatibility - Part 1 - Simplified super prototype (#1038)

* SG-38307 Remove Python 2 compatibility - Part 2 - Removed useless __future__ imports (#1039)

* Removed __future__ functions

---------

Co-authored-by: Julien Langlois <julien.langlois@autodesk.com>

* SG-38307 Remove Python 2 compatibility - Part 3 - Replace "linux2" key to "linux" (#1037)

* python2 key by only python key

* sys.platform used instead sgsix.platform

---------

Co-authored-by: Julien Langlois <julien.langlois@autodesk.com>

* SG-38307 Remove Python 2 compatibility - Part 4 - Cleanup six.moves imports and other imports (#1040)

* six.moves

* Test fixup CI

---------

Co-authored-by: Eduardo Chauca <eduardo.chauca@autodesk.com>

* SG-38307 Remove Python 2 compatibility - Part 5 - Simplify pyyaml bundle (#1041)

* Update pyaml - remove python2 copy

Also add an option to the script to specify the tag
to use instead of latest

* Run script

---------

Co-authored-by: Eduardo Chauca <eduardo.chauca@autodesk.com>

* SG-38307 Remove Python 2 compatibility - Part 6 - Everything else (#1030)

* Remove Python 2 Compatibility

* Apply suggestion from @julien-lang

* Remove useless Python 2 support code

* Remove six

* fixup! Remove useless Python 2 support code

* Revert wrong change

* Update tk-shell version used by CI tests to a version that does use six

* fixup! Update tk-shell version used by CI tests to a version that does use six

* Revert "Remove six"

This reverts commit b01dc45.

* custom dumps pickle func fixed

* keep six

* Restore json.py copy for long term deprecation process

---------

Co-authored-by: Julien Langlois <julien.langlois@autodesk.com>
Co-authored-by: Julien Langlois <16244608+julien-lang@users.noreply.github.com>

* SG-39029 Make core not importing PySide/Qt when importing the library (#1022)

* Move the explicit UI authentication module imports

* Missing one thing

* Cleanup unused ret_val variable

unittest.main calls sys.exit by default

* Fixup broken tests

* Minor fixup found by coPilot

* Fix import

* Remove import six

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Barbara Laigneau <38566472+barbara-darkshot@users.noreply.github.com>
Co-authored-by: Martin Chesnay <104032692+mchesnay@users.noreply.github.com>
Co-authored-by: Eduardo Chauca <166560435+eduardoChaucaGallegos@users.noreply.github.com>
Co-authored-by: Julien Langlois <julien.langlois@autodesk.com>
Co-authored-by: Julien Langlois <16244608+julien-lang@users.noreply.github.com>
Co-authored-by: Eduardo Chauca <eduardo.chauca@autodesk.com>
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.

3 participants