From bea7db537c824975cb1921761d8a6a5a3b356479 Mon Sep 17 00:00:00 2001 From: Aran-Fey Date: Tue, 9 Sep 2025 20:07:39 +0200 Subject: [PATCH] resolve absolutely incorrect usage of `Path.resolve` --- rio/cli/cloud_commands.py | 4 ++-- rio/cli/project_setup.py | 4 ++-- rio/path_match.py | 4 +++- rio/project_config.py | 2 +- .../project-template-Dashboard Better Name/utils.py | 2 +- .../snippet-files/project-template-Multipage Website/utils.py | 2 +- scripts/build_icon_set.py | 4 ++-- scripts/build_rio_api_client.py | 2 +- 8 files changed, 13 insertions(+), 11 deletions(-) diff --git a/rio/cli/cloud_commands.py b/rio/cli/cloud_commands.py index b79f3661..bd269d56 100644 --- a/rio/cli/cloud_commands.py +++ b/rio/cli/cloud_commands.py @@ -77,7 +77,7 @@ def _list_files( assert dir_path.exists(), dir_path assert dir_path.is_dir(), dir_path - dir_path = dir_path.resolve() + dir_path = dir_path.absolute() for path in dir_path.iterdir(): # Ignore files that are ignored by the project @@ -135,7 +135,7 @@ def _pack_up_project( # Find all files which are part of the project revel.print("Scanning project") - project_directory = proj.project_directory.resolve() + project_directory = proj.project_directory.absolute() files = set(_list_files(proj, project_directory)) # Make sure essential files are included diff --git a/rio/cli/project_setup.py b/rio/cli/project_setup.py index d823ee84..29667bf0 100644 --- a/rio/cli/project_setup.py +++ b/rio/cli/project_setup.py @@ -517,11 +517,11 @@ import {module_name} # TODO: Other tools like poetry!? Add a command to activate the venv? print() success("The project has been created!") - success(f"You can find it at `{project_dir.resolve()}`") + success(f"You can find it at `{project_dir.absolute()}`") print() print("To see your new project in action, run the following commands:") print() - print(f"[dim]>[/] cd {revel.shell_escape(project_dir.resolve())}") + print(f"[dim]>[/] cd {revel.shell_escape(project_dir.absolute())}") if template.dependencies: print( diff --git a/rio/path_match.py b/rio/path_match.py index f92b7980..7ea6170a 100644 --- a/rio/path_match.py +++ b/rio/path_match.py @@ -24,7 +24,7 @@ class PathMatch: *, rules: t.Iterable[str] = tuple(), ) -> None: - self._base_dir = base_dir.resolve() + self._base_dir = base_dir.absolute() self._rules: list[gitignore_parser.IgnoreRule] = [] for rule in rules: @@ -52,6 +52,8 @@ class PathMatch: """ Given a path, return whether the given path matches any of the rules. """ + path = path.absolute() + for rule in reversed(self._rules): if rule.match(path): return not rule.negation diff --git a/rio/project_config.py b/rio/project_config.py index cb115f0e..57e7dd45 100644 --- a/rio/project_config.py +++ b/rio/project_config.py @@ -226,7 +226,7 @@ class RioProjectConfig: the project's glob patterns. This does not access the file system, or perform any checks whether the - fil exists. It simply compares the path to the project's glob patterns. + file exists. It simply compares the path to the project's glob patterns. """ # This is a more complex task than it might seem at first. Use a helper # class to do the heavy lifting diff --git a/rio/snippets/snippet-files/project-template-Dashboard Better Name/utils.py b/rio/snippets/snippet-files/project-template-Dashboard Better Name/utils.py index 1a39b242..6c52f677 100644 --- a/rio/snippets/snippet-files/project-template-Dashboard Better Name/utils.py +++ b/rio/snippets/snippet-files/project-template-Dashboard Better Name/utils.py @@ -1,4 +1,4 @@ from pathlib import Path -PROJECT_ROOT_DIR = Path(__file__).resolve().parent +PROJECT_ROOT_DIR = Path(__file__).absolute().parent ASSETS_DIR = PROJECT_ROOT_DIR / "assets" diff --git a/rio/snippets/snippet-files/project-template-Multipage Website/utils.py b/rio/snippets/snippet-files/project-template-Multipage Website/utils.py index 12a23de8..3e07869e 100644 --- a/rio/snippets/snippet-files/project-template-Multipage Website/utils.py +++ b/rio/snippets/snippet-files/project-template-Multipage Website/utils.py @@ -2,7 +2,7 @@ from pathlib import Path from . import data_models -PROJECT_ROOT_DIR = Path(__file__).resolve().parent +PROJECT_ROOT_DIR = Path(__file__).absolute().parent ASSETS_DIR = PROJECT_ROOT_DIR / "assets" diff --git a/scripts/build_icon_set.py b/scripts/build_icon_set.py index 9590b285..ae0a321b 100644 --- a/scripts/build_icon_set.py +++ b/scripts/build_icon_set.py @@ -97,7 +97,7 @@ def build_icon_set( # Extract the name and variant of the icon. If this function returns # `None` the file is skipped. - parsed = icon_name_from_path(file_path.resolve()) + parsed = icon_name_from_path(file_path.absolute()) if parsed is None: revel.print(f"{file_path.name} -> [bold]skipped[/bold]") @@ -165,7 +165,7 @@ def build_icon_set( if __name__ == "__main__": - PROJECT_DIR = Path(__file__).resolve().parent.parent + PROJECT_DIR = Path(__file__).absolute().parent.parent # Clone the material-icons repoisitory from GitHub: # diff --git a/scripts/build_rio_api_client.py b/scripts/build_rio_api_client.py index 074f3613..e8205d37 100644 --- a/scripts/build_rio_api_client.py +++ b/scripts/build_rio_api_client.py @@ -2,7 +2,7 @@ import shutil import subprocess from pathlib import Path -PROJECT_ROOT_DIR = Path(__file__).parent.parent.resolve() +PROJECT_ROOT_DIR = Path(__file__).parent.parent.absolute() assert (PROJECT_ROOT_DIR / "pyproject.toml").exists()