mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 23:02:39 +00:00
Fix ty warnings for using shutil.which on Windows
Apparently `ty` is being too strict here and warning about `Any` possibly being `PathLike` which is not supported on older Pythons.
```
error[deprecated]: The overload of `which` is deprecated
--> src\bonsai\bonsai\bim\module\drawing\operator.py:2267:34
|
2267 | command[0] = shutil.which(command[0]) or command[0]
| ^^^^^^^^^^^^ On Windows before Python 3.12, using a PathLike as `cmd` would always fail or return `None`.
error[deprecated]: The overload of `which` is deprecated
--> src\bonsai\bonsai\tool\drawing.py:1324:30
|
1324 | command[0] = shutil.which(command[0]) or command[0]
| ^^^^^^^^^^^^ On Windows before Python 3.12, using a PathLike as `cmd` would always fail or return `None`.
```
This commit is contained in:
@@ -2264,7 +2264,7 @@ class CreateSheets(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
# [["inkscape", "svg", "-o", "eps"], ["pstoedit", "-dt", "-f", "dxf:-polyaslines -mm", "eps", "dxf", "-psarg", "-dNOSAFER"]]
|
# [["inkscape", "svg", "-o", "eps"], ["pstoedit", "-dt", "-f", "dxf:-polyaslines -mm", "eps", "dxf", "-psarg", "-dNOSAFER"]]
|
||||||
commands = json.loads(svg2dxf_command)
|
commands = json.loads(svg2dxf_command)
|
||||||
for command in commands:
|
for command in commands:
|
||||||
command[0] = shutil.which(command[0]) or command[0]
|
command[0] = shutil.which(str(command[0])) or command[0]
|
||||||
subprocess.run([replacements.get(c, c) for c in command])
|
subprocess.run([replacements.get(c, c) for c in command])
|
||||||
|
|
||||||
if self.open_viewer:
|
if self.open_viewer:
|
||||||
|
|||||||
@@ -1321,7 +1321,7 @@ class Drawing(bonsai.core.tool.Drawing):
|
|||||||
commands = json.loads(user_command)
|
commands = json.loads(user_command)
|
||||||
replacements = {"path": path}
|
replacements = {"path": path}
|
||||||
for command in commands:
|
for command in commands:
|
||||||
command[0] = shutil.which(command[0]) or command[0]
|
command[0] = shutil.which(str(command[0])) or command[0]
|
||||||
subprocess.Popen([replacements.get(c, c) for c in command])
|
subprocess.Popen([replacements.get(c, c) for c in command])
|
||||||
else:
|
else:
|
||||||
if platform.system() == "Darwin":
|
if platform.system() == "Darwin":
|
||||||
|
|||||||
Reference in New Issue
Block a user