From 0e493f2d0a5ccb7b3a78012cebfab675539f6d54 Mon Sep 17 00:00:00 2001 From: Carol Willing Date: Mon, 20 Mar 2023 16:33:44 -0700 Subject: [PATCH] Clarify that reason is not yet implemented --- src/pyprojroot/criterion.py | 8 ++------ src/pyprojroot/here.py | 9 ++++++--- src/pyprojroot/root.py | 8 ++++---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/pyprojroot/criterion.py b/src/pyprojroot/criterion.py index 5b3762f..68e36b1 100644 --- a/src/pyprojroot/criterion.py +++ b/src/pyprojroot/criterion.py @@ -1,4 +1,5 @@ -""" +"""Set and use criteria to find the project root. + This module is inspired by the `rprojroot` library for R. See https://github.com/r-lib/rprojroot. @@ -20,11 +21,6 @@ Iterable[Callable[[Path], bool]], ] -# TODO: It would be nice to have a class that encapsulates these checks, -# so that we can implement methods like |, !, &, ^ operators - -# TODO: Refactor in a way that allows creation of reasons - def as_root_criterion( criterion: _CriterionType, diff --git a/src/pyprojroot/here.py b/src/pyprojroot/here.py index d807e3b..f404a90 100644 --- a/src/pyprojroot/here.py +++ b/src/pyprojroot/here.py @@ -1,4 +1,5 @@ -""" +"""Convenience to find the path for a file or directory relative to the root. + This module is inspired by the `here` library for R. See https://github.com/r-lib/here. @@ -28,7 +29,7 @@ def get_here() -> Tuple[Path, str]: - # TODO: This should only find_root once per session + """Return a tuple with the root path and a reason""" start = Path.cwd() path, reason = find_root_with_reason(CRITERIA, start=start) return path, reason @@ -42,12 +43,14 @@ def here( ) -> Path: """ Returns the path relative to the projects root directory. + :param relative_project_path: relative path from project root :param warn_missing: warn user if path does not exist (default=False) :return: pathlib path + + Note: `reason` is not yet implemented. """ path, reason = get_here() - # TODO: Show reason when requested if relative_project_path: path = path / relative_project_path diff --git a/src/pyprojroot/root.py b/src/pyprojroot/root.py index d2a5377..913a5ce 100644 --- a/src/pyprojroot/root.py +++ b/src/pyprojroot/root.py @@ -3,6 +3,8 @@ See https://github.com/r-lib/rprojroot. It is intended for interactive or programmatic only. + +NOTE: `reason` is not fully implemented. """ from pathlib import Path @@ -33,8 +35,9 @@ def find_root_with_reason( Recursively search parents of start path for directory matching root criterion with reason. + + NOTE: `reason` is not fully implemented. """ - # TODO: Implement reasons # Prepare inputs criterion = _as_root_criterion(criterion) @@ -45,13 +48,10 @@ def find_root_with_reason( return start, "Pass" # Iterate over all parents - # TODO: Consider adding maximum depth - # TODO: Consider limiting depth to path (e.g. "if p == stop: raise") for p in start.parents: if criterion(p): return p, "Pass" - # Not found raise RuntimeError("Project root not found.")