某些检查不成功,这就是 GitHub 操作失败并要求 "Run mypy --ignore-missing-imports" 的原因

Some checks were not successful that's why GitHub action is failing and asking for "Run mypy --ignore-missing-imports"

我在 GitHub 上的 python 中添加了一个堆排序文件,当我在其他框架上执行它时它工作得很好但是当我在 Github 上添加它时我没有不知道为什么一个 GitHub 操作每次都失败,我完全陷入其中。

这是我的代码:

def heapsort(alist):
    build_max_heap(alist)
    for i in range(len(alist) - 1, 0, -1):
        alist[0], alist[i] = alist[i], alist[0]
        max_heapify(alist, index=0, size=i)

def parent(i):
    return (i - 1)//2

def left(i):
    return 2*i + 1

def right(i):
    return 2*i + 2

def build_max_heap(alist):
    length = len(alist)
    start = parent(length - 1)
    while start >= 0:
        max_heapify(alist, index=start, size=length)
        start = start - 1

def max_heapify(alist, index, size):
    l = left(index)
    r = right(index)
    if (l < size and alist[l] > alist[index]):
        largest = l
    else:
        largest = index
    if (r < size and alist[r] > alist[largest]):
        largest = r
    if (largest != index):
        alist[largest], alist[index] = alist[index], alist[largest]
        max_heapify(alist, largest, size)


alist = input('Enter the list of numbers: ').split()
alist = [x for x in alist] 
alist = list(map(int, alist))
heapsort(alist)
print('Sorted list: ', end='')
print(alist)

这就是我面临的错误:

您可以使用 Pip-Installer 从 Github 操作到 运行 包安装脚本,请参阅此处的这篇文章。

https://github.com/marketplace/actions/pip-installer

构建中似乎缺少 mypy 包。

And/or 您可以在您的项目根目录顶部添加一个 requirements.txt 并将您的 actions.yaml 修改为此。

steps:
- uses: actions/checkout@v2
- name: Set up Python
  uses: actions/setup-python@v2
  with:
    python-version: '3.x'
- name: Install dependencies
  run: |
    python -m pip install --upgrade pip
    pip install -r requirements.txt