Skip to content

Commit 8260201

Browse files
committed
Python: Minor refactor to use os.path.<func>
Since that's the idiomatic way to use this module
1 parent e476cde commit 8260201

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

python/ql/test/library-tests/frameworks/stdlib/FileSystemAccess.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import builtins
22
import io
3+
import os
34

45
open("filepath") # $ getAPathArgument="filepath"
56
open(file="filepath") # $ getAPathArgument="filepath"
@@ -28,13 +29,14 @@ def through_function(open_file):
2829

2930
through_function(f)
3031

31-
from os import path
32-
path.exists("filepath") # $ getAPathArgument="filepath"
33-
path.isfile("filepath") # $ getAPathArgument="filepath"
34-
path.isdir("filepath") # $ getAPathArgument="filepath"
35-
path.islink("filepath") # $ getAPathArgument="filepath"
36-
path.ismount("filepath") # $ getAPathArgument="filepath"
32+
# os.path
33+
os.path.exists("filepath") # $ getAPathArgument="filepath"
34+
os.path.isfile("filepath") # $ getAPathArgument="filepath"
35+
os.path.isdir("filepath") # $ getAPathArgument="filepath"
36+
os.path.islink("filepath") # $ getAPathArgument="filepath"
37+
os.path.ismount("filepath") # $ getAPathArgument="filepath"
3738

39+
# actual os.path implementations
3840
import posixpath
3941
import ntpath
4042
import genericpath
@@ -43,7 +45,6 @@ def through_function(open_file):
4345
ntpath.exists("filepath") # $ getAPathArgument="filepath"
4446
genericpath.exists("filepath") # $ getAPathArgument="filepath"
4547

46-
import os
47-
48+
# os
4849
os.stat("filepath") # $ getAPathArgument="filepath"
4950
os.stat(path="filepath") # $ getAPathArgument="filepath"

0 commit comments

Comments
 (0)