Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find pyproject from vim relative to current file #1871

Merged
merged 6 commits into from Jun 12, 2021

Commits on Dec 15, 2020

  1. Find pyproject from vim relative to current file

    Austin Glaser committed Dec 15, 2020
    Copy the full SHA
    1e3cb97 View commit details
    Browse the repository at this point in the history

Commits on Jun 12, 2021

  1. Copy the full SHA
    483bb21 View commit details
    Browse the repository at this point in the history
  2. Finish and fix this patch (thanks Matt Wozniski!)

    Both the existing code and the proposed code are broken.
    The vim.eval() call (whether it's vim.eval("@%") or
    vim.eval("fnamemodify(getcwd(), ':t')) returns a string, and it passes
    that string to find_pyproject_toml, which expects a sequence of strings,
    not a single string, and - since a string is a sequence of single
    character strings - it gets turned into a list of ridiculous paths. I
    tested with a file called foo.py, and added a print(path_srcs) into
    find_project_root, which printed out:
    
    [
      PosixPath('/home/matt/f'),
      PosixPath('/home/matt/o'),
      PosixPath('/home/matt/o'),
      PosixPath('/home/matt'),
      PosixPath('/home/matt/p'),
      PosixPath('/home/matt/y')
    ]
    
    This does work for an unnamed buffer, too - we wind up calling
    black.find_pyproject_toml(("",)), and that winds up prepending the
    working directory to any relative paths, so "" just gets turned into
    the current working directory.
    
    Note that find_pyproject_toml needs to be passed a 1-tuple, not a
    list, because it requires something hashable (thanks to
    functools.lru_cache being used)
    
    Co-authored-by: Matt Wozniski <mwozniski@bloomberg.net>
    ichard26 and godlygeek committed Jun 12, 2021
    Copy the full SHA
    d7f1274 View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    b56b184 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    a9b9b12 View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    2a36254 View commit details
    Browse the repository at this point in the history