提交 d88f3f9e authored 作者: Michael Osthege's avatar Michael Osthege

Upgrade to mypy v0.991 and fix mypy errors

上级 5aa17801
...@@ -47,7 +47,7 @@ repos: ...@@ -47,7 +47,7 @@ repos:
)$ )$
args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable'] args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable']
- repo: https://github.com/pre-commit/mirrors-mypy - repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982 rev: v0.991
hooks: hooks:
- id: mypy - id: mypy
additional_dependencies: additional_dependencies:
......
...@@ -2440,28 +2440,29 @@ class GCC_compiler(Compiler): ...@@ -2440,28 +2440,29 @@ class GCC_compiler(Compiler):
def linking_patch(lib_dirs: List[str], libs: List[str]) -> List[str]: def linking_patch(lib_dirs: List[str], libs: List[str]) -> List[str]:
if sys.platform != "win32": if sys.platform != "win32":
return [f"-l{l}" for l in libs] return [f"-l{l}" for l in libs]
else:
def sort_key(lib): # type: ignore # In explicit else because of https://github.com/python/mypy/issues/10773
name, *numbers, extension = lib.split(".") def sort_key(lib):
return (extension == "dll", tuple(map(int, numbers))) name, *numbers, extension = lib.split(".")
return (extension == "dll", tuple(map(int, numbers)))
patched_lib_ldflags = []
for lib in libs: patched_lib_ldflags = []
ldflag = f"-l{lib}" for lib in libs:
for lib_dir in lib_dirs: ldflag = f"-l{lib}"
lib_dir = lib_dir.strip('"') for lib_dir in lib_dirs:
windows_styled_libs = [ lib_dir = lib_dir.strip('"')
fname windows_styled_libs = [
for fname in os.listdir(lib_dir) fname
if not (os.path.isdir(os.path.join(lib_dir, fname))) for fname in os.listdir(lib_dir)
and fname.split(".")[0] == lib if not (os.path.isdir(os.path.join(lib_dir, fname)))
and fname.split(".")[-1] in ["dll", "lib"] and fname.split(".")[0] == lib
] and fname.split(".")[-1] in ["dll", "lib"]
if windows_styled_libs: ]
selected_lib = sorted(windows_styled_libs, key=sort_key)[-1] if windows_styled_libs:
ldflag = f'"{os.path.join(lib_dir, selected_lib)}"' selected_lib = sorted(windows_styled_libs, key=sort_key)[-1]
patched_lib_ldflags.append(ldflag) ldflag = f'"{os.path.join(lib_dir, selected_lib)}"'
return patched_lib_ldflags patched_lib_ldflags.append(ldflag)
return patched_lib_ldflags
@staticmethod @staticmethod
def compile_str( def compile_str(
......
...@@ -1056,7 +1056,7 @@ class VMLinker(LocalLinker): ...@@ -1056,7 +1056,7 @@ class VMLinker(LocalLinker):
callback=self.callback, callback=self.callback,
callback_input=self.callback_input, callback_input=self.callback_input,
) )
elif self.use_cloop and CVM: elif self.use_cloop and CVM is not None:
# create a map from nodes to ints and vars to ints # create a map from nodes to ints and vars to ints
nodes_idx = {} nodes_idx = {}
......
...@@ -3449,7 +3449,7 @@ def profile_printer( ...@@ -3449,7 +3449,7 @@ def profile_printer(
@op_debug_information.register(Scan) # type: ignore[has-type] @op_debug_information.register(Scan) # type: ignore[has-type]
def _op_debug_information_Scan(op, node): def _op_debug_information_Scan(op: Scan, node: Apply):
from typing import Sequence from typing import Sequence
from aesara.scan.utils import ScanArgs from aesara.scan.utils import ScanArgs
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论