1111from typing import TYPE_CHECKING
1212if TYPE_CHECKING :
1313 from mypy_boto3_dynamodb .client import DynamoDBClient
14- # print("DEBUG: WE ARE TYPECHECKING NOW...")
15-
16- # from mypy_boto3_dynamodb.service_resource import DynamoDBServiceResource, Table
14+ from mypy_boto3_dynamodb .service_resource import DynamoDBServiceResource
1715
1816class sra_dynamodb :
1917 PROFILE = "default"
@@ -25,22 +23,32 @@ class sra_dynamodb:
2523
2624 # DEBUG STUFF
2725 import sys
28- LOGGER . debug ( "Python import paths:" )
26+ system_path = []
2927 for path in sys .path :
30- LOGGER .debug (path )
28+ system_path .append (path )
29+ LOGGER .debug (f"Python import paths: { system_path } " )
3130
3231 import pkgutil
33- LOGGER . debug ( "Installed packages:" )
32+ packages_installed = []
3433 for module in pkgutil .iter_modules ():
35- LOGGER .debug (module .name )
36-
37- try :
38- from mypy_boto3_dynamodb .service_resource import DynamoDBServiceResource
39- LOGGER .info ("Successfully imported DynamoDBServiceResource." )
40- except ModuleNotFoundError as e :
41- LOGGER .error (f"Failed to import DynamoDBServiceResource: { e } " )
42- except Exception as e :
43- LOGGER .error (f"Unexpected error during import: { e } " )
34+ packages_installed .append (module .name )
35+ LOGGER .debug (f"Installed packages: { packages_installed } " )
36+
37+ # try:
38+ # from mypy_boto3_dynamodb.service_resource import DynamoDBServiceResource
39+ # LOGGER.info("Successfully imported DynamoDBServiceResource.")
40+ # except ModuleNotFoundError as e:
41+ # LOGGER.error(f"Failed to import DynamoDBServiceResource: {e}")
42+ # except Exception as e:
43+ # LOGGER.error(f"Unexpected error during import: {e}")
44+
45+ # try:
46+ # from mypy_boto3_dynamodb.client import DynamoDBClient
47+ # LOGGER.info("Successfully imported DynamoDBClient.")
48+ # except ModuleNotFoundError as e:
49+ # LOGGER.error(f"Failed to import DynamoDBClient: {e}")
50+ # except Exception as e:
51+ # LOGGER.error(f"Unexpected error during import: {e}")
4452 # END DEBUG STUFF
4553
4654 try :
@@ -50,8 +58,11 @@ class sra_dynamodb:
5058 raise ValueError ("Unexpected error executing Lambda function. Review CloudWatch logs for details." ) from None
5159
5260 try :
53- DYNAMODB_RESOURCE : DynamoDBServiceResource = MANAGEMENT_ACCOUNT_SESSION .resource ("dynamodb" )
54- DYNAMODB_CLIENT : DynamoDBClient = MANAGEMENT_ACCOUNT_SESSION .client ("dynamodb" )
61+ # Use string-based type annotations
62+ DYNAMODB_CLIENT : "DynamoDBClient" = MANAGEMENT_ACCOUNT_SESSION .client ("dynamodb" a )
63+ DYNAMODB_RESOURCE : "DynamoDBServiceResource" = MANAGEMENT_ACCOUNT_SESSION .resource ("dynamodb" )
64+ # DYNAMODB_RESOURCE: DynamoDBServiceResource = MANAGEMENT_ACCOUNT_SESSION.resource("dynamodb")
65+ # DYNAMODB_CLIENT: DynamoDBClient = MANAGEMENT_ACCOUNT_SESSION.client("dynamodb")
5566 LOGGER .info ("DynamoDB resource and client created successfully." )
5667 except Exception as error :
5768 LOGGER .warning (f"Error creating boto3 dymanodb resource and client: { error } " )
0 commit comments