ImportError: DLL load failed while importing typevartuples: An Application Control policy has blocked this file.

未关闭
#21,759 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
冷清
技术栈
python
领域
devtools, tooling

调研方向

从报告中所示的 Windows 11 pre-commit 配置以及 mypy/typevartuples.py 中的导入失败入手。使用 poetry run pre-commit run --all-files 复现,然后确定被阻止的 DLL 是由 mypy 还是其 pre-commit 环境生成或打包的。完成的标准是确定原因,并建立仓库级修复或记录在案的限制。

由索引模型根据 Issue 内容生成。

描述

crash

Crash Report

On Windows 11 SAC flags mypy as having a security issues cause the publisher cannot be verified of one of the DLLs.

Traceback

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\bani5\.cache\pre-commit\repo6vsqreec\py_env-python3.13\Scripts\mypy.EXE\__main__.py", line 2, in <module>
    from mypy.__main__ import console_entry
  File "C:\Users\bani5\.cache\pre-commit\repo6vsqreec\py_env-python3.13\Lib\site-packages\mypy\__main__.py", line 9, in <module>
    from mypy.main import main, process_options
  File "mypy\main.py", line 17, in <module>
    from mypy import build, defaults, state, util
  File "mypy\build.py", line 33, in <module>
  File "mypy\semanal_main.py", line 37, in <module>
    from mypy.checker import FineGrainedDeferredNode
  File "mypy\checker.py", line 23, in <module>
  File "mypy\checkexpr.py", line 16, in <module>
    from mypy import applytype, erasetype, join, message_registry, nodes, operators, types
  File "mypy\applytype.py", line 6, in <module>
  File "mypy\subtypes.py", line 9, in <module>
  File "mypy\constraints.py", line 10, in <module>
    import mypy.typeops
  File "mypy\typeops.py", line 14, in <module>
    from mypy.checker_state import checker_state
  File "mypy\checker_state.py", line 7, in <module>
    from mypy.checker_shared import TypeCheckerSharedApi
  File "mypy\checker_shared.py", line 13, in <module>
    from mypy.errors import ErrorWatcher
  File "mypy\errors.py", line 18, in <module>
    from mypy.types import Type
  File "mypy\types.py", line 4425, in <module>
  File "mypy\expandtype.py", line 44, in <module>
    from mypy.typevartuples import split_with_instance
ImportError: DLL load failed while importing typevartuples: An Application Control policy has blocked this file.

To Reproduce

mypy is my last pre-commit hook and it fails.

poetry run pre-commit run --all-files

Your Environment

# `pre-commit install` (no flags) installs both the pre-commit and commit-msg git
# hooks, so the file checks/linters and the conventional-commit message check both run.
default_install_hook_types: [pre-commit, commit-msg]

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v6.0.0
    hooks:
      - id: end-of-file-fixer
      - id: trailing-whitespace
      - id: check-merge-conflict
      - id: no-commit-to-branch
        args: [ "--branch", "main", "--branch", "develop" ]
      - id: check-toml
      - id: check-json
      - id: mixed-line-ending
      - id: check-yaml
        args: [ "--allow-multiple-documents" ]
      - id: check-added-large-files
        args: [ "--maxkb=500" ]
      - id: check-case-conflict
      - id: check-docstring-first
      - id: check-executables-have-shebangs
      - id: check-shebang-scripts-are-executable
      - id: debug-statements
      - id: name-tests-test
        args: ['--pytest-test-first']
      - id: requirements-txt-fixer

  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.15.7
    hooks:
      - id: ruff
        args:
          - --fix
          - --target-version=py313
          - --line-length=120
          - --select=E,F,I,B,C,W,UP,ARG,PERF,PL,RET,SIM,TID,ERA,PD,PGH,PT,PYI,RUF
          - --ignore=E501,B008,PLR0913,ERA001
        language_version: python3.13
      - id: ruff-format
        args:
          - --target-version=py313
          - --line-length=120
        language_version: python3.13

  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.19.1
    hooks:
      - id: mypy
        args:
          - --config-file=pyproject.toml
          - --ignore-missing-imports
        additional_dependencies:
          - types-requests>=2.32.0
          - types-tabulate>=0.9.0
          - types-PyYAML>=6.0
          - pydantic
          - sqlalchemy[mypy]
        language_version: python3.13

  - repo: https://github.com/compilerla/conventional-pre-commit
    rev: v4.4.0
    hooks:
      - id: conventional-pre-commit
        stages: [commit-msg]
        args:
          # `types` are positional arguments (not a --types flag); --scopes is an option.
          - --scopes=api,db,config,test,docs,ci,infra,security,qa,orchestrator,worker,prompts
          - feat
          - fix
          - docs
          - style
          - refactor
          - test
          - chore
          - perf
          - ci
          - build
          - revert

OS: Windows 11

主要语言
Python
星标
20.6k
派生
3.3k
平均合并
1 天 18 小时
30 天内合并 PR
54

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

python/mypy 的其他 Issue

查看 python/mypy 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。