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

chore: drop python 2 support and run test in PRs #328

Merged
merged 8 commits into from
Nov 15, 2024

Conversation

MaferMazu
Copy link
Collaborator

@MaferMazu MaferMazu commented Nov 14, 2024

Description

This PR edits and removes functions related to Python 2—all the corrections were made based on searching for Python 2 comments in the code.

Related to #326

Note

I think it is easier to review this PR by commit.

Details

  • Remove Python 2 condition from tests/helpers/test_compatibility.py
  • Use reload from importlib.
  • Use mock from unittest and not from helpers for clarity and correctness.
  • Remove ValueError try-except from mitxgraders/helpers/calc/robust_pow.py.
  • Remove the text_string function, that was created for Python 2.
  • Remove get_number_of_args_py2 function.
  • Use get_number_of_args_py3 in get_number_of_args.
  • Remove get_builtin_positional_args_py2 because it is no longer used in get_number_of_args_py2.
  • Remove the ensure_text function because was used to maintain compatibility with Python 2.
  • Remove the UNICODE_PREFIX variable used for Python 2.
  • Refactor format_message_with_locations.

How to test

Code

All the checks are passed.

Integration:

Environment

  • Have a tutor environment with Tutor v18.1.4
  • Install codejail. You can follow the installation and usage process from the tutor-contrib-codejail README.
  • Perform a dev launch

Data

  • Import the MIT demo course running:
tutor dev do importdemocourse -r https://github.com/mitodl/mitx-grading-library -d course -v master

For more info: tutor dev do importdemocourse -h

  • Create an admin user
tutor dev do createuser --staff --superuser admin [email protected]

Test

  1. Enter in Studio > MITx Grading Library > Content > Files
  2. Remove the python_lib.zip and add this one:
    python_lib.zip

Note

If you want to create your python_lib from this version, you can clone the repo, enter in it, and then:

find mitxgraders voluptuous -type f ! -path "*/__pycache__/*" | zip python_lib.zip -@
  1. Make sure the units are rendered and worked well.

@jolyonb
Copy link
Collaborator

jolyonb commented Nov 14, 2024

I've approved the other PR. When that's merged and you've rebased this on top of master and pushed again, I'll review this :)

mitxgraders/baseclasses.py Show resolved Hide resolved
@jolyonb
Copy link
Collaborator

jolyonb commented Nov 15, 2024

Okay, I've worked my way through all the commits (thanks for the suggestion).

I'm okay with just merging this as-is, but beware that you're still going to need to remove the six library in a future PR.

Also, I'm concerned that the github actions are no longer running our unit tests... that seems bad? (probably good to fix that in another PR too).

Copy link
Collaborator

@jolyonb jolyonb left a comment

Choose a reason for hiding this comment

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

Please fix the github actions unit tests next!

@MaferMazu
Copy link
Collaborator Author

MaferMazu commented Nov 15, 2024

I added the fix for the GitHub action to have the testing here and ensure everything works well.

I'll merge this. Thanks @jolyonb.

@MaferMazu MaferMazu changed the title chore: drop python 2 support chore: drop python 2 support and run test in PRs Nov 15, 2024
@MaferMazu MaferMazu merged commit ffb4552 into mitodl:master Nov 15, 2024
4 checks passed
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