From 6d26ba60ff27d3359f469e863e238e12dee3394d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 10 Mar 2021 22:33:59 +0100 Subject: scripts: Add some additional checks for pathlib --- scripts/dev/misc_checks.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/dev/misc_checks.py b/scripts/dev/misc_checks.py index 91baec926..3a93b05e1 100644 --- a/scripts/dev/misc_checks.py +++ b/scripts/dev/misc_checks.py @@ -247,7 +247,23 @@ def check_spelling(args: argparse.Namespace) -> Optional[bool]: ( re.compile(fr'qtbot\.(?!{qtbot_excludes})[a-z]+[A-Z].*'), "use snake-case instead", - ) + ), + ( + re.compile(r'\.joinpath\('), + "use the / operator for joining paths", + ), + ( + re.compile(r"""pathlib\.Path\(["']~["']\)\.expanduser\(\)"""), + "use pathlib.Path.home() instead", + ), + ( + re.compile(r'pathlib\.Path\(tmp_path\)'), + "tmp_path already is a pathlib.Path", + ), + ( + re.compile(r'pathlib\.Path\(tmpdir\)'), + "use tmp_path instead", + ), ] # Files which should be ignored, e.g. because they come from another -- cgit v1.2.3-54-g00ecf