original_docstring: 
      Normalizes the path by expanding ~user on Unix, ${var} environmental vars
      (is this a good idea?), expanding %name% on Windows, normalizing path names (Windows
      turns backslashes to forward slashes, and finally if that file is not an absolute path,
      turns it from a relative path to an absolute path.
  
      v5 -- returnPathlib -- None (default) does not convert. False, returns a string,
      True, returns a pathlib.Path.
      
docstring: Normalizes the path by expanding ~user on Unix, ${var} environmental vars
  (is this a good idea?), expanding %name% on Windows, normalizing path names (Windows
  turns backslashes to forward slashes, and finally if that file is not an absolute path,
  turns it from a relative path to an absolute path.
  
  - returnPathlib -- None (default) does not convert. False, returns a string,
  True, returns a pathlib.Path.
docstring_tokens: Normalizes the path by expanding ~user on Unix $ { var } environmental vars ( is this a good idea? ) expanding %name% on Windows normalizing path names ( Windows turns backslashes to forward slashes and finally if that file is not an absolute path turns it from a relative path to an absolute path . - returnPathlib -- None ( default ) does not convert . False returns a string True returns a pathlib . Path .
code: def cleanpath(path: Union[str, pathlib.Path], *, returnPathlib=None) -> Union[str, pathlib.Path]:
      '''
      Normalizes the path by expanding ~user on Unix, ${var} environmental vars
      (is this a good idea?), expanding %name% on Windows, normalizing path names (Windows
      turns backslashes to forward slashes, and finally if that file is not an absolute path,
      turns it from a relative path to an absolute path.
  
      v5 -- returnPathlib -- None (default) does not convert. False, returns a string,
      True, returns a pathlib.Path.
      '''
      if isinstance(path, pathlib.Path):
          path = str(path)
          if returnPathlib is None:
              returnPathlib = True
      elif returnPathlib is None:
          returnPathlib = False
      path = os.path.expanduser(path)
      path = os.path.normpath(path)
      if not os.path.isabs(path):
          path = os.path.abspath(path)
  
      path = os.path.expandvars(path)
      if not returnPathlib:
          return path
      else:
          return pathlib.Path(path)
code_tokens: def cleanpath ( path : Union [ str , pathlib . Path ] , * , returnPathlib = None ) -> Union [ str , pathlib . Path ] : if isinstance ( path , pathlib . Path ) : path = str ( path ) if returnPathlib is None : returnPathlib = True elif returnPathlib is None : returnPathlib = False path = os . path . expanduser ( path ) path = os . path . normpath ( path ) if not os . path . isabs ( path ) : path = os . path . abspath ( path ) path = os . path . expandvars ( path ) if not returnPathlib : return path else : return pathlib . Path ( path )
short_docstring: Normalizes the path by expanding ~user on Unix, ${var} environmental vars
  (is this a good idea?
short_docstring_tokens: Normalizes the path by expanding ~user on Unix $ { var } environmental vars ( is this a good idea?
comment: '''
      Normalizes the path by expanding ~user on Unix, ${var} environmental vars
      (is this a good idea?), expanding %name% on Windows, normalizing path names (Windows
      turns backslashes to forward slashes, and finally if that file is not an absolute path,
      turns it from a relative path to an absolute path.
  
      v5 -- returnPathlib -- None (default) does not convert. False, returns a string,
      True, returns a pathlib.Path.
      '''