-
Notifications
You must be signed in to change notification settings - Fork 245
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
fix(python): parameter names shadow imported modules #3848
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In certain cases, a function parameter may shadow an imported module name, resultin in run-time errors either during type-checking or during the type-cast that is performed before returning a kernel call's result. This change adds a test case that covers this particular scenario in Python, and changes how foreign modules are imported so that an alias is always generated for those, removin the risk for collisions. Fixes aws/aws-cdk#22975
MrArnoldPalmer
approved these changes
Nov 22, 2022
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! 🚢
Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it! |
Merging (with squash)... |
RomainMuller
added a commit
to DanielMSchmidt/jsii
that referenced
this pull request
Dec 1, 2022
Added an integration test to verify parameters named `builtins` or `str` do not shadow the relevant type names, which used to be problematic until aws#3848 fixed the overarching issue, hoever the existing test only covered the case where a parameter name shadowed an namespace/import. Additionally, changes various `typing.Dict` keys that were mistakenly spelled out as `str` to use `builtins.str` in order to improve overall consistency in type declarations (see also aws#3866). Co-authored-by: rmuller@amazon.fr
mergify bot
pushed a commit
that referenced
this pull request
Dec 1, 2022
Added an integration test to verify parameters named `builtins` or `str` do not shadow the relevant type names, which used to be problematic until #3848 fixed the overarching issue, hoever the existing test only covered the case where a parameter name shadowed an namespace/import. Additionally, changes various `typing.Dict` keys that were mistakenly spelled out as `str` to use `builtins.str` in order to improve overall consistency in type declarations (see also #3866). Co-authored-by: rmuller@amazon.fr --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In certain cases, a function parameter may shadow an imported module name, resultin in run-time errors either during type-checking or during the type-cast that is performed before returning a kernel call's result.
This change adds a test case that covers this particular scenario in Python, and changes how foreign modules are imported so that an alias is always generated for those, removing the risk for collisions. It also moves the type-checking stubs out to the root of the module to remove the risk of more "runtime context" polluting the type evaluation.
Fixes aws/aws-cdk#22975
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.