How do I move my Python function handlers into a subdirectory?

I thought this would be as simple as:

functions:
  SignUp:
    handler: handler/unauthorized_api.sign_up
    events:
      - httpApi:
          path: /sign_up
          method: post

with a handler/unauthorized_api.py file but I get this error:

sls logs -f SignUp
START
[ERROR] Runtime.ImportModuleError: Unable to import module 'handler.unauthorized_api': No module named 'handler'
Traceback (most recent call last):
END Duration: 1.78 ms (init: 124.40 ms) Memory Used: 39 MB

Long story short, here’s the right way to do it. Assume a directory structure like this:

handler
|-- __init__.py
+-- unauthorized_api..py
constants.py
serverless.yml

Having an __init__.py seems important here.

serverless.yml:

functions:
  SignUp:
    handler: handler.unauthorized_api.sign_up

unauthorized_api.py:

import constants

def sign_up(event, context):
  pass

I found the right approach in Python relative imports in AWS Lambda fail with `attempted relative import with no known parent package` · GitHub.