Skip to content

Commit d6e4338

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix/narrow_type_vs_Type
2 parents 4330ea0 + 1f200dd commit d6e4338

File tree

850 files changed

+48137
-21284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

850 files changed

+48137
-21284
lines changed

.git-blame-ignore-revs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@
66
f98f78216ba9d6ab68c8e69c19e9f3c7926c5efe
77
# run pyupgrade (#12711)
88
fc335cb16315964b923eb1927e3aad1516891c28
9+
# update black to 23.3.0 (#15059)
10+
4276308be01ea498d946a79554b4a10b1cf13ccb
11+
# Update black to 24.1.1 (#16847)
12+
8107e53158d83d30bb04d290ac10d8d3ccd344f8

.github/workflows/build_wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4
17-
- uses: actions/setup-python@v4
17+
- uses: actions/setup-python@v5
1818
with:
1919
python-version: '3.11'
2020
- name: Trigger script

.github/workflows/docs.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@ concurrency:
2828
jobs:
2929
docs:
3030
runs-on: ubuntu-latest
31+
timeout-minutes: 10
3132
env:
3233
TOXENV: docs
3334
TOX_SKIP_MISSING_INTERPRETERS: False
3435
VERIFY_MYPY_ERROR_CODES: 1
3536
steps:
3637
- uses: actions/checkout@v4
37-
- uses: actions/setup-python@v4
38+
- uses: actions/setup-python@v5
3839
with:
39-
python-version: '3.8'
40+
python-version: '3.12'
4041
- name: Install tox
41-
run: pip install --upgrade 'setuptools!=50' tox==4.11.0
42+
run: pip install tox==4.21.2
4243
- name: Setup tox environment
4344
run: tox run -e ${{ env.TOXENV }} --notest
4445
- name: Test

.github/workflows/mypy_primer.yml

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ jobs:
3232
matrix:
3333
shard-index: [0, 1, 2, 3, 4]
3434
fail-fast: false
35+
timeout-minutes: 60
3536
steps:
3637
- uses: actions/checkout@v4
3738
with:
3839
path: mypy_to_test
3940
fetch-depth: 0
40-
- uses: actions/setup-python@v4
41+
- uses: actions/setup-python@v5
4142
with:
42-
python-version: "3.10"
43+
python-version: "3.12"
4344
- name: Install dependencies
4445
run: |
4546
python -m pip install -U pip
@@ -69,18 +70,35 @@ jobs:
6970
--output concise \
7071
| tee diff_${{ matrix.shard-index }}.txt
7172
) || [ $? -eq 1 ]
72-
- name: Upload mypy_primer diff
73-
uses: actions/upload-artifact@v3
74-
with:
75-
name: mypy_primer_diffs
76-
path: diff_${{ matrix.shard-index }}.txt
77-
- if: ${{ matrix.shard-index }} == 0
73+
- if: ${{ matrix.shard-index == 0 }}
7874
name: Save PR number
7975
run: |
8076
echo ${{ github.event.pull_request.number }} | tee pr_number.txt
81-
- if: ${{ matrix.shard-index }} == 0
82-
name: Upload PR number
83-
uses: actions/upload-artifact@v3
77+
- if: ${{ matrix.shard-index == 0 }}
78+
name: Upload mypy_primer diff + PR number
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: mypy_primer_diffs-${{ matrix.shard-index }}
82+
path: |
83+
diff_${{ matrix.shard-index }}.txt
84+
pr_number.txt
85+
- name: Upload mypy_primer diff
86+
uses: actions/upload-artifact@v4
87+
if: ${{ matrix.shard-index != 0 }}
88+
with:
89+
name: mypy_primer_diffs-${{ matrix.shard-index }}
90+
path: diff_${{ matrix.shard-index }}.txt
91+
92+
join_artifacts:
93+
name: Join artifacts
94+
runs-on: ubuntu-latest
95+
needs: [mypy_primer]
96+
permissions:
97+
contents: read
98+
steps:
99+
- name: Merge artifacts
100+
uses: actions/upload-artifact/merge@v4
84101
with:
85102
name: mypy_primer_diffs
86-
path: pr_number.txt
103+
pattern: mypy_primer_diffs-*
104+
delete-merged: true

.github/workflows/mypy_primer_comment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1919
steps:
2020
- name: Download diffs
21-
uses: actions/github-script@v6
21+
uses: actions/github-script@v7
2222
with:
2323
script: |
2424
const fs = require('fs');
@@ -44,7 +44,7 @@ jobs:
4444
4545
- name: Post comment
4646
id: post-comment
47-
uses: actions/github-script@v6
47+
uses: actions/github-script@v7
4848
with:
4949
github-token: ${{ secrets.GITHUB_TOKEN }}
5050
script: |

.github/workflows/sync_typeshed.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ jobs:
1414
name: Sync typeshed
1515
if: github.repository == 'python/mypy'
1616
runs-on: ubuntu-latest
17+
timeout-minutes: 10
1718
steps:
1819
- uses: actions/checkout@v4
1920
with:
2021
fetch-depth: 0
2122
# TODO: use whatever solution ends up working for
2223
# https://github.com/python/typeshed/issues/8434
23-
- uses: actions/setup-python@v4
24+
- uses: actions/setup-python@v5
2425
with:
2526
python-version: "3.10"
2627
- name: git config

.github/workflows/test.yml

Lines changed: 85 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,54 +36,74 @@ jobs:
3636
arch: x64
3737
os: ubuntu-latest
3838
toxenv: py
39-
tox_extra_args: "-n 2"
39+
tox_extra_args: "-n 4"
4040
test_mypyc: true
4141
- name: Test suite with py38-windows-64
4242
python: '3.8'
4343
arch: x64
4444
os: windows-latest
4545
toxenv: py38
46-
tox_extra_args: "-n 2"
46+
tox_extra_args: "-n 4"
4747
- name: Test suite with py39-ubuntu
4848
python: '3.9'
4949
arch: x64
5050
os: ubuntu-latest
5151
toxenv: py
52-
tox_extra_args: "-n 2"
52+
tox_extra_args: "-n 4"
5353
- name: Test suite with py310-ubuntu
5454
python: '3.10'
5555
arch: x64
5656
os: ubuntu-latest
5757
toxenv: py
58-
tox_extra_args: "-n 2"
58+
tox_extra_args: "-n 4"
5959
- name: Test suite with py311-ubuntu, mypyc-compiled
6060
python: '3.11'
6161
arch: x64
6262
os: ubuntu-latest
6363
toxenv: py
64-
tox_extra_args: "-n 2"
64+
tox_extra_args: "-n 4"
6565
test_mypyc: true
6666
- name: Test suite with py312-ubuntu, mypyc-compiled
6767
python: '3.12'
6868
arch: x64
6969
os: ubuntu-latest
7070
toxenv: py
71-
tox_extra_args: "-n 2"
71+
tox_extra_args: "-n 4"
72+
test_mypyc: true
73+
- name: Test suite with py313-ubuntu, mypyc-compiled
74+
python: '3.13'
75+
arch: x64
76+
os: ubuntu-latest
77+
toxenv: py
78+
tox_extra_args: "-n 4"
7279
test_mypyc: true
7380

81+
# - name: Test suite with py314-dev-ubuntu
82+
# python: '3.14-dev'
83+
# arch: x64
84+
# os: ubuntu-latest
85+
# toxenv: py
86+
# tox_extra_args: "-n 4"
87+
# allow_failure: true
88+
# test_mypyc: true
89+
7490
- name: mypyc runtime tests with py39-macos
7591
python: '3.9.18'
7692
arch: x64
77-
os: macos-latest
93+
# TODO: macos-13 is the last one to support Python 3.9, change it to macos-latest when updating the Python version
94+
os: macos-13
7895
toxenv: py
79-
tox_extra_args: "-n 2 mypyc/test/test_run.py mypyc/test/test_external.py"
80-
- name: mypyc runtime tests with py38-debug-build-ubuntu
81-
python: '3.8.17'
82-
arch: x64
83-
os: ubuntu-latest
84-
toxenv: py
85-
tox_extra_args: "-n 2 mypyc/test/test_run.py mypyc/test/test_external.py"
86-
debug_build: true
96+
tox_extra_args: "-n 3 mypyc/test/test_run.py mypyc/test/test_external.py"
97+
# This is broken. See
98+
# - https://github.com/python/mypy/issues/17819
99+
# - https://github.com/python/mypy/pull/17822
100+
# - name: mypyc runtime tests with py38-debug-build-ubuntu
101+
# python: '3.8.17'
102+
# arch: x64
103+
# os: ubuntu-latest
104+
# toxenv: py
105+
# tox_extra_args: "-n 4 mypyc/test/test_run.py mypyc/test/test_external.py"
106+
# debug_build: true
87107

88108
- name: Type check our own code (py38-ubuntu)
89109
python: '3.8'
@@ -106,10 +126,11 @@ jobs:
106126
toxenv: lint
107127

108128
name: ${{ matrix.name }}
129+
timeout-minutes: 60
109130
env:
110131
TOX_SKIP_MISSING_INTERPRETERS: False
111-
# Rich (pip)
112-
FORCE_COLOR: 1
132+
# Rich (pip) -- Disable color for windows + pytest
133+
FORCE_COLOR: ${{ !(startsWith(matrix.os, 'windows-') && startsWith(matrix.toxenv, 'py')) && 1 || 0 }}
113134
# Tox
114135
PY_COLORS: 1
115136
# Mypy (see https://github.com/python/mypy/issues/7771)
@@ -118,35 +139,74 @@ jobs:
118139
MYPY_FORCE_TERMINAL_WIDTH: 200
119140
# Pytest
120141
PYTEST_ADDOPTS: --color=yes
142+
121143
steps:
122144
- uses: actions/checkout@v4
123-
- uses: actions/setup-python@v4
124-
with:
125-
python-version: ${{ matrix.python }}
126-
architecture: ${{ matrix.arch }}
145+
127146
- name: Debug build
128147
if: ${{ matrix.debug_build }}
129148
run: |
130149
PYTHONVERSION=${{ matrix.python }}
131150
PYTHONDIR=~/python-debug/python-$PYTHONVERSION
132151
VENV=$PYTHONDIR/env
133152
./misc/build-debug-python.sh $PYTHONVERSION $PYTHONDIR $VENV
153+
# TODO: does this do anything? env vars aren't passed to the next step right
134154
source $VENV/bin/activate
155+
- name: Latest dev build
156+
if: ${{ endsWith(matrix.python, '-dev') }}
157+
run: |
158+
git clone --depth 1 https://github.com/python/cpython.git /tmp/cpython --branch $( echo ${{ matrix.python }} | sed 's/-dev//' )
159+
cd /tmp/cpython
160+
echo git rev-parse HEAD; git rev-parse HEAD
161+
git show --no-patch
162+
sudo apt-get update
163+
sudo apt-get install -y --no-install-recommends \
164+
build-essential gdb lcov libbz2-dev libffi-dev libgdbm-dev liblzma-dev libncurses5-dev \
165+
libreadline6-dev libsqlite3-dev libssl-dev lzma lzma-dev tk-dev uuid-dev zlib1g-dev
166+
./configure --prefix=/opt/pythondev
167+
make -j$(nproc)
168+
sudo make install
169+
sudo ln -s /opt/pythondev/bin/python3 /opt/pythondev/bin/python
170+
sudo ln -s /opt/pythondev/bin/pip3 /opt/pythondev/bin/pip
171+
echo "/opt/pythondev/bin" >> $GITHUB_PATH
172+
- uses: actions/setup-python@v5
173+
if: ${{ !(matrix.debug_build || endsWith(matrix.python, '-dev')) }}
174+
with:
175+
python-version: ${{ matrix.python }}
176+
architecture: ${{ matrix.arch }}
177+
135178
- name: Install tox
136-
run: pip install setuptools==68.2.2 tox==4.11.0
179+
run: |
180+
echo PATH; echo $PATH
181+
echo which python; which python
182+
echo which pip; which pip
183+
echo python version; python -c 'import sys; print(sys.version)'
184+
echo debug build; python -c 'import sysconfig; print(bool(sysconfig.get_config_var("Py_DEBUG")))'
185+
echo os.cpu_count; python -c 'import os; print(os.cpu_count())'
186+
echo os.sched_getaffinity; python -c 'import os; print(len(getattr(os, "sched_getaffinity", lambda *args: [])(0)))'
187+
pip install setuptools==75.1.0 tox==4.21.2
188+
137189
- name: Compiled with mypyc
138190
if: ${{ matrix.test_mypyc }}
139191
run: |
140192
pip install -r test-requirements.txt
141193
CC=clang MYPYC_OPT_LEVEL=0 MYPY_USE_MYPYC=1 pip install -e .
194+
142195
- name: Setup tox environment
143-
run: tox run -e ${{ matrix.toxenv }} --notest
196+
run: |
197+
tox run -e ${{ matrix.toxenv }} --notest
144198
- name: Test
145199
run: tox run -e ${{ matrix.toxenv }} --skip-pkg-install -- ${{ matrix.tox_extra_args }}
200+
continue-on-error: ${{ matrix.allow_failure == 'true' }}
201+
202+
- name: Mark as success (check failures manually)
203+
if: ${{ matrix.allow_failure == 'true' }}
204+
run: exit 0
146205

147206
python_32bits:
148207
runs-on: ubuntu-latest
149208
name: Test mypyc suite with 32-bit Python
209+
timeout-minutes: 60
150210
env:
151211
TOX_SKIP_MISSING_INTERPRETERS: False
152212
# Rich (pip)
@@ -185,8 +245,8 @@ jobs:
185245
default: 3.11.1
186246
command: python -c "import platform; print(f'{platform.architecture()=} {platform.machine()=}');"
187247
- name: Install tox
188-
run: pip install setuptools==68.2.2 tox==4.11.0
248+
run: pip install setuptools==75.1.0 tox==4.21.2
189249
- name: Setup tox environment
190250
run: tox run -e py --notest
191251
- name: Test
192-
run: tox run -e py --skip-pkg-install -- -n 2 mypyc/test/
252+
run: tox run -e py --skip-pkg-install -- -n 4 mypyc/test/

.github/workflows/test_stubgenc.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test stubgenc on pybind11-mypy-demo
1+
name: Test stubgenc on pybind11_fixtures
22

33
on:
44
workflow_dispatch:
@@ -10,6 +10,7 @@ on:
1010
- 'misc/test-stubgenc.sh'
1111
- 'mypy/stubgenc.py'
1212
- 'mypy/stubdoc.py'
13+
- 'mypy/stubutil.py'
1314
- 'test-data/stubgen/**'
1415

1516
permissions:
@@ -24,12 +25,13 @@ jobs:
2425
# Check stub file generation for a small pybind11 project
2526
# (full text match is required to pass)
2627
runs-on: ubuntu-latest
28+
timeout-minutes: 10
2729
steps:
2830

2931
- uses: actions/checkout@v4
3032

3133
- name: Setup 🐍 3.8
32-
uses: actions/setup-python@v4
34+
uses: actions/setup-python@v5
3335
with:
3436
python-version: 3.8
3537

.pre-commit-config.yaml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
1-
exclude: '^(mypyc/external/)|(mypy/typeshed/)' # Exclude all vendored code from lints
1+
exclude: '^(mypyc/external/)|(mypy/typeshed/)|misc/typeshed_patches' # Exclude all vendored code from lints
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
44
rev: v4.5.0 # must match test-requirements.txt
55
hooks:
66
- id: trailing-whitespace
77
- id: end-of-file-fixer
88
- repo: https://github.com/psf/black-pre-commit-mirror
9-
rev: 23.9.1 # must match test-requirements.txt
9+
rev: 24.8.0 # must match test-requirements.txt
1010
hooks:
1111
- id: black
12+
exclude: '^(test-data/)'
1213
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: v0.1.0 # must match test-requirements.txt
14+
rev: v0.6.9 # must match test-requirements.txt
1415
hooks:
1516
- id: ruff
1617
args: [--exit-non-zero-on-fix]
18+
- repo: https://github.com/python-jsonschema/check-jsonschema
19+
rev: 0.29.4
20+
hooks:
21+
- id: check-dependabot
22+
- id: check-github-workflows
23+
- repo: https://github.com/rhysd/actionlint
24+
rev: v1.7.3
25+
hooks:
26+
- id: actionlint
27+
args: [
28+
-ignore=property "debug_build" is not defined,
29+
-ignore=property "allow_failure" is not defined,
30+
-ignore=SC2(046|086),
31+
]
1732
ci:
1833
autoupdate_schedule: quarterly

0 commit comments

Comments
 (0)