code: def test_comment_picker_location():
      # multiple "before" comments
      source = (
          "#: comment before assignment1\n"
          "#:\n"
          "#: comment before assignment2\n"
          "a = 1 + 1\n"
      )
      parser = Parser(source)
      parser.parse()
      assert parser.comments == {
          ("", "a"): (
              "comment before assignment1\n"
              "\n"
              "comment before assignment2"
          )
      }
  
      # before and after comments
      source = (
          "#: comment before assignment\n"
          "a = 1 + 1  #: comment after assignment\n"
      )
      parser = Parser(source)
      parser.parse()
      assert parser.comments == {("", "a"): "comment after assignment"}
  
      # after comment and next line string
      source = (
          "a = 1 + 1\n  #: comment after assignment\n"
          '"""string on next line"""\n'
      )
      parser = Parser(source)
      parser.parse()
      assert parser.comments == {("", "a"): "string on next line"}
  
      # before comment and next line string
      source = (
          "#: comment before assignment\n"
          "a = 1 + 1\n"
          '"""string on next line"""\n'
      )
      parser = Parser(source)
      parser.parse()
      assert parser.comments == {("", "a"): "string on next line"}
  
      # before comment, after comment and next line string
      source = (
          "#: comment before assignment\n"
          "a = 1 + 1  #: comment after assignment\n"
          '"""string on next line"""\n'
      )
      parser = Parser(source)
      parser.parse()
      assert parser.comments == {("", "a"): "string on next line"}
  
      # inside __init__ method
      source = (
          "class Foo(object):\n"
          "    def __init__(self):\n"
          "        #: comment before assignment\n"
          "        self.attr1 = None\n"
          "        self.attr2 = None  #: comment after assignment\n"
          "\n"
          "        #: comment for attr3(1)\n"
          "        self.attr3 = None  #: comment for attr3(2)\n"
          '        """comment for attr3(3)"""\n'
      )
      parser = Parser(source)
      parser.parse()
      assert parser.comments == {
          ("Foo", "attr1"): "comment before assignment",
          ("Foo", "attr2"): "comment after assignment",
          ("Foo", "attr3"): "comment for attr3(3)",
      }
  
imports: from sphinx.pycode.parser import Parser
  from sphinx.util.inspect import signature_from_str
label_desc: Use image node_id 2 for calling a global function with example usage: test_comment_picker_location() without return types