Skip to content

Commit f37ee84

Browse files
committed
Apply rule PTH208
1 parent cbd662f commit f37ee84

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

pytensor/bin/pytensor_cache.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
import os
33
import sys
4+
from pathlib import Path
45

56

67
if sys.platform == "win32":
@@ -65,11 +66,7 @@ def main():
6566
# Print a warning if some cached modules were not removed, so that the
6667
# user knows he should manually delete them, or call
6768
# pytensor-cache purge, # to properly clear the cache.
68-
items = [
69-
item
70-
for item in sorted(os.listdir(cache.dirname))
71-
if item.startswith("tmp")
72-
]
69+
items = list(Path(cache.dirname).glob("tmp*"))
7370
if items:
7471
_logger.warning(
7572
"There remain elements in the cache dir that you may "

pytensor/tensor/blas.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777

7878
import functools
7979
import logging
80-
import os
8180
import shlex
8281
import warnings
8382
from pathlib import Path
@@ -402,9 +401,9 @@ def _ldflags(
402401
include_dir=False,
403402
)
404403
for d in dirs:
405-
for f in os.listdir(d.strip('"')):
406-
if f.endswith(".so") or f.endswith(".dylib") or f.endswith(".dll"):
407-
if any(f.find(ll) >= 0 for ll in l):
404+
for f in Path(d.strip('"')).iterdir():
405+
if f.suffix in {".so", ".dylib", ".dll"}:
406+
if any(f.stem.find(ll) >= 0 for ll in l):
408407
found_dyn = True
409408
# Special treatment of clang framework. Specifically for MacOS Accelerate
410409
if "-framework" in l and "Accelerate" in l:

0 commit comments

Comments
 (0)