-
Notifications
You must be signed in to change notification settings - Fork 247
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): accept Sequence[T] for array parameters #2606
Conversation
Instead of typing array (list) parameters as `typing.List[T]`, using the more flexible `typing.Sequence[T]` type, as recommended by the `typing` package documentation for this use-case. Using `List[T]` is inconvenient as it is invariant ([ref]), and requires very intentional typing, which elads to boilerplate. `Sequence[T]` is variant, which removes the need for boilerplate, as long as all items in the sequence match the expected type. [ref]: https://mypy.readthedocs.io/en/latest/common_issues.html#variance This was reported in aws/aws-cdk#13203
@@ -67,7 +67,7 @@ export function verifyGeneratedCodeFor( | |||
|
|||
expect({ [TREE]: checkTree(outDir) }).toMatchSnapshot('<outDir>/'); | |||
|
|||
if (targetName !== TargetName.PYTHON) { | |||
if (targetName !== TargetName.PYTHON || process.env.SKIP_MYPY_CHECK) { |
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.
The Mypy check adds between 40 and 100 seconds to the execution... Disabling it temporarily can help iterating much faster...
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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)... |
Merging (with squash)... |
Instead of typing array (list) parameters as
typing.List[T]
, using themore flexible
typing.Sequence[T]
type, as recommended by thetyping
package documentation for this use-case.
Using
List[T]
is inconvenient as it is invariant (ref), and requiresvery intentional typing, which elads to boilerplate.
Sequence[T]
isvariant, which removes the need for boilerplate, as long as all items
in the sequence match the expected type.
This was reported in #4533
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.