From fa80834391691f6601dfdf8df1bf23a3ce8b5c88 Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Wed, 10 Apr 2024 12:04:00 +0100 Subject: [PATCH] Update pathlib references in the general module --- brainglobe_utils/general/pathlib.py | 8 +++++++- brainglobe_utils/general/string.py | 17 +++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/brainglobe_utils/general/pathlib.py b/brainglobe_utils/general/pathlib.py index 0f5845d..1f90e85 100644 --- a/brainglobe_utils/general/pathlib.py +++ b/brainglobe_utils/general/pathlib.py @@ -1,4 +1,10 @@ -def append_to_pathlib_stem(path, string_to_append): +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from pathlib import Path + + +def append_to_pathlib_stem(path: "Path", string_to_append): """ Appends a string to the stem of a pathlib object. diff --git a/brainglobe_utils/general/string.py b/brainglobe_utils/general/string.py index b7702de..7663ad3 100644 --- a/brainglobe_utils/general/string.py +++ b/brainglobe_utils/general/string.py @@ -1,15 +1,20 @@ +from typing import TYPE_CHECKING, Optional + from natsort import natsorted from brainglobe_utils.general import list +if TYPE_CHECKING: + from pathlib import Path + def get_text_lines( - file, - return_lines=None, - rstrip=True, - sort=False, - remove_empty_lines=True, - encoding="utf8", + file: "Path", + return_lines: Optional[int] = None, + rstrip: Optional[bool] = True, + sort: Optional[bool] = False, + remove_empty_lines: Optional[bool] = True, + encoding: Optional[str] = "utf8", ): """ Return only the nth line of a text file.