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

feat(python): add dynamic type checking #3660

Merged
merged 12 commits into from
Jul 21, 2022
Merged

Conversation

RomainMuller
Copy link
Contributor

@RomainMuller RomainMuller commented Jul 13, 2022

Use typeguard to perform runtime type checking of arguments passed
into methods (static or instance), setters, and constructors. This
ensures a pythonic error message is produced (and raised as a
TypeError), to help developers identify bugs in their code and fix
them.

These checks are disabled when running Python in optimized mode (via
python3 -O, which sets __debug__ to false).

Fixes #3639


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

Use `typeguard` to perform runtime type checking of arguments passed
into methods (static or instance), setters, and constructors. This
ensures a pythonic error message is produced (and raised as a
`TypeError`), to help developers identify bugs in their code and fix
them.

These checks are disabled when running Python in optimized mode (via
`python3 -O`, which sets `__debug__` to false).
@RomainMuller RomainMuller self-assigned this Jul 13, 2022
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jul 13, 2022
@RomainMuller RomainMuller marked this pull request as ready for review July 18, 2022 12:12
@RomainMuller RomainMuller requested a review from a team July 18, 2022 13:01
@mergify
Copy link
Contributor

mergify bot commented Jul 21, 2022

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Jul 21, 2022
@mergify
Copy link
Contributor

mergify bot commented Jul 21, 2022

Merging (with squash)...

1 similar comment
@mergify
Copy link
Contributor

mergify bot commented Jul 21, 2022

Merging (with squash)...

@mergify mergify bot merged commit 6c4b773 into main Jul 21, 2022
@mergify mergify bot deleted the rmuller/py-runtime-type-checking branch July 21, 2022 15:47
@mergify
Copy link
Contributor

mergify bot commented Jul 21, 2022

Merging (with squash)...

@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Jul 21, 2022
RomainMuller added a commit that referenced this pull request Jul 27, 2022
Formalize the contract that it is allowed to pass a dict in places where
a struct instance is expected (this provides less type checking guarantees,
and the developer is responsible for passing the right keys in).

This should address a false-positive issue with the runtime type-checking
introduced in 1.63.0 (#3660).
RomainMuller added a commit that referenced this pull request Jul 27, 2022
Formalize the contract that it is allowed to pass a dict in places where
a struct instance is expected (this provides less type checking guarantees,
and the developer is responsible for passing the right keys in).

This should address a false-positive issue with the runtime type-checking
introduced in 1.63.0 (#3660).
RomainMuller added a commit that referenced this pull request Jul 27, 2022
Formalize the contract that it is allowed to pass a dict in places where
a struct instance is expected (this provides less type checking guarantees,
and the developer is responsible for passing the right keys in).

This should address a false-positive issue with the runtime type-checking
introduced in 1.63.0 (#3660).
RomainMuller added a commit that referenced this pull request Jul 27, 2022
…3683)

Formalize the contract that it is allowed to pass a dict in places where
a struct instance is expected (this provides less type checking guarantees,
and the developer is responsible for passing the right keys in).

This should address a false-positive issue with the runtime type-checking
introduced in 1.63.0 (#3660).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate dynamic type-checks in Python bindings
2 participants