input: from typing import Callable
  
  def port_method_to_python(java_code: str) -> Callable:
      """Given a Java method declaration as a string, translate it into a Python 3 function.
  
      >>> port_method_to_python("public int foo(int a, int b) {return a + b;}")
      foo(a, b):
       return a + b
  
      >>> port_method_to_python("public String bar(String s) {return s.toUpperCase();}")
      bar(s):
       return s.upper()
      """
output:     
      import re
  
      def parse_java_method(java_code: str) -> dict:
          pattern = r"public\s+(\w+)\s+(\w+)\s*\((.*?)\)\s*\{(.*)\}"
          match = re.match(pattern, java_code.strip())
          if not match:
              raise ValueError("Invalid Java method format")
          return {
              "return_type": match.group(1),
              "method_name": match.group(2),
              "parameters": match.group(3),
              "body": match.group(4).strip()
          }
  
      def translate_type(java_type: str) -> str:
          type_map = {
              "int": "int",
              "String": "str",
              "double": "float",
              "boolean": "bool",
              "void": "None"
          }
          return type_map.get(java_type, "object")
  
      def translate_parameters(params: str) -> str:
          if not params:
              return ""
          param_list = params.split(",")
          translated_params = []
          for param in param_list:
              param_type, param_name = param.strip().split()
              translated_params.append(f"{param_name}: {translate_type(param_type)}")
          return ", ".join(translated_params)
  
      def translate_body(body: str) -> str:
          body = body.replace("return ", "return ")
          body = body.replace("toUpperCase()", "upper()")
          body = body.replace("toLowerCase()", "lower()")
          return body
  
      java_method = parse_java_method(java_code)
      return_type = translate_type(java_method["return_type"])
      method_name = java_method["method_name"]
      parameters = translate_parameters(java_method["parameters"])
      body = translate_body(java_method["body"])
  
      python_function = f"{method_name}({parameters}):\n return {body}"
      exec(python_function, globals())
      return globals()[method_name]
  