cloudtools / troposphere

troposphere - Python library to create AWS CloudFormation descriptions
BSD 2-Clause "Simplified" License
4.93k stars 1.45k forks source link

GlobalsHelperFn type validation crashes for list types or validation functions #2063

Closed TeeSeal closed 2 years ago

TeeSeal commented 2 years ago

Problem statement

The *Globals classes defined in https://github.com/cloudtools/troposphere/blob/main/troposphere/serverless.py have some properties with their type specified as [T] or as validation functions (e.g. validate_memory_size). They all inherit from GlobalsHelperFn which does not handle those types during runtime type validation, all it does is feed them into isinstance which ends up throwing:

TypeError: isinstance() arg 2 must be a type or tuple of types

Steps to reproduce

from troposphere.serverless import FunctionGlobals
FunctionGlobals(MemorySize=3072)

I've noticed BaseAWSObject has proper handling for such types here for validation functions and here for lists. Something similar needs to be used for the Globals.

TeeSeal commented 2 years ago

I am currently studying the project. Will try to come up with a solution and submit a PR.