0

I'm getting an issue where lambda throws a "'module' object is not callable" error when I decorate a function with the multimethod decorator. I created an arbitary example to recreate this issue.

import json
from multimethod import multimethod

@multimethod
def test(word: str):
    print("you called string version", word)
    

def lambda_handler(event, context):
    test("hello")
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }

If I remove the decorator it works. For some reason my function gets treated as a module as soon as I decorate it. I'm using layers to include multimethod but I don't think that's the issue since other decorators have worked before.

Ozymandias
  • 839
  • 1
  • 8
  • 13

1 Answers1

0

The issue above was arising from me using multimethod installed from pip rather than pip3. The library from pip had a separate multimethod.py and init.py file. So when my lambda function was importing it from lambda layers, "from multimethod import multimethod" was actually importing the module and not the function.

Installing multimethod with pip3 and uploading the pip3 version to layers fixed it.

Ozymandias
  • 839
  • 1
  • 8
  • 13