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: Add basic mypy check (no behavior change) #2488

Merged
merged 1 commit into from
Sep 1, 2022

Conversation

aahung
Copy link
Contributor

@aahung aahung commented Sep 1, 2022

Issue #, if available:

Description of changes:

Have bare minimal type check and we can enable more checks in the future to ensure code quality and correctness.

Description of how you validated changes:

No behavior changes have been made in this PR.

Checklist:

  • Add/update unit tests using:
  • Add/update integration tests
  • make pr passes
  • Update documentation
  • Verify transformed template deploys and application functions as expected
  • Do these changes include any template validations?
    • Did the newly validated properties support intrinsics prior to adding the validations? (If unsure, please review Intrinsic Functions before proceeding).
      • Does the pull request ensure that intrinsics remain functional with the new validations?

Examples?

Please reach out in the comments, if you want to add an example. Examples will be
added to sam init through https://github.com/awslabs/aws-sam-cli-app-templates/

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@@ -1,3 +0,0 @@
# flake8: noqa

from samtranslator.translator import add_default_parameter_values
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explanation: this file is not used, and samtranslator.translator doesn't have add_default_parameter_values

@@ -179,9 +181,7 @@ def _parse(self, globals_dict):

globals = {}
if not isinstance(globals_dict, dict):
raise InvalidGlobalsSectionException(
self._KEYWORD, "It must be a non-empty dictionary".format(self._KEYWORD)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explanation: .format() is noop because there are not %s in the string template.

@@ -607,7 +607,7 @@ def _validate_dlq(self):
if not self.DeadLetterQueue.get("Type") or not self.DeadLetterQueue.get("TargetArn"):
raise InvalidResourceException(
self.logical_id,
"'DeadLetterQueue' requires Type and TargetArn properties to be specified.".format(valid_dlq_types),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explanation: .format() is noop because there are not %s in the string template.

@@ -20,11 +20,11 @@

_CORS_WILDCARD = "*"
CorsProperties = namedtuple(
"_CorsProperties", ["AllowMethods", "AllowHeaders", "AllowOrigins", "MaxAge", "ExposeHeaders", "AllowCredentials"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explanation: first parameter needs to be consistent with assigned type name. the literal _CorsProperties is only a type hint name, not used anywhere in our codebase.

@aahung aahung marked this pull request as ready for review September 1, 2022 21:04
Copy link
Contributor

@hoffa hoffa left a comment

Choose a reason for hiding this comment

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

Great! 🚢

@aahung aahung changed the title Add basic mypy check (no behavior change) chore: Add basic mypy check (no behavior change) Sep 1, 2022
Copy link
Contributor

@hawflau hawflau left a comment

Choose a reason for hiding this comment

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

yay 🙌

@aahung aahung merged commit 38d535c into aws:develop Sep 1, 2022
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