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

Add Support for Python Upgrade Rules #9776

Merged
merged 3 commits into from
Nov 10, 2023

Conversation

thsparks
Copy link
Contributor

@thsparks thsparks commented Nov 9, 2023

Need this so we can update python code when we make a breaking change. I mostly just copied whatever we were doing for typescript and tried to do it for python as well.

@thsparks thsparks requested review from riknoll and a team November 9, 2023 22:25
opts.fileSystem[fn] = ts2
if (fn.indexOf("/") == -1 && U.endsWith(fn, extension)) {
const initial = opts.fileSystem[fn]
const patched = pxt.patching.patchPython(version, initial)
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is being used by both Typescript and Python, should this be more generic? Because if computePyPatches returns undefined for TypeScript, that means it won't compute any upgrades, right? It would just return fileContents?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or should there just also be patchJavascript here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, good catch. I may need to split this out after all and not re-use...

Copy link
Member

Choose a reason for hiding this comment

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

yeah, looks like this needs something like a const patchFunction = extension == ".ts" ? pxt.patching.patchJavaScript : pxt.patching.patchPython; then call that here to me?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opted to just keep them separate. Seemed simpler at this point...

webapp/src/compiler.ts Show resolved Hide resolved
@@ -953,6 +958,37 @@ function upgradeFromTSAsync(): Promise<UpgradeResult> {
});
}

function upgradeFromPythonAsync(): Promise<UpgradeResult> {
Copy link
Member

Choose a reason for hiding this comment

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

async/await-ify this please

Copy link
Contributor

@srietkerk srietkerk left a comment

Choose a reason for hiding this comment

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

Nice!

@thsparks thsparks merged commit 98cda85 into master Nov 10, 2023
6 checks passed
@thsparks thsparks deleted the thsparks/support_py_upgrade_rules branch November 10, 2023 22:17
thsparks added a commit that referenced this pull request Nov 10, 2023
Need this so we can update python code when we make a breaking change. I mostly just copied whatever we were doing for typescript and tried to do it for python as well.
abchatra pushed a commit that referenced this pull request Nov 13, 2023
Need this so we can update python code when we make a breaking change. I mostly just copied whatever we were doing for typescript and tried to do it for python as well.
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.

4 participants