code: def strings_with_wrong_placed_whitespace(
      file_obj: IO[str],
  ) -> Iterable[tuple[int, str]]:
      """
      Test case for leading spaces in concated strings.
  
      For example:
  
      >>> rule = (
      ...    "We want the space at the end of the line, "
      ...    "not at the beginning"
      ... )
  
      Instead of:
  
      >>> rule = (
      ...    "We want the space at the end of the line,"
      ...    " not at the beginning"
      ... )
  
      Parameters
      ----------
      file_obj : IO
          File-like object containing the Python code to validate.
  
      Yields
      ------
      line_number : int
          Line number of unconcatenated string.
      msg : str
          Explanation of the error.
      """
  
      def has_wrong_whitespace(
          first_line: str, second_line: str
      ) -> bool:
          """
          Checking if the two lines are mattching the unwanted pattern.
  
          Parameters
          ----------
          first_line : str
              First line to check.
          second_line : str
              Second line to check.
  
          Returns
          -------
          bool
              True if the two received string match, an unwanted pattern.
  
          Notes
          -----
          The unwanted pattern that we are trying to catch is if the spaces in
          a string that is concatenated over multiple lines are placed at the
          end of each string, unless this string is ending with a
          newline character (\n).
  
          For example, this is bad:
  
          >>> rule = (
          ...    "We want the space at the end of the line,"
          ...    " not at the beginning"
          ... )
  
          And what we want is:
  
          >>> rule = (
          ...    "We want the space at the end of the line, "
          ...    "not at the beginning"
          ... )
  
          And if the string is ending with a new line character (\n) we
          do not want any trailing whitespaces after it.
  
          For example, this is bad:
  
          >>> rule = (
          ...    "We want the space at the begging of "
          ...    "the line if the previous line is ending with a \n "
          ...    "not at the end, like always"
          ... )
  
          And what we do want is:
  
          >>> rule = (
          ...    "We want the space at the begging of "
          ...    "the line if the previous line is ending with a \n"
          ...    " not at the end, like always"
          ... )
          """
          if first_line.endswith(r"\n"):
              return False
          elif first_line.startswith("  ") or second_line.startswith(
              "  "
          ):
              return False
          elif first_line.endswith("  ") or second_line.endswith("  "):
              return False
          elif (
              not first_line.endswith(" ")
          ) and second_line.startswith(" "):
              return True
          return False
  
      tokens: list = list(tokenize.generate_tokens(file_obj.readline))
  
      for first_token, second_token, third_token in zip(
          tokens, tokens[1:], tokens[2:]
      ):
          # Checking if we are in a block of concated string
          if (
              first_token.type == third_token.type == token.STRING
              and second_token.type == token.NL
          ):
              # Striping the quotes, with the string literal prefix
              first_string: str = first_token.string[
                  _get_literal_string_prefix_len(first_token.string)
                  + 1 : -1
              ]
              second_string: str = third_token.string[
                  _get_literal_string_prefix_len(third_token.string)
                  + 1 : -1
              ]
  
              if has_wrong_whitespace(first_string, second_string):
                  yield (
                      third_token.start[0],
                      (
                          "String has a space at the beginning instead "
                          "of the end of the previous string."
                      ),
                  )
  
file_path: pandas/scripts/validate_unwanted_patterns.py
imports: import argparse
  import ast
  from collections.abc import Iterable
  import sys
  import token
  import tokenize
  from typing import IO, Callable
label_desc: Use image node_id 4 for calling a global function with example usage: strings_with_wrong_placed_whitespace(file_obj) and returns: False, False, False, False, True