Skip to content

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

Description

@Bani57

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions