Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into nspcdef
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Aug 6, 2021
2 parents 088990d + c90026b commit b524c66
Show file tree
Hide file tree
Showing 1,345 changed files with 104,221 additions and 16,855 deletions.
59 changes: 33 additions & 26 deletions .github/workflows/mypy_primer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: Run mypy_primer

on:
# Only run on PR, since we diff against master
# pull_request_target gives us access to a write token
pull_request_target:
pull_request:
paths-ignore:
- 'docs/**'
- '**/*.rst'
Expand All @@ -12,15 +11,19 @@ on:

jobs:
mypy_primer:
name: Run mypy_primer
name: Run
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
shard-index: [0, 1, 2]
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
path: mypy_to_test
fetch-depth: 0
# pull_request_target checks out the PR base branch by default
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- uses: actions/setup-python@v2
with:
python-version: 3.8
Expand All @@ -33,30 +36,34 @@ jobs:
run: |
cd mypy_to_test
echo "new commit"
COMMIT=$(git rev-parse HEAD)
git rev-list --format=%s --max-count=1 $COMMIT
git rev-list --format=%s --max-count=1 $GITHUB_SHA
git checkout -b upstream_master origin/master
echo "base commit"
git rev-list --format=%s --max-count=1 upstream_master
echo ''
cd ..
( mypy_primer --repo mypy_to_test --new $COMMIT --old upstream_master --mypyc-compile-level 0 -o concise | tee diff.txt ) || [ $? -eq 1 ]
- name: Post comment
uses: actions/github-script@v3
# fail action if exit code isn't zero or one
(
mypy_primer \
--repo mypy_to_test \
--new $GITHUB_SHA --old upstream_master \
--num-shards 3 --shard-index ${{ matrix.shard-index }} \
--debug \
--output concise \
| tee diff_${{ matrix.shard-index }}.txt
) || [ $? -eq 1 ]
- name: Upload mypy_primer diff
uses: actions/upload-artifact@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs').promises;
try {
data = await fs.readFile('diff.txt', 'utf-8')
if (data.trim()) {
await github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Diff from [mypy_primer](https://github.com/hauntsaninja/mypy_primer), showing the effect of this PR on open source code:\n```diff\n' + data + '```'
})
}
} catch (error) {
console.log(error)
}
name: mypy_primer_diffs
path: diff_${{ matrix.shard-index }}.txt
- if: ${{ matrix.shard-index }} == 0
name: Save PR number
run: |
echo ${{ github.event.pull_request.number }} | tee pr_number.txt
- if: ${{ matrix.shard-index }} == 0
name: Upload PR number
uses: actions/upload-artifact@v2
with:
name: mypy_primer_diffs
path: pr_number.txt
99 changes: 99 additions & 0 deletions .github/workflows/mypy_primer_comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Comment with mypy_primer diff

on:
workflow_run:
workflows:
- Run mypy_primer
types:
- completed

permissions:
contents: read
pull-requests: write

jobs:
comment:
name: Comment PR from mypy_primer
runs-on: ubuntu-latest
steps:
- name: Download diffs
uses: actions/github-script@v3
with:
script: |
const fs = require('fs');
const artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
const [matchArtifact] = artifacts.data.artifacts.filter((artifact) =>
artifact.name == "mypy_primer_diffs");
const download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: "zip",
});
fs.writeFileSync("diff.zip", Buffer.from(download.data));
- run: unzip diff.zip

# Based on https://github.com/kanga333/comment-hider
- name: Hide old comments
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs')
const response = await github.issues.listComments({
issue_number: fs.readFileSync("pr_number.txt", { encoding: "utf8" }),
owner: context.repo.owner,
repo: context.repo.repo,
})
const botCommentIds = response.data
.filter(comment => comment.user.login === 'github-actions[bot]')
.map(comment => comment.node_id)
for (const id of botCommentIds) {
const resp = await github.graphql(`
mutation {
minimizeComment(input: {classifier: OUTDATED, subjectId: "${id}"}) {
minimizedComment {
isMinimized
}
}
}
`)
if (resp.errors) {
throw new Error(resp.errors)
}
}
- name: Post comment
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs')
// Keep in sync with shards produced by mypy_primer workflow
const data = (
['diff_0.txt', 'diff_1.txt', 'diff_2.txt']
.map(fileName => fs.readFileSync(fileName, { encoding: 'utf8' }))
.join('')
.substr(0, 30000) // About 300 lines
)
console.log("Diff from mypy_primer:")
console.log(data)
if (data.trim()) {
const body = 'Diff from [mypy_primer](https://github.com/hauntsaninja/mypy_primer), showing the effect of this PR on open source code:\n```diff\n' + data + '```'
await github.issues.createComment({
issue_number: fs.readFileSync("pr_number.txt", { encoding: "utf8" }),
owner: context.repo.owner,
repo: context.repo.repo,
body
})
}
8 changes: 3 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ jobs:
toxenv: py37

steps:
- uses: actions/checkout@v1
- name: initialize submodules
run: git submodule update --init
- uses: actions/setup-python@v1
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.arch }}
- name: install tox
run: pip install --upgrade 'setuptools!=50' 'virtualenv<20' tox==3.20.1
run: pip install --upgrade 'setuptools!=50' 'virtualenv<16.7.11' tox==3.20.1
- name: setup tox environment
run: tox -e ${{ matrix.toxenv }} --notest
- name: test
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/test_stubgenc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test stubgenc on pybind11-mypy-demo

on:
push:
branches: [master]
tags: ['*']
pull_request:
paths:
- 'misc/test-stubgenc.sh'
- 'mypy/stubgenc.py'
- 'mypy/stubdoc.py'
- 'test-data/stubgen/**'

jobs:
stubgenc:
# Check stub file generation for a small pybind11 project
# (full text match is required to pass)
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2

- name: Setup 🐍 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Test stubgenc
run: misc/test-stubgenc.sh
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ build/
__pycache__
*.py[cod]
*~
@*
/build
/env*/
docs/build/
docs/source/_build
mypyc/doc/_build
*.iml
/out/
.venv*/
venv/
.mypy_cache/
.incremental_checker_cache.json
.cache
Expand Down Expand Up @@ -44,6 +45,8 @@ htmlcov
bin/
lib/
include/
.python-version
pyvenv.cfg

.tox
pip-wheel-metadata
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

30 changes: 16 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,26 @@ env:
PYTHON_DEBUG_BUILD=0

jobs:
fast_finish: true
include:
# Specifically request 3.5.1 because we need to be compatible with that.
- name: "run test suite with python 3.5.1 (compiled with mypyc)"
python: 3.5.1
dist: trusty
- name: "run test suite with python 3.6 (compiled with mypyc)"
python: 3.6 # 3.6.3 pip 9.0.1
env:
- TOXENV=py
- EXTRA_ARGS="-n 2"
- TEST_MYPYC=1
- name: "run test suite with python 3.6"
python: 3.6 # 3.6.3 pip 9.0.1
- name: "run test suite with python 3.7 (compiled with mypyc)"
- name: "run test suite with python 3.7"
python: 3.7
- name: "run test suite with python 3.8"
python: 3.8
- name: "run test suite with python 3.9 (compiled with mypyc)"
python: 3.9
env:
- TOXENV=py
- EXTRA_ARGS="-n 2"
- TEST_MYPYC=1
- name: "run test suite with python 3.8"
python: 3.8
- name: "run test suite with python 3.9"
python: 3.9
- name: "run test suite with python nightly"
python: nightly
- name: "run mypyc runtime tests with python 3.6 debug build"
language: generic
env:
Expand Down Expand Up @@ -80,10 +79,13 @@ jobs:
# env:
# - TOXENV=dev
# - EXTRA_ARGS=
allow_failures:
- python: nightly

install:
- pip install -U pip setuptools
- pip install -U 'virtualenv<20'
# pip 21.0 no longer works on Python 3.5
- pip install -U pip==20.3.4 setuptools
- pip install -U 'virtualenv<16.7.11'
- pip install -U tox==3.20.1
- python2 -m pip install --user -U typing
- tox --notest
Expand All @@ -92,7 +94,7 @@ install:
# means that tox picks up the mypy from the source directories instead of
# the version it installed into a venv. This is also *why* we need to do this,
# since if we arranged for tox to build with mypyc, pytest wouldn't use it.
- if [[ $TEST_MYPYC == 1 ]]; then pip install -r mypy-requirements.txt; CC=clang MYPYC_OPT_LEVEL=0 python3 setup.py --use-mypyc build_ext --inplace; fi
- if [[ $TEST_MYPYC == 1 ]]; then pip install -r test-requirements.txt; CC=clang MYPYC_OPT_LEVEL=0 python3 setup.py --use-mypyc build_ext --inplace; fi

script:
- tox --skip-pkg-install -- $EXTRA_ARGS
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Getting started, building, and testing

If you haven't already, take a look at the project's
[README.md file](README.md)
and the [Mypy documentation](http://mypy.readthedocs.io/en/latest/),
and the [Mypy documentation](https://mypy.readthedocs.io/en/latest/),
and try adding type annotations to your file and type-checking it with Mypy.


Expand Down
7 changes: 4 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Mypy (and mypyc) are licensed under the terms of the MIT license, reproduced bel

The MIT License

Copyright (c) 2015-2019 Jukka Lehtosalo and contributors
Copyright (c) 2015-2021 Jukka Lehtosalo and contributors

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
Expand All @@ -28,8 +28,9 @@ DEALINGS IN THE SOFTWARE.

Portions of mypy and mypyc are licensed under different licenses. The
files under stdlib-samples as well as the files
mypyc/lib-rt/pythonsupport.h and mypyc/lib-rt/getargs.c are licensed
under the PSF 2 License, reproduced below.
mypyc/lib-rt/pythonsupport.h, mypyc/lib-rt/getargs.c and
mypyc/lib-rt/getargsfast.c are licensed under the PSF 2 License, reproduced
below.

= = = = =

Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

# stubs
prune mypy/typeshed
include mypy/typeshed/LICENSE
include mypy/typeshed/stdlib/VERSIONS
recursive-include mypy/typeshed *.pyi

# mypy and mypyc
Expand All @@ -28,6 +30,7 @@ graft mypyc/doc

# files necessary for testing sdist
include mypy-requirements.txt
include build-requirements.txt
include test-requirements.txt
include mypy_self_check.ini
prune misc
Expand Down
Loading

0 comments on commit b524c66

Please sign in to comment.